]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
ifupdown2 loses interfaces on second down of swp port
authorSam Tannous <stannous@cumulusnetworks.com>
Fri, 24 Apr 2015 00:19:22 +0000 (20:19 -0400)
committerSam Tannous <stannous@cumulusnetworks.com>
Wed, 3 Jun 2015 17:06:54 +0000 (13:06 -0400)
Testing Done: tested bridge and bonds with interfaces with configs

Both bridge and mstpctl modules set priv_flags on interfaces
that have configs (like link-speed) even when used as bridge-ports.
And this collision causes statemanager.ifaceobj_sync() to never get called
because ifaceobj.priv_flags is 1 (we return immediately):
The fix was to create a new iface module_flags array to carry module info.
(cherry picked from commit 56924fef20984fd959939bf7f17c3dd6fd6b137a)
(cherry picked from commit 28d96f7643e2885b1f9c17ad9324a6dbb1b0f8c7)

ifupdown2/addons/bridge.py
ifupdown2/addons/mstpctl.py
ifupdown2/ifupdown/iface.py

index ebc9fbf18402bf747978f678d4f8fa882792f28b..2a54fb2e4166c056a7b812770d62373dbfdf6585 100644 (file)
@@ -15,6 +15,9 @@ import itertools
 import re
 import time
 
+class bridgeFlags:
+    PORT_PROCESSED = 0x1
+
 class bridge(moduleBase):
     """  ifupdown2 addon module to configure linux bridges """
 
@@ -190,14 +193,10 @@ class bridge(moduleBase):
                           'example' : ['bridge-port-pvids bond0=100 bond1=200']},
                      }}
 
-    # declare some ifaceobj priv_flags.
-    # XXX: This assumes that the priv_flags is owned by this module
-    # which it is not.
-    _BRIDGE_PORT_PROCESSED = 0x1
-
     def __init__(self, *args, **kargs):
         moduleBase.__init__(self, *args, **kargs)
         self.ipcmd = None
+        self.name = self.__class__.__name__
         self.brctlcmd = None
         self._running_vidinfo = {}
         self._running_vidinfo_valid = False
@@ -787,7 +786,8 @@ class bridge(moduleBase):
                continue
             for bportifaceobj in bportifaceobjlist:
                 # Dont process bridge port if it already has been processed
-                if bportifaceobj.priv_flags & self._BRIDGE_PORT_PROCESSED:
+                if (bportifaceobj.module_flags.get(self.name,0x0) & \
+                    bridgeFlags.PORT_PROCESSED):
                     continue
                 try:
                     # Add attributes specific to the vlan aware bridge
@@ -816,7 +816,8 @@ class bridge(moduleBase):
                                                               bridge_vids,
                                                               bridge_pvid)
            self._apply_bridge_port_settings(ifaceobj, bridgename=bridgename)
-           ifaceobj.priv_flags |= self._BRIDGE_PORT_PROCESSED
+           ifaceobj.module_flags[self.name] = ifaceobj.module_flags.setdefault(self.name,0) | \
+                                              bridgeFlags.PORT_PROCESSED
            return
         if not self._is_bridge(ifaceobj):
             return
index 33ea69334b05159974c5d0e6767e96d307d32f82..2ac021ba39b3f38bb053aad4ae35313fda8b2dc8 100644 (file)
@@ -12,6 +12,9 @@ from ifupdownaddons.iproute2 import iproute2
 from ifupdownaddons.mstpctlutil import mstpctlutil
 import traceback
 
+class mstpctlFlags:
+    PORT_PROCESSED = 0x1
+
 class mstpctl(moduleBase):
     """  ifupdown2 addon module to configure mstp attributes """
 
@@ -161,14 +164,10 @@ class mstpctl(moduleBase):
                  'mstpctl-portnetwork' : 'portnetwork',
                  'mstpctl-portbpdufilter' : 'portbpdufilter'}
 
-    # declare some ifaceobj priv_flags.
-    # XXX: This assumes that the priv_flags is owned by this module
-    # which it is not.
-    _BRIDGE_PORT_PROCESSED = 0x1
-
     def __init__(self, *args, **kargs):
         moduleBase.__init__(self, *args, **kargs)
         self.ipcmd = None
+        self.name = self.__class__.__name__
         self.brctlcmd = None
         self.mstpctlcmd = None
 
@@ -342,7 +341,8 @@ class mstpctl(moduleBase):
                continue
             for bportifaceobj in bportifaceobjlist:
                 # Dont process bridge port if it already has been processed
-                if bportifaceobj.priv_flags & self._BRIDGE_PORT_PROCESSED:
+                if (bportifaceobj.module_flags.get(self.name,0x0) & \
+                    mstpctlFlags.PORT_PROCESSED):
                     continue
                 try:
                     self._apply_bridge_port_settings(bportifaceobj, 
@@ -361,7 +361,8 @@ class mstpctl(moduleBase):
                       %bridgename) == '2' else False)
             self._apply_bridge_port_settings(ifaceobj, bridgename, None,
                                              stp_on, mstpd_running)
-            ifaceobj.priv_flags |= self._BRIDGE_PORT_PROCESSED
+            ifaceobj.module_flags[self.name] = ifaceobj.module_flags.setdefault(self.name,0) | \
+                                               mstpctlFlags.PORT_PROCESSED
             return
         if not self._is_bridge(ifaceobj):
             return
index 7e3f8496f812e8d3f1e26aff7ce650a98973abba..6946cf97e56cd03fede38207f493615d0c05f96f 100644 (file)
@@ -168,6 +168,8 @@ class iface():
 
         **priv_flags**      private flags owned by module using this class
 
+        **module_flags**    module flags owned by module using this class
+
         **refcnt**          reference count, indicating number of interfaces
                             dependent on this iface
 
@@ -208,6 +210,8 @@ class iface():
         self.flags = 0x0
         """iface flags """
         self.priv_flags = 0x0
+        """iface module flags dictionary with module name: flags"""
+        self.module_flags = {}
         """iface priv flags. can be used by the external object manager """
         self.refcnt = 0
         """iface refcnt (incremented for each dependent this interface has) """
@@ -411,6 +415,7 @@ class iface():
         del odict['_config_status']
         del odict['flags']
         del odict['priv_flags']
+        del odict['module_flags']
         del odict['raw_config']
         del odict['linkstate']
         del odict['env']
@@ -430,6 +435,7 @@ class iface():
         self.linkstate = None
         self.env = None
         self.priv_flags = 0
+        self.module_flags = {}
         self.raw_config = []
         self.flags |= self._PICKLED
         self.link_type = ifaceLinkType.LINK_NA