@@ -594,8 +594,15 @@ func configProviderNic(nicName, brName string) (int, error) {
594
594
continue
595
595
}
596
596
597
+ if ! strings .HasPrefix (addr .Label , nicName ) {
598
+ if strings .HasPrefix (addr .Label , brName ) {
599
+ addr .Label = nicName + addr .Label [len (brName ):]
600
+ } else {
601
+ addr .Label = nicName
602
+ }
603
+ }
597
604
if err = netlink .AddrDel (nic , & addr ); err != nil {
598
- errMsg := fmt .Errorf ("failed to delete address %s on nic %s: %v" , addr .String (), nicName , err )
605
+ errMsg := fmt .Errorf ("failed to delete address %q on nic %s: %v" , addr .String (), nicName , err )
599
606
if errors .Is (err , syscall .EADDRNOTAVAIL ) {
600
607
// the IP address does not exist now
601
608
klog .Warning (errMsg )
@@ -605,10 +612,10 @@ func configProviderNic(nicName, brName string) (int, error) {
605
612
}
606
613
607
614
if addr .Label != "" {
608
- addr .Label = brName + strings . TrimPrefix ( addr .Label , nicName )
615
+ addr .Label = brName + addr .Label [ len ( nicName ):]
609
616
}
610
617
if err = netlink .AddrReplace (bridge , & addr ); err != nil {
611
- return 0 , fmt .Errorf ("failed to replace address %s on OVS bridge %s: %v" , addr .String (), brName , err )
618
+ return 0 , fmt .Errorf ("failed to replace address %q on OVS bridge %s: %v" , addr .String (), brName , err )
612
619
}
613
620
}
614
621
0 commit comments