From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [IPv6:2a0f:8001:1:32::40]) by lore.proxmox.com (Postfix) with ESMTPS id A3BC81FF0DF for ; Thu, 15 Oct 2026 11:26:15 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id 269922144A; Thu, 15 Oct 2026 11:26:11 +0200 (CEST) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Thu, 15 Oct 2026 11:26:04 +0200 Message-Id: From: "Christoph Heiss" To: "Gabriel Goller" Subject: Re: [PATCH ifupdown2] fix #8130: bond MAC inheritance to avoid outages on first reload X-Mailer: aerc 0.22.0 References: <20261008095634.77401-1-g.goller@proxmox.com> In-Reply-To: <20261008095634.77401-1-g.goller@proxmox.com> X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1792056364865 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.301 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Message-ID-Hash: C6IYJ52NKSKL6E3J4O6O5VVUZI6ARL7B X-Message-ID-Hash: C6IYJ52NKSKL6E3J4O6O5VVUZI6ARL7B X-MailFrom: c.heiss@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: pve-devel@lists.proxmox.com X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Thanks for backporting these fixes! On Thu Oct 8, 2026 at 11:56 AM CEST, Gabriel Goller wrote: > The netlink cache can list bond slaves in a different order than they > were initially enslaved (index vs order in config). A valid inherited > MAC is then considered invalid, which causes the first reload after boot > to flap the bond and its bridges. Including a quick reproducer would have been nice, to aid testing. For future reference (had this already ready as part of something else): /etc/network/interfaces: auto enp6s20.1 iface enp6s20.1 inet manual auto enp6s21.1 iface enp6s21.1 inet manual auto bond672 iface bond672 inet manual bond-slaves enp6s20.1 enp6s21.1 bond-mode active-backup bond-primary enp6s21.1 bond-miimon 100 Then, reboot and - w/o the patch - upon the first `ifreload -avd` would produce the following error: info: bond672: invalid bond mac detected - resetting to enp6s21.1's mac [..] > > Backport both upstream commits. > > Upstream-Link: https://github.com/CumulusNetworks/ifupdown2/pull/318 > Fixes: https://bugzilla.proxmox.com/show_bug.cgi?id=3D8130 > Signed-off-by: Gabriel Goller Could not reproduce this anymore w/ the patch applied, and the changes look sane - please consider this: Tested-by: Christoph Heiss Reviewed-by: Christoph Heiss > --- > debian/patches/series | 2 + > ...reserve-mac-inherited-from-any-slave.patch | 116 ++++++++++++++++++ > ...004-bond-fix-list-index-out-of-range.patch | 40 ++++++ > 3 files changed, 158 insertions(+) > create mode 100644 debian/patches/upstream/0003-bond-preserve-mac-inheri= ted-from-any-slave.patch > create mode 100644 debian/patches/upstream/0004-bond-fix-list-index-out-= of-range.patch > > diff --git a/debian/patches/series b/debian/patches/series > index 2865533271c9..45924c8d21dc 100644 > --- a/debian/patches/series > +++ b/debian/patches/series > @@ -16,3 +16,5 @@ upstream/0001-use-raw-strings-for-regex-to-fix-backslas= h-interpret.patch > upstream/0002-vxlan-add-support-for-IPv6-vxlan-local-tunnelip.patch > pve/0014-nlmanager-read-ipv6-devconf-disable_ipv6-attribute-t.patch > pve/0015-revert-addons-bond-warn-if-sub-interface-is-detected-on-bond-sl= ave.patch > +upstream/0003-bond-preserve-mac-inherited-from-any-slave.patch > +upstream/0004-bond-fix-list-index-out-of-range.patch > diff --git a/debian/patches/upstream/0003-bond-preserve-mac-inherited-fro= m-any-slave.patch b/debian/patches/upstream/0003-bond-preserve-mac-inherite= d-from-any-slave.patch > new file mode 100644 > index 000000000000..daa8876dfdfd > --- /dev/null > +++ b/debian/patches/upstream/0003-bond-preserve-mac-inherited-from-any-s= lave.patch > @@ -0,0 +1,116 @@ > +From 29807929cce23e0c11875c9efddea45b187e3c86 Mon Sep 17 00:00:00 2001 > +From: Julien Fortin > +Date: Tue, 28 Nov 2023 23:17:18 +0100 > +Subject: [PATCH] addons: bond: change bond mac inheritance code (any sla= ve mac > + is fine) > + > +Upstream-Link: https://github.com/CumulusNetworks/ifupdown2/pull/318 > +Signed-off-by: Julien Fortin > +--- > + ifupdown2/addons/bond.py | 90 +++++++++++++++++++++------------------- > + 1 file changed, 48 insertions(+), 42 deletions(-) > + > +diff --git a/ifupdown2/addons/bond.py b/ifupdown2/addons/bond.py > +index deb88def..b691ef44 100644 > +--- a/ifupdown2/addons/bond.py > ++++ b/ifupdown2/addons/bond.py > +@@ -901,51 +901,57 @@ def _up(self, ifaceobj, ifaceobj_getfunc=3DNone): > + bond_slaves, > + ifaceobj_getfunc, > + ) > +- > +- if not self.bond_mac_mgmt or not link_exists or ifaceobj.ge= t_attr_value_first("hwaddress"): > +- return > +- > +- # check if the bond mac address is correctly inherited from= it's > +- # first slave. There's a case where that might not be happe= ning: > +- # $ ip link show swp1 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ ip link show swp2 | grep ether > +- # link/ether 08:00:27:04:d8:02 brd ff:ff:ff:ff:ff:ff > +- # $ ip link add dev bond0 type bond > +- # $ ip link set dev swp1 master bond0 > +- # $ ip link set dev swp2 master bond0 > +- # $ ip link show bond0 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ ip link add dev bond1 type bond > +- # $ ip link set dev swp1 master bond1 > +- # $ ip link show swp1 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ ip link show swp2 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ ip link show bond0 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ ip link show bond1 | grep ether > +- # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > +- # $ > +- # ifupdown2 will automatically correct and fix this unexpec= ted behavior > +- bond_mac =3D self.cache.get_link_address(ifaceobj.name) > +- > +- if bond_slaves: > +- first_slave_ifname =3D bond_slaves[0] > +- first_slave_mac =3D self.cache.get_link_info_slave_data= _attribute( > +- first_slave_ifname, > +- Link.IFLA_BOND_SLAVE_PERM_HWADDR > +- ) > +- > +- if first_slave_mac and bond_mac !=3D first_slave_mac: > +- self.logger.info( > +- "%s: invalid bond mac detected - resetting to %= s's mac (%s)" > +- % (ifaceobj.name, first_slave_ifname, first_sla= ve_mac) > +- ) > +- self.netlink.link_set_address(ifaceobj.name, first_= slave_mac, utils.mac_str_to_int(first_slave_mac)) > ++ self.set_bond_mac(link_exists, ifaceobj, bond_slaves) > + except Exception as e: > + self.log_error(str(e), ifaceobj) > + > ++ def set_bond_mac(self, link_exists, ifaceobj, bond_slaves): > ++ if not self.bond_mac_mgmt or not link_exists or ifaceobj.get_at= tr_value_first("hwaddress"): > ++ return > ++ > ++ # check if the bond mac address is correctly inherited from it'= s > ++ # first slave. There's a case where that might not be happening= : > ++ # $ ip link show swp1 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link show swp2 | grep ether > ++ # link/ether 08:00:27:04:d8:02 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link add dev bond0 type bond > ++ # $ ip link set dev swp1 master bond0 > ++ # $ ip link set dev swp2 master bond0 > ++ # $ ip link show bond0 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link add dev bond1 type bond > ++ # $ ip link set dev swp1 master bond1 > ++ # $ ip link show swp1 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link show swp2 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link show bond0 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ ip link show bond1 | grep ether > ++ # link/ether 08:00:27:04:d8:01 brd ff:ff:ff:ff:ff:ff > ++ # $ > ++ # ifupdown2 will automatically correct and fix this unexpected = behavior > ++ # Although if the bond's mac belongs to any of its slave we won= 't update it > ++ bond_mac =3D self.cache.get_link_address(ifaceobj.name) > ++ > ++ # Get the list of slave macs > ++ bond_slave_macs =3D map( > ++ lambda slave_ifname: self.cache.get_link_info_slave_data_at= tribute(slave_ifname, Link.IFLA_BOND_SLAVE_PERM_HWADDR), > ++ bond_slaves > ++ ) > ++ > ++ if bond_slaves and bond_mac not in bond_slave_macs: > ++ first_slave_ifname =3D bond_slaves[0] > ++ first_slave_mac =3D list(bond_slave_macs)[0] > ++ > ++ if first_slave_mac and bond_mac !=3D first_slave_mac: > ++ self.logger.info( > ++ "%s: invalid bond mac detected - resetting to %s's = mac (%s)" > ++ % (ifaceobj.name, first_slave_ifname, first_slave_m= ac) > ++ ) > ++ self.netlink.link_set_address(ifaceobj.name, first_slav= e_mac, utils.mac_str_to_int(first_slave_mac)) > ++ > + def _down(self, ifaceobj, ifaceobj_getfunc=3DNone): > + bond_slaves =3D self.cache.get_slaves(ifaceobj.name) > + > diff --git a/debian/patches/upstream/0004-bond-fix-list-index-out-of-rang= e.patch b/debian/patches/upstream/0004-bond-fix-list-index-out-of-range.pat= ch > new file mode 100644 > index 000000000000..e79653eb8fd8 > --- /dev/null > +++ b/debian/patches/upstream/0004-bond-fix-list-index-out-of-range.patch > @@ -0,0 +1,40 @@ > +From 97fb31ce1af89079834d441b59a3d7be865158c4 Mon Sep 17 00:00:00 2001 > +From: Julien Fortin > +Date: Fri, 5 Jan 2024 15:57:26 +0100 > +Subject: [PATCH] addons: bond: fix 'list index out of range' error when > + removing first bond slave > + > +Upstream-Link: https://github.com/CumulusNetworks/ifupdown2/pull/318 > +Signed-off-by: Julien Fortin > +--- > + ifupdown2/addons/bond.py | 14 +++++++++----- > + 1 file changed, 9 insertions(+), 5 deletions(-) > + > +diff --git a/ifupdown2/addons/bond.py b/ifupdown2/addons/bond.py > +index b691ef44..2e6edf2d 100644 > +--- a/ifupdown2/addons/bond.py > ++++ b/ifupdown2/addons/bond.py > +@@ -936,14 +936,18 @@ def set_bond_mac(self, link_exists, ifaceobj, bond= _slaves): > + bond_mac =3D self.cache.get_link_address(ifaceobj.name) > + > + # Get the list of slave macs > +- bond_slave_macs =3D map( > +- lambda slave_ifname: self.cache.get_link_info_slave_data_at= tribute(slave_ifname, Link.IFLA_BOND_SLAVE_PERM_HWADDR), > ++ bond_slave_macs =3D list(map( > ++ lambda slave_ifname: self.cache.get_link_info_slave_data_at= tribute( > ++ slave_ifname, > ++ Link.IFLA_BOND_SLAVE_PERM_HWADDR, > ++ default=3Dlist() > ++ ), > + bond_slaves > +- ) > ++ )) > + > +- if bond_slaves and bond_mac not in bond_slave_macs: > ++ if bond_slaves and bond_slave_macs and bond_mac not in bond_sla= ve_macs: > + first_slave_ifname =3D bond_slaves[0] > +- first_slave_mac =3D list(bond_slave_macs)[0] > ++ first_slave_mac =3D bond_slave_macs[0] > + > + if first_slave_mac and bond_mac !=3D first_slave_mac: > + self.logger.info(