1
0
mirror of https://github.com/CumulusNetworks/ifupdown2.git synced 2024-05-06 15:54:50 +00:00

addons: address: clear stale svi fdb entries when svi mac is changed

Three issues:
- when `hwaddress` is removed from an SVI (on top of a bridge), the svi
mac is not resetted back to the bridge mac: fixed
- when `hwaddress` is used on an svi, stale fdb enties were added with the
bridge mac: fixed
- on ifdown we were leaving a leftover fdb entry on the deleted svi: fixed

Signed-off-by: Julien Fortin <jfortin@nvidia.com>
This commit is contained in:
Julien Fortin
2022-04-19 01:36:03 +02:00
parent 30f615f2d6
commit 4e0f16d0cf

View File

@ -424,8 +424,7 @@ class address(AddonWithIpBlackList, moduleBase):
def _get_hwaddress(self, ifaceobj):
return utils.strip_hwaddress(ifaceobj.get_attr_value_first('hwaddress'))
def _process_bridge(self, ifaceobj, up, old_mac_addr=None):
hwaddress = self._get_hwaddress(ifaceobj)
def _process_bridge(self, ifaceobj, up, hwaddress, old_mac_addr=None):
addrs = ifaceobj.get_attr_value_first('address')
arp_accept = ifaceobj.get_attr_value_first('arp-accept')
arp_accept = utils.boolean_support_binary(arp_accept)
@ -454,7 +453,8 @@ class address(AddonWithIpBlackList, moduleBase):
# mac address. The current code only checks for the statemanager for old 'hwaddress' attribute but
# couldn't find any. Now we save the mac addr before updating it, so we can later clear it from the fdb.
try:
self.iproute2.bridge_fdb_del(bridgename, old_mac_addr, vlan)
if utils.mac_str_to_int(old_mac_addr) != utils.mac_str_to_int(hwaddress):
self.iproute2.bridge_fdb_del(bridgename, old_mac_addr, vlan)
except:
pass
if up:
@ -1072,7 +1072,7 @@ class address(AddonWithIpBlackList, moduleBase):
try:
# Handle special things on a bridge
self._process_bridge(ifaceobj, True, self.process_hwaddress(ifaceobj))
self._process_bridge(ifaceobj, True, *self.process_hwaddress(ifaceobj))
except Exception as e:
self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
@ -1154,9 +1154,9 @@ class address(AddonWithIpBlackList, moduleBase):
hwaddress = self.cache.get_link_address(lower)
break
if not hwaddress:
return
return None, None
else:
return
return None, None
if not ifupdownflags.flags.PERFMODE: # system is clean
running_hwaddress = self.cache.get_link_address(ifaceobj.name)
@ -1183,7 +1183,7 @@ class address(AddonWithIpBlackList, moduleBase):
for l in ifaceobj.lowerifaces:
self.netlink.link_up(l)
return old_mac_addr
return hwaddress, old_mac_addr
def _down(self, ifaceobj, ifaceobj_getfunc=None):
try:
@ -1232,7 +1232,10 @@ class address(AddonWithIpBlackList, moduleBase):
# address.
# Handle special things on a bridge
self._process_bridge(ifaceobj, False)
hwaddress = self._get_hwaddress(ifaceobj)
if not hwaddress:
hwaddress = self.cache.get_link_address(ifaceobj.name)
self._process_bridge(ifaceobj, False, hwaddress, None)
except Exception as e:
self.logger.debug('%s : %s' %(ifaceobj.name, str(e)))
pass