Patch "bonding: restore IFF_MASTER/SLAVE flags on bond enslave ether type change" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    bonding: restore IFF_MASTER/SLAVE flags on bond enslave ether type change

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     bonding-restore-iff_master-slave-flags-on-bond-ensla.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2cc9a79e26cbe8eb4384ce7fa36a23e9dda31d1f
Author: Nikolay Aleksandrov <razor@xxxxxxxxxxxxx>
Date:   Wed Mar 15 13:18:40 2023 +0200

    bonding: restore IFF_MASTER/SLAVE flags on bond enslave ether type change
    
    [ 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: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN mode DEFAULT 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 <razor@xxxxxxxxxxxxx>
    Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 456298919d541..b2db30d5f1f45 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1744,6 +1744,19 @@ void bond_lower_state_changed(struct slave *slave)
 		slave_err(bond_dev, slave_dev, "Error: %s\n", errmsg);	\
 } while (0)
 
+/* 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 was set
+ */
+static void bond_ether_setup(struct net_device *bond_dev)
+{
+	unsigned int slave_flag = bond_dev->flags & IFF_SLAVE;
+
+	ether_setup(bond_dev);
+	bond_dev->flags |= IFF_MASTER | slave_flag;
+	bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
+}
+
 /* enslave device <slave> to bond device <master> */
 int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 		 struct netlink_ext_ack *extack)
@@ -1835,10 +1848,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 
 			if (slave_dev->type != ARPHRD_ETHER)
 				bond_setup_by_slave(bond_dev, slave_dev);
-			else {
-				ether_setup(bond_dev);
-				bond_dev->priv_flags &= ~IFF_TX_SKB_SHARING;
-			}
+			else
+				bond_ether_setup(bond_dev);
 
 			call_netdevice_notifiers(NETDEV_POST_TYPE_CHANGE,
 						 bond_dev);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux