@@ -689,6 +689,35 @@ func (nsc *NetworkServicesController) syncIpvsServices(serviceInfoMap serviceInf
689689 }
690690 }
691691
692+ // cleanup stale IPs on dummy interface
693+ glog .V (1 ).Info ("Cleaning up if any, old service IPs on dummy interface" )
694+ addrActive := make (map [string ]bool )
695+ for k , endpoints := range activeServiceEndpointMap {
696+ // verify active and its a generateIpPortId() type service
697+ if len (endpoints ) > 0 && strings .Contains (k , "-" ) {
698+ parts := strings .SplitN (k , "-" , 3 )
699+ addrActive [parts [0 ]] = true
700+ }
701+ }
702+
703+ var addrs []netlink.Addr
704+ addrs , err = netlink .AddrList (dummyVipInterface , netlink .FAMILY_V4 )
705+ if err != nil {
706+ return errors .New ("Failed to list dummy interface IPs: " + err .Error ())
707+ }
708+ for _ , addr := range addrs {
709+ isActive := addrActive [addr .IP .String ()]
710+ if ! isActive {
711+ glog .V (1 ).Infof ("Found an IP %s which is no longer needed so cleaning up" , addr .IP .String ())
712+ err := nsc .ln .ipAddrDel (dummyVipInterface , addr .IP .String ())
713+ if err != nil {
714+ glog .Errorf ("Failed to delete stale IP %s due to: %s" ,
715+ addr .IP .String (), err .Error ())
716+ continue
717+ }
718+ }
719+ }
720+
692721 // cleanup stale ipvs service and servers
693722 glog .V (1 ).Info ("Cleaning up if any, old ipvs service and servers which are no longer needed" )
694723 ipvsSvcs , err = nsc .ln .ipvsGetServices ()
0 commit comments