From 315f4f03b3cab80b9e40beb6c95136b8571125c1 Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Mon, 7 Sep 2020 12:40:40 +0200 Subject: [PATCH] addons: bond: keep link admin up after being removed from bond with kernel 4.19, slaves that are removed from a bond will be admin down, this patch makes sure that the links are admin up if they are part of the "auto" class and link-down yes is not set Signed-off-by: Julien Fortin --- ifupdown2/addons/bond.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ifupdown2/addons/bond.py b/ifupdown2/addons/bond.py index 16f6d9d..f35d7aa 100644 --- a/ifupdown2/addons/bond.py +++ b/ifupdown2/addons/bond.py @@ -387,6 +387,19 @@ class bond(Addon, moduleBase): self.netlink.link_set_protodown_off(s) except Exception as e: self.logger.error('%s: %s' % (ifaceobj.name, str(e))) + + # ip link set $slave nomaster will set the slave admin down + # if the slave has an auto stanza, we should keep it admin up + # unless link-down yes is set + slave_class_auto = False + slave_link_down = False + for obj in ifaceobj_getfunc(s) or []: + if obj.auto: + slave_class_auto = True + if obj.link_privflags & ifaceLinkPrivFlags.KEEP_LINK_DOWN: + slave_link_down = True + if slave_class_auto and not slave_link_down: + self.netlink.link_up_force(s) else: # apply link-down config changes on running slaves try: