aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/bonding/bond_netlink.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/bonding/bond_netlink.c')
-rw-r--r--drivers/net/bonding/bond_netlink.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/drivers/net/bonding/bond_netlink.c b/drivers/net/bonding/bond_netlink.c
index 5ab3c1847e67..4d97e23eb497 100644
--- a/drivers/net/bonding/bond_netlink.c
+++ b/drivers/net/bonding/bond_netlink.c
@@ -398,20 +398,31 @@ static size_t bond_get_size(const struct net_device *bond_dev)
398 0; 398 0;
399} 399}
400 400
401static int bond_option_active_slave_get_ifindex(struct bonding *bond)
402{
403 const struct net_device *slave;
404 int ifindex;
405
406 rcu_read_lock();
407 slave = bond_option_active_slave_get_rcu(bond);
408 ifindex = slave ? slave->ifindex : 0;
409 rcu_read_unlock();
410 return ifindex;
411}
412
401static int bond_fill_info(struct sk_buff *skb, 413static int bond_fill_info(struct sk_buff *skb,
402 const struct net_device *bond_dev) 414 const struct net_device *bond_dev)
403{ 415{
404 struct bonding *bond = netdev_priv(bond_dev); 416 struct bonding *bond = netdev_priv(bond_dev);
405 struct net_device *slave_dev = bond_option_active_slave_get(bond);
406 struct nlattr *targets;
407 unsigned int packets_per_slave; 417 unsigned int packets_per_slave;
408 int i, targets_added; 418 int ifindex, i, targets_added;
419 struct nlattr *targets;
409 420
410 if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond))) 421 if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond)))
411 goto nla_put_failure; 422 goto nla_put_failure;
412 423
413 if (slave_dev && 424 ifindex = bond_option_active_slave_get_ifindex(bond);
414 nla_put_u32(skb, IFLA_BOND_ACTIVE_SLAVE, slave_dev->ifindex)) 425 if (ifindex && nla_put_u32(skb, IFLA_BOND_ACTIVE_SLAVE, ifindex))
415 goto nla_put_failure; 426 goto nla_put_failure;
416 427
417 if (nla_put_u32(skb, IFLA_BOND_MIIMON, bond->params.miimon)) 428 if (nla_put_u32(skb, IFLA_BOND_MIIMON, bond->params.miimon))