]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
ifupdown2: Allow lacp parameters to be set on 802.3ad bonds
authorScott Emery <scotte@cumulusnetworks.com>
Thu, 14 Apr 2016 23:03:06 +0000 (16:03 -0700)
committerScott Emery <scotte@cumulusnetworks.com>
Fri, 15 Apr 2016 18:50:37 +0000 (11:50 -0700)
Ticket: CM-10437
Reviewed By: CCR-4480
Testing Done: Created a bond and made sure it's lacp_rate could be set fast or
slow wioth or without specifying the mode.

The current code assumes that for a bond to be in 802.3ad mode the "bond-mode"
parameter has to be specified in the list of bond attributes being set. Only
then will ifupdown2 allow the lacp_rate and lacp_bypass attributes to be set.
But since we have changed the default mode to be 802.3ad, the mode attribute no
longer needs to be specified for a bond to be in 802.3ad mode.

So, instead of doing a check for the configuration attributes to determine the
mode, the linkinfo cache is checked. And the cache is refreshed, just in case
the mode attribute has been specified and just previously been set. The order in
which the attributes are set is fixed for bonds, and the mode is always set
prior to the lacp_rate and lacp_bypass attributes.

Also, while testing this I noticed another assumption about the default value of
an attribute: min_links. A warning is displayed when min_links is not specified
or set to 0, and the mode is set to 802.3ad. Well, now that the default for
min_links is 1 it doesn't have to be specified, even if the mode is set to
802.3ad. So ifupdown2 checks the current state of min_links if it is not
specified as one of the attibutes. If it is 0, either by being specified as an
attribute or not being specified but having that value, and the mode is set to
802.3ad, a warning is displayed.

And there was this other little problem where if a bond already existed in the
linkcache it wouldn't be refreshed, even if the refresh=True parameter was
specified in the _bond_linkinfo_fill function.

addons/bond.py
ifupdownaddons/bondutil.py

index 646b32d5be6ef90401de99b80fafd69a8c28f149..882f543851d0b2ee19709d99d230e6372471cfbc 100644 (file)
@@ -168,10 +168,12 @@ class bond(moduleBase):
             if attrname == 'bond-mode' and attrval == '802.3ad':
                dattrname = 'bond-min-links'
                min_links = ifaceobj.get_attr_value_first(dattrname)
-               if not min_links or min_links == '0':
-                   self.logger.warn('%s: required attribute %s'
+               if not min_links:
+                   min_links = self.bondcmd.get_min_links(ifaceobj.name)
+               if min_links == '0':
+                   self.logger.warn('%s: attribute %s'
                         %(ifaceobj.name, dattrname) +
-                        ' not present or set to \'0\'')
+                        ' is set to \'0\'')
         elif policy_default_val:
             return policy_default_val
         return attrval
index 32250e7d069f29e40f764680e70c676f2362ba98..027f4682643e5db5f693413406e10067b67e6993 100644 (file)
@@ -68,11 +68,12 @@ class bondutil(utilsBase):
         [self._bond_linkinfo_fill_attrs(b) for b in bondstr.split()]
 
     def _bond_linkinfo_fill(self, bondname, refresh=False):
-        try:
-            linkCache.get_attr([bondname, 'linkinfo', 'slaves'])
-            return
-        except:
-            pass
+        if not refresh:
+            try:
+                linkCache.get_attr([bondname, 'linkinfo', 'slaves'])
+                return
+            except:
+                pass
         bondstr = self.read_file_oneline('/sys/class/net/bonding_masters')
         if (not bondstr or bondname not in bondstr.split()):
             raise Exception('bond %s not found' %bondname)
@@ -144,7 +145,8 @@ class bondutil(utilsBase):
             try:
                 if ((attrname not in ['lacp_rate',
                                       'lacp_bypass']) or
-                    ('mode', '802.3ad') in attrdict.items()):
+                    self._cache_check([bondname, 'linkinfo', 'mode'], '802.3ad',
+                                      True)):
                     self.write_file('/sys/class/net/%s/bonding/%s'
                                     %(bondname, attrname), attrval)
             except Exception, e: