]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: bridge: down: when ifreload_down_changed=1: purge bridge and upper devices...
authorJulien Fortin <julien@cumulusnetworks.com>
Fri, 22 Mar 2019 07:35:18 +0000 (15:35 +0800)
committerJulien Fortin <julien@cumulusnetworks.com>
Mon, 22 Apr 2019 02:56:14 +0000 (10:56 +0800)
On ifreload (down ops) we need to purge the cache entry of the bridge and its upper devices
to avoid stale values in our cache.

ifup this config, then remove bridge-vids 20, ifreload: since the bridge is removed because
of ifreload_down_changed=1, we need torecreate the vlan bridge.10 and it's configuration, the
cache is stale. We need to clear it to remove the ip 10.10.10.10/32.

auto bridge
iface bridge
      bridge-ports swp1 swp2
      bridge-vids 10 20
      bridge-vlan-aware yes

auto swp1
iface swp1
      link-speed 10000

auto swp2
iface swp2

auto bridge.10
iface bridge.10
      address 10.10.10.10/32

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
ifupdown2/addons/bridge.py
ifupdown2/ifupdownaddons/LinkUtils.py

index 901424feba7b5d3835e370c756a6939954098000..5d8ae2fed90950479324d293cab123ab0a31a19b 100644 (file)
@@ -25,6 +25,8 @@ try:
     from ifupdown2.ifupdownaddons.cache import *
     from ifupdown2.ifupdownaddons.LinkUtils import LinkUtils
     from ifupdown2.ifupdownaddons.modulebase import moduleBase
+
+    import ifupdown2.ifupdown.ifupdownconfig as ifupdownconfig
 except ImportError:
     import ifupdown.exceptions as exceptions
     import ifupdown.policymanager as policymanager
@@ -40,6 +42,8 @@ except ImportError:
     from ifupdownaddons.LinkUtils import LinkUtils
     from ifupdownaddons.modulebase import moduleBase
 
+    import ifupdown.ifupdownconfig as ifupdownconfig
+
 
 class bridgeFlags:
     PORT_PROCESSED = 0x1
@@ -2227,6 +2231,14 @@ class bridge(moduleBase):
             self.log_error('%s: %s' % (ifaceobj.name, str(e)), ifaceobj)
         try:
             netlink.link_del(ifname)
+
+            if utils.get_boolean_from_string(ifupdownconfig.config.get("ifreload_down_changed")):
+                self.ipcmd.del_cache_entry(ifname)
+                for upper in ifaceobj.upperifaces or []:
+                    try:
+                        self.ipcmd.del_cache_entry(upper)
+                    except:
+                        pass
         except Exception as e:
             ifaceobj.set_status(ifaceStatus.ERROR)
             self.logger.error(str(e))
index 368441482f1ae851e22e0b5b24dd1579c2456860..f3ae9403c7f527b0b18bb00d43a3beec2772b847 100644 (file)
@@ -700,6 +700,12 @@ class LinkUtils(utilsBase):
         [linkCache.update_attrdict([ifname], linkattrs)
          for ifname, linkattrs in linkout.items()]
 
+    def del_cache_entry(self, ifname):
+        try:
+            del linkCache.links[ifname]
+        except:
+            pass
+
     def cache_get(self, t, attrlist, refresh=False):
         return self._cache_get(t, attrlist, refresh)