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

addons: bond: add support for es-sys-mac and es-bonds

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>
This commit is contained in:
Julien Fortin
2020-05-13 20:27:21 +02:00
parent 85d04bab16
commit 9808982edf
4 changed files with 46 additions and 4 deletions

8
debian/changelog vendored
View 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

View 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)),

View 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)

View 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)