From nobody Mon Dec 1 22:37:45 2025 Received: from mail-gw02.astralinux.ru (mail-gw02.astralinux.ru [93.188.205.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5DFD3303CAB; Fri, 28 Nov 2025 13:21:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=93.188.205.243 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336108; cv=none; b=D2RKC+1LdeXxSdsX5srTMns+LI5C7xVWRPCJvuKoEhFf9IsmKELE5hgNAFVFxxnDHPYu6yga9OcnxY9zDzNdwABS9jeB9kLW63UlAdlSnXxdlskowZIprlKtAETo8+jsKFlXJ7vsd3zQQ5iD3dGopa0oXuF+Za1DNde0OovFHEk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764336108; c=relaxed/simple; bh=5MwlDraxyNlmirgOdWC70LRDoKS3QWroy32Zqswic8U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eImCTwoVZhnkx+6vBBsEwCYE/VHYfMTDzd3YzSZLnaD/mwCGA2GTbuyrJB2J/DFAD8zUDmypOEjKy3USxJoq1REcE7Fel24ysi8yJcXwgFXCKWwSGzO6giO0h5B2uFXM1wNJ8BXtrSm+14NAutmzZTTp+HachvuDeiq6W6Sz10g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru; spf=pass smtp.mailfrom=astralinux.ru; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b=iEYthXr7; arc=none smtp.client-ip=93.188.205.243 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=astralinux.ru Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=astralinux.ru header.i=@astralinux.ru header.b="iEYthXr7" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=astralinux.ru; s=mail; t=1764336104; bh=5MwlDraxyNlmirgOdWC70LRDoKS3QWroy32Zqswic8U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iEYthXr7hVGMu+POu20QmNfAEi2+D9lQlGw7v7yUlMbAIGGNccmYyeawHbaMQyXkE cJyxFOOG9W3xxx3wu73mU2hcfqrWYVPYhBWi2b1/VRWLjOvoDsADzOdesdLI6PbCer uadrtGrNgbozczLXHRaBo5M4ILvfc/FdfpfpHlrC1AieO3RSb+6lJ2oqnP9q2Qpu+E n2QVWd7+PdLGifT5MJZpBlGPWx0Y/HS3Z+VU1OT2ErqufexJLkriaq8O4P9F4ZZG6A yWLtmIxh0LBglWgPosj+O9+iUHFJxbb6TP2wVbOYqqoSJadMYh1IgjPfVioc9mT/O2 XmLsE6SNX0R7w== Received: from gca-msk-a-srv-ksmg01 (localhost [127.0.0.1]) by mail-gw02.astralinux.ru (Postfix) with ESMTP id 3922F1F9C1; Fri, 28 Nov 2025 16:21:44 +0300 (MSK) Received: from new-mail.astralinux.ru (unknown [10.205.207.13]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail-gw02.astralinux.ru (Postfix) with ESMTPS; Fri, 28 Nov 2025 16:21:43 +0300 (MSK) Received: from rbta-msk-lt-156703.astralinux.ru.astracloud.ru (rbta-msk-lt-156703.astralinux.ru [10.198.57.41]) by new-mail.astralinux.ru (Postfix) with ESMTPA id 4dHv8M5RpRzJqN0; Fri, 28 Nov 2025 16:21:39 +0300 (MSK) From: Alexey Panov To: stable@vger.kernel.org, Greg Kroah-Hartman Cc: Alexey Panov , Jay Vosburgh , Veaceslav Falico , Andy Gospodarek , "David S. Miller" , Jakub Kicinski , Moni Shoua , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Nikolay Aleksandrov , bpf@vger.kernel.org, lvc-project@linuxtesting.org, Nikolay Aleksandrov Subject: [PATCH 5.10 v3 1/3] bonding: restore IFF_MASTER/SLAVE flags on bond enslave ether type change Date: Fri, 28 Nov 2025 16:21:24 +0300 Message-Id: <20251128132126.7467-2-apanov@astralinux.ru> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20251128132126.7467-1-apanov@astralinux.ru> References: <20251128132126.7467-1-apanov@astralinux.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-KSMG-AntiPhishing: NotDetected X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Envelope-From: apanov@astralinux.ru X-KSMG-AntiSpam-Info: LuaCore: 81 0.3.81 2adfceff315e7344370a427642ad41a4cfd99e1f, {Tracking_uf_ne_domains}, {Tracking_from_domain_doesnt_match_to}, {Tracking_spam_in_reply_from_match_msgid}, d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;astralinux.ru:7.1.1;new-mail.astralinux.ru:7.1.1;127.0.0.199:7.1.2, FromAlignment: s X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiSpam-Lua-Profiles: 198520 [Nov 28 2025] X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Version: 6.1.1.20 X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.1.0.7854, bases: 2025/11/28 12:43:00 #27986045 X-KSMG-AntiVirus-Status: NotDetected, skipped X-KSMG-LinksScanning: NotDetected X-KSMG-Message-Action: skipped X-KSMG-Rule-ID: 1 Content-Type: text/plain; charset="utf-8" From: Nikolay Aleksandrov [ Upstream commit 9ec7eb60dcbcb6c41076defbc5df7bbd95ceaba5 ] Add bond_ether_setup helper which is used to fix ether_setup() calls in the bonding driver. It takes care of both IFF_MASTER and IFF_SLAVE flags, the former is always restored and the latter only if it was set. If the bond enslaves non-ARPHRD_ETHER device (changes its type), then releases it and enslaves ARPHRD_ETHER device (changes back) then we use ether_setup() to restore the bond device type but it also resets its flags and removes IFF_MASTER and IFF_SLAVE[1]. Use the bond_ether_setup helper to restore both after such transition. [1] reproduce (nlmon is non-ARPHRD_ETHER): $ ip l add nlmon0 type nlmon $ ip l add bond2 type bond mode active-backup $ ip l set nlmon0 master bond2 $ ip l set nlmon0 nomaster $ ip l add bond1 type bond (we use bond1 as ARPHRD_ETHER device to restore bond2's mode) $ ip l set bond1 master bond2 $ ip l sh dev bond2 37: bond2: mtu 1500 qdisc noop state DOWN mode DEFAU= LT group default qlen 1000 link/ether be:d7:c5:40:5b:cc brd ff:ff:ff:ff:ff:ff promiscuity 0 minmtu= 68 maxmtu 1500 (notice bond2's IFF_MASTER is missing) Fixes: e36b9d16c6a6 ("bonding: clean muticast addresses when device changes= type") Signed-off-by: Nikolay Aleksandrov Signed-off-by: David S. Miller Signed-off-by: Alexey Panov --- drivers/net/bonding/bond_main.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_mai= n.c index 08bc930afc4c..127242101c8e 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c @@ -1691,6 +1691,19 @@ void bond_lower_state_changed(struct slave *slave) netdev_lower_state_changed(slave->dev, &info); } =20 +/* The bonding driver uses ether_setup() to convert a master bond device + * to ARPHRD_ETHER, that resets the target netdevice's flags so we always + * have to restore the IFF_MASTER flag, and only restore IFF_SLAVE if it w= as set + */ +static void bond_ether_setup(struct net_device *bond_dev) +{ + unsigned int slave_flag =3D bond_dev->flags & IFF_SLAVE; + + ether_setup(bond_dev); + bond_dev->flags |=3D IFF_MASTER | slave_flag; + bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; +} + /* enslave device to bond device */ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev, struct netlink_ext_ack *extack) @@ -1777,10 +1790,8 @@ int bond_enslave(struct net_device *bond_dev, struct= net_device *slave_dev, =20 if (slave_dev->type !=3D ARPHRD_ETHER) bond_setup_by_slave(bond_dev, slave_dev); - else { - ether_setup(bond_dev); - bond_dev->priv_flags &=3D ~IFF_TX_SKB_SHARING; - } + else + bond_ether_setup(bond_dev); =20 call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE, bond_dev); --=20 2.30.2