]> git.proxmox.com Git - mirror_ifupdown2.git/commitdiff
addons: bond: add support for es-sys-mac and es-bonds
authorJulien Fortin <julien@cumulusnetworks.com>
Wed, 13 May 2020 18:27:21 +0000 (20:27 +0200)
committerJulien Fortin <julien@cumulusnetworks.com>
Wed, 13 May 2020 18:27:21 +0000 (20:27 +0200)
ES bonds have the same "init state" requirements as CLAG bonds -
1. A bond needs to be designated as an "es-bond" for this purpose.
For clag-bonds we used "clag-id" attr (to designate a bond as a "clag-bond").
For ES bonds we will use "es-sys-mac" attr.

2. Slaves added to an "ES bond" must have protodown-on.
This is again similar to CLAG bonds

3. And vice-versa i.e. when a slave is removed from an "es-bond",
protodown-on must be cleared.

4. When es-sys-mac is first set on a bond, all the bond-slaves must be
placed in "protodown-on" state. This is needed whether FRR is running at that point or not.

Signed-off-by: Julien Fortin <julien@cumulusnetworks.com>
debian/changelog
ifupdown2/addons/bond.py
ifupdown2/ifupdown/iface.py
ifupdown2/lib/nlcache.py

index aa1f2ad6e0ab67c83ea6ff399444b4c1d40f268c..a62cd1dfbe443d6f24ce162caf0944cddc9847a1 100644 (file)
@@ -1,3 +1,9 @@
+ifupdown2 (3.0.1-1) unstable; urgency=medium
+
+   * New. Enabled: ES bond with "es-sys-mac" attribute
+
+ -- Julien Fortin <julien@cumulusnetworks.com>  Tue, 14 Apr 2020 23:42:42 +0200
+
 ifupdown2 (3.0.0-1) unstable; urgency=medium
 
    * New. Enabled: python3 support
@@ -12,7 +18,7 @@ ifupdown2 (3.0.0-1) unstable; urgency=medium
    * Fix: mstpctl: check mstpctl-stp and bridge-stp and fix bridge cache update
    * Removing python-argcomplete dependency
 
- -- Julien Fortin <julien@cumulusnetworks.com>  Tue, 14 Apr 2020 19:10:49 +0200
+ -- Julien Fortin <julien@cumulusnetworks.com>  Tue, 14 Apr 2020 23:42:42 +0200
 
 ifupdown2 (2.0.2-1) unstable; urgency=medium
 
index 415ee68082db7138a98f017fafd1448f3132c3aa..41c90f09b63c1ac6946a5dc4a2a8ef5ebfb3f2c7 100644 (file)
@@ -171,6 +171,11 @@ class bond(Addon, moduleBase):
                     "2", "failure",
                 ],
                 "example": ["bond-primary-reselect failure"]
+            },
+            "es-sys-mac": {
+                "help": "evpn-mh: system mac address",
+                "validvals": ["<mac>", ],
+                "example": ["bond-ad-actor-system 00:00:00:00:00:42"],
             }
         }
     }
@@ -184,6 +189,7 @@ class bond(Addon, moduleBase):
         'bond-min-links': Link.IFLA_BOND_MIN_LINKS,
         'bond-num-grat-arp': Link.IFLA_BOND_NUM_PEER_NOTIF,
         'bond-num-unsol-na': Link.IFLA_BOND_NUM_PEER_NOTIF,
+        'es-sys-mac': Link.IFLA_BOND_AD_ACTOR_SYSTEM,
         'bond-ad-sys-mac-addr': Link.IFLA_BOND_AD_ACTOR_SYSTEM,
         'bond-ad-actor-system': Link.IFLA_BOND_AD_ACTOR_SYSTEM,
         'bond-ad-sys-priority': Link.IFLA_BOND_AD_ACTOR_SYS_PRIO,
@@ -231,6 +237,7 @@ class bond(Addon, moduleBase):
         ('bond-use-carrier', Link.IFLA_BOND_USE_CARRIER, lambda x: int(utils.get_boolean_from_string(x))),
         ('bond-lacp-rate', Link.IFLA_BOND_AD_LACP_RATE, lambda x: int(utils.get_boolean_from_string(x))),
         ('bond-lacp-bypass-allow', Link.IFLA_BOND_AD_LACP_BYPASS, lambda x: int(utils.get_boolean_from_string(x))),
+        ('es-sys-mac', Link.IFLA_BOND_AD_ACTOR_SYSTEM, str),
         ('bond-ad-sys-mac-addr', Link.IFLA_BOND_AD_ACTOR_SYSTEM, str),
         ('bond-ad-actor-system', Link.IFLA_BOND_AD_ACTOR_SYSTEM, str),
         ('bond-primary-reselect', Link.IFLA_BOND_PRIMARY_RESELECT, lambda x: Link.ifla_bond_primary_reselect_tbl[x])
@@ -276,6 +283,9 @@ class bond(Addon, moduleBase):
         ifaceobj.link_kind |= ifaceLinkKind.BOND
         ifaceobj.role |= ifaceRole.MASTER
 
+        if ifaceobj.get_attr_value("es-sys-mac"):
+            ifaceobj.link_privflags |= ifaceLinkPrivFlags.ES_BOND
+
         return slave_list
 
     def syntax_check(self, ifaceobj, ifaceobj_getfunc):
@@ -340,9 +350,10 @@ class bond(Addon, moduleBase):
             if self.cache.link_is_up(slave):
                 self.netlink.link_down_force(slave)
                 link_up = True
-            # If clag bond place the slave in a protodown state; clagd
-            # will protoup it when it is ready
-            if clag_bond:
+
+            # if clag or ES bond: place the slave in a protodown state;
+            # (clagd will proto-up it when it is ready)
+            if clag_bond or ifaceobj.link_privflags & ifaceLinkPrivFlags.ES_BOND:
                 try:
                     self.netlink.link_set_protodown_on(slave)
                 except Exception as e:
@@ -599,6 +610,12 @@ class bond(Addon, moduleBase):
 
                 for lower_dev in ifaceobj.lowerifaces:
                     self.netlink.link_set_nomaster(lower_dev)
+
+                    # when unslaving a device from an ES bond we need to set
+                    # protodown off
+                    if ifaceobj.link_privflags & ifaceLinkPrivFlags.ES_BOND:
+                        self.netlink.link_set_protodown_off(lower_dev)
+
                     try:
                         bond_slaves.remove(lower_dev)
                     except:
@@ -772,6 +789,7 @@ class bond(Addon, moduleBase):
             'bond-lacp-rate': self.translate_nl_value_slowfast(cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_AD_LACP_RATE)),
             'bond-min-links': cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_MIN_LINKS),
             'bond-ad-actor-system': cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_AD_ACTOR_SYSTEM),
+            'es-sys-mac': cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_AD_ACTOR_SYSTEM),
             'bond-ad-actor-sys-prio': cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_AD_ACTOR_SYS_PRIO),
             'bond-xmit-hash-policy': Link.ifla_bond_xmit_hash_policy_pretty_tbl.get(cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_XMIT_HASH_POLICY)),
             'bond-lacp-bypass-allow': self.translate_nl_value_yesno(cached_vxlan_ifla_info_data.get(Link.IFLA_BOND_AD_LACP_BYPASS)),
index bb24050d1af6034fff8e02100cc9126899155d12..ab1b8373d2c537ef732fe92017b8b2d3efe9b8a7 100644 (file)
@@ -89,6 +89,7 @@ class ifaceLinkPrivFlags():
     LOOPBACK = 0x1000000
     KEEP_LINK_DOWN = 0x10000000
     MGMT_INTF = 0x100000000
+    ES_BOND = 0x1000000000
 
     @classmethod
     def get_str(cls, flag):
@@ -118,6 +119,9 @@ class ifaceLinkPrivFlags():
         if flag & cls.KEEP_LINK_DOWN:
             string_list.append("keep ling down")
 
+        if flag & cls.ES_BOND:
+            string_list.append("es bond")
+
         return ", ".join(string_list)
 
 
index 73266590e6b04b5fcfc2b0688a449a0790233d86..5de84b95d7e23d1471d23d9f958f2f67231e793d 100644 (file)
@@ -694,6 +694,14 @@ class _NetlinkCache:
         """
         return self.get_link_attribute(ifname, Link.IFLA_IFALIAS)
 
+    def get_link_protodown(self, ifname):
+        """
+        Return link IFLA_PROTO_DOWN
+        :param ifname:
+        :return: int
+        """
+        return self.get_link_attribute(ifname, Link.IFLA_PROTO_DOWN)
+
     def get_link_attribute(self, ifname, attr, default=None):
         """
         Return link attribute 'attr'.value
@@ -2486,6 +2494,9 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
         """
         Bring ifname up by setting IFLA_PROTO_DOWN on
         """
+        if self.cache.get_link_protodown(ifname) == 1:
+            return True
+
         self.logger.info("%s: netlink: set link %s protodown on" % (ifname, ifname))
         try:
             self.__link_set_protodown(ifname, 1)
@@ -2496,6 +2507,9 @@ class NetlinkListenerWithCache(nllistener.NetlinkManagerWithListener, BaseObject
         """
         Take ifname down by setting IFLA_PROTO_DOWN off
         """
+        if self.cache.get_link_protodown(ifname) == 0:
+            return True
+
         self.logger.info("%s: netlink: set link %s protodown off" % (ifname, ifname))
         try:
             self.__link_set_protodown(ifname, 0)