bonding: remove locking from bond_set_rx_mode()
authorVeaceslav Falico <vfalico@redhat.com>
Mon, 5 Aug 2013 12:56:06 +0000 (14:56 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 5 Aug 2013 19:22:53 +0000 (12:22 -0700)
We're already protected by RTNL lock, so nothing can happen to bond/its
slaves, and thus the locking is useless here (both bond->lock and
bond->curr_active_slave).

Also, add ASSERT_RTNL() both to bond_set_rx_mode() and bond_hw_addr_swap()
to catch possible uses of it without RTNL locking.

This patch also saves us from a lockdep false-positive in
bond_set_rx_mode() vs bond_hw_addr_swap().

CC: Jay Vosburgh <fubar@us.ibm.com>
CC: Andy Gospodarek <andy@greyhouse.net>
CC: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
Signed-off-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_main.c

index d58237b3dd98d4c45d2f4b08796a6a3dfb24eb67..5697043eafbda57d079a4ea0ba68de41ba4f1d28 100644 (file)
@@ -776,6 +776,8 @@ static void bond_hw_addr_flush(struct net_device *bond_dev,
 static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
                              struct slave *old_active)
 {
+       ASSERT_RTNL();
+
        if (old_active) {
                if (bond->dev->flags & IFF_PROMISC)
                        dev_set_promiscuity(old_active->dev, -1);
@@ -3551,24 +3553,20 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
        struct bonding *bond = netdev_priv(bond_dev);
        struct slave *slave;
 
-       read_lock(&bond->lock);
+       ASSERT_RTNL();
 
        if (USES_PRIMARY(bond->params.mode)) {
-               read_lock(&bond->curr_slave_lock);
-               slave = bond->curr_active_slave;
+               slave = rtnl_dereference(bond->curr_active_slave);
                if (slave) {
                        dev_uc_sync(slave->dev, bond_dev);
                        dev_mc_sync(slave->dev, bond_dev);
                }
-               read_unlock(&bond->curr_slave_lock);
        } else {
                bond_for_each_slave(bond, slave) {
                        dev_uc_sync_multiple(slave->dev, bond_dev);
                        dev_mc_sync_multiple(slave->dev, bond_dev);
                }
        }
-
-       read_unlock(&bond->lock);
 }
 
 static int bond_neigh_init(struct neighbour *n)