@@ -482,49 +482,33 @@ func configureNic(link, ip string, macAddr net.HardwareAddr, mtu int) error {
482
482
return nil
483
483
}
484
484
485
- func configProviderPort ( providerInterfaceName string ) error {
486
- output , err := ovs .Exec (ovs .MayExist , "add-br" , util . UnderlayBridge )
485
+ func configExternalBridge ( provider , bridge string ) error {
486
+ output , err := ovs .Exec (ovs .MayExist , "add-br" , bridge )
487
487
if err != nil {
488
- return fmt .Errorf ("failed to create bridge %s, %v: %q" , util . UnderlayBridge , err , output )
488
+ return fmt .Errorf ("failed to create bridge %s, %v: %q" , bridge , err , output )
489
489
}
490
490
output , err = ovs .Exec (ovs .IfExists , "get" , "open" , "." , "external-ids:ovn-bridge-mappings" )
491
491
if err != nil {
492
492
return fmt .Errorf ("failed to get external-ids, %v" , err )
493
493
}
494
- bridgeMappings := fmt .Sprintf ("%s:%s" , providerInterfaceName , util .UnderlayBridge )
495
- if output != "" && ! util .IsStringIn (bridgeMappings , strings .Split (output , "," )) {
494
+
495
+ bridgeMappings := fmt .Sprintf ("%s:%s" , provider , bridge )
496
+ if util .IsStringIn (bridgeMappings , strings .Split (output , "," )) {
497
+ return nil
498
+ }
499
+ if output != "" {
496
500
bridgeMappings = fmt .Sprintf ("%s,%s" , output , bridgeMappings )
497
501
}
498
-
499
- output , err = ovs .Exec ("set" , "open" , "." , fmt .Sprintf ("external-ids:ovn-bridge-mappings=%s" , bridgeMappings ))
500
- if err != nil {
502
+ if output , err = ovs .Exec ("set" , "open" , "." , "external-ids:ovn-bridge-mappings=" + bridgeMappings ); err != nil {
501
503
return fmt .Errorf ("failed to set bridge-mappings, %v: %q" , err , output )
502
504
}
503
505
504
506
return nil
505
507
}
506
508
507
- func providerBridgeExists () (bool , error ) {
508
- output , err := ovs .Exec ("list-br" )
509
- if err != nil {
510
- klog .Errorf ("failed to list bridge %v" , err )
511
- return false , err
512
- }
513
-
514
- lines := strings .Split (output , "\n " )
515
- for _ , l := range lines {
516
- if l == util .UnderlayBridge {
517
- return true , nil
518
- }
519
- }
520
-
521
- return false , nil
522
- }
523
-
524
- // Add host nic to br-provider
525
- // MAC, MTU, IP addresses & routes will be copied/transferred to br-provider
526
- func configProviderNic (nicName string ) error {
527
- brName := util .UnderlayBridge
509
+ // Add host nic to external bridge
510
+ // Mac address, MTU, IP addresses & routes will be copied/transferred to the external bridge
511
+ func configProviderNic (nicName , brName string ) error {
528
512
nic , err := netlink .LinkByName (nicName )
529
513
if err != nil {
530
514
return fmt .Errorf ("failed to get nic by name %s: %v" , nicName , err )
0 commit comments