Skip to content

Commit b324187

Browse files
Veaceslav Falicodavem330
authored andcommitted
bonding: RCUify bond_set_rx_mode()
Currently we rely on rtnl locking in bond_set_rx_mode(), however it's not always the case: RTNL: assertion failed at drivers/net/bonding/bond_main.c (3391) ... [<ffffffff81651ca5>] dump_stack+0x54/0x74 [<ffffffffa029e717>] bond_set_rx_mode+0xc7/0xd0 [bonding] [<ffffffff81553af7>] __dev_set_rx_mode+0x57/0xa0 [<ffffffff81557ff8>] __dev_mc_add+0x58/0x70 [<ffffffff81558020>] dev_mc_add+0x10/0x20 [<ffffffff8161e26e>] igmp6_group_added+0x18e/0x1d0 [<ffffffff81186f76>] ? kmem_cache_alloc_trace+0x236/0x260 [<ffffffff8161f80f>] ipv6_dev_mc_inc+0x29f/0x320 [<ffffffff8161f9e7>] ipv6_sock_mc_join+0x157/0x260 ... Fix this by using RCU primitives. Reported-by: Joe Lawrence <joe.lawrence@stratus.com> Tested-by: Joe Lawrence <joe.lawrence@stratus.com> CC: Jay Vosburgh <fubar@us.ibm.com> CC: Andy Gospodarek <andy@greyhouse.net> Signed-off-by: Veaceslav Falico <vfalico@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent eea3b20 commit b324187

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

‎drivers/net/bonding/bond_main.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3393,20 +3393,21 @@ static void bond_set_rx_mode(struct net_device *bond_dev)
33933393
struct list_head *iter;
33943394
struct slave *slave;
33953395

3396-
ASSERT_RTNL();
33973396

3397+
rcu_read_lock();
33983398
if (USES_PRIMARY(bond->params.mode)) {
3399-
slave = rtnl_dereference(bond->curr_active_slave);
3399+
slave = rcu_dereference(bond->curr_active_slave);
34003400
if (slave) {
34013401
dev_uc_sync(slave->dev, bond_dev);
34023402
dev_mc_sync(slave->dev, bond_dev);
34033403
}
34043404
} else {
3405-
bond_for_each_slave(bond, slave, iter) {
3405+
bond_for_each_slave_rcu(bond, slave, iter) {
34063406
dev_uc_sync_multiple(slave->dev, bond_dev);
34073407
dev_mc_sync_multiple(slave->dev, bond_dev);
34083408
}
34093409
}
3410+
rcu_read_unlock();
34103411
}
34113412

34123413
static int bond_neigh_init(struct neighbour *n)

0 commit comments

Comments
 (0)