bonding: get rid of bond_option_active_slave_get()
authorEric Dumazet <edumazet@google.com>
Tue, 15 Jul 2014 13:56:53 +0000 (06:56 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 16 Jul 2014 00:49:41 +0000 (17:49 -0700)
Only keep bond_option_active_slave_get_rcu() helper.

bond_fill_info() uses a new bond_option_active_slave_get_ifindex()
helper.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Acked-by: Veaceslav Falico <vfalico@gmail.com>
Reviewed-by: Nikolay Aleksandrov <nikolay@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/bonding/bond_netlink.c
drivers/net/bonding/bond_options.c
drivers/net/bonding/bonding.h

index 5ab3c18..4d97e23 100644 (file)
@@ -398,20 +398,31 @@ static size_t bond_get_size(const struct net_device *bond_dev)
                0;
 }
 
+static int bond_option_active_slave_get_ifindex(struct bonding *bond)
+{
+       const struct net_device *slave;
+       int ifindex;
+
+       rcu_read_lock();
+       slave = bond_option_active_slave_get_rcu(bond);
+       ifindex = slave ? slave->ifindex : 0;
+       rcu_read_unlock();
+       return ifindex;
+}
+
 static int bond_fill_info(struct sk_buff *skb,
                          const struct net_device *bond_dev)
 {
        struct bonding *bond = netdev_priv(bond_dev);
-       struct net_device *slave_dev = bond_option_active_slave_get(bond);
-       struct nlattr *targets;
        unsigned int packets_per_slave;
-       int i, targets_added;
+       int ifindex, i, targets_added;
+       struct nlattr *targets;
 
        if (nla_put_u8(skb, IFLA_BOND_MODE, BOND_MODE(bond)))
                goto nla_put_failure;
 
-       if (slave_dev &&
-           nla_put_u32(skb, IFLA_BOND_ACTIVE_SLAVE, slave_dev->ifindex))
+       ifindex = bond_option_active_slave_get_ifindex(bond);
+       if (ifindex && nla_put_u32(skb, IFLA_BOND_ACTIVE_SLAVE, ifindex))
                goto nla_put_failure;
 
        if (nla_put_u32(skb, IFLA_BOND_MIIMON, bond->params.miimon))
index 540e016..b26271f 100644 (file)
@@ -704,11 +704,6 @@ struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond)
        return __bond_option_active_slave_get(bond, slave);
 }
 
-struct net_device *bond_option_active_slave_get(struct bonding *bond)
-{
-       return __bond_option_active_slave_get(bond, bond->curr_active_slave);
-}
-
 static int bond_option_active_slave_set(struct bonding *bond,
                                        const struct bond_opt_value *newval)
 {
index 0b4d9cd..713e2a9 100644 (file)
@@ -514,7 +514,6 @@ unsigned int bond_get_num_tx_queues(void);
 int bond_netlink_init(void);
 void bond_netlink_fini(void);
 struct net_device *bond_option_active_slave_get_rcu(struct bonding *bond);
-struct net_device *bond_option_active_slave_get(struct bonding *bond);
 const char *bond_slave_link_status(s8 link);
 bool bond_verify_device_path(struct net_device *start_dev,
                             struct net_device *end_dev,