public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Eric Dumazet <edumazet@google•com>
To: "David S. Miller" <davem@davemloft•net>
Cc: netdev@vger•kernel.org, Jay Vosburgh <j.vosburgh@gmail•com>,
	Veaceslav Falico <vfalico@gmail•com>,
	Andy Gospodarek <andy@greyhouse•net>,
	Nikolay Aleksandrov <nikolay@redhat•com>,
	Mahesh Bandewar <maheshb@google•com>,
	Eric Dumazet <edumazet@google•com>
Subject: [PATCH net-next 1/3] bonding: get rid of bond_option_active_slave_get()
Date: Tue, 15 Jul 2014 02:46:42 -0700	[thread overview]
Message-ID: <1405417604-7828-2-git-send-email-edumazet@google.com> (raw)
In-Reply-To: <1405417604-7828-1-git-send-email-edumazet@google.com>

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>
---
 drivers/net/bonding/bond_netlink.c | 21 ++++++++++++++++-----
 drivers/net/bonding/bond_options.c |  5 -----
 drivers/net/bonding/bonding.h      |  1 -
 3 files changed, 16 insertions(+), 11 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)
 		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))
diff --git a/drivers/net/bonding/bond_options.c b/drivers/net/bonding/bond_options.c
index 540e0167bf24..b26271fd7b09 100644
--- a/drivers/net/bonding/bond_options.c
+++ b/drivers/net/bonding/bond_options.c
@@ -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)
 {
diff --git a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
index 0b4d9cde0b05..713e2a99c661 100644
--- a/drivers/net/bonding/bonding.h
+++ b/drivers/net/bonding/bonding.h
@@ -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,
-- 
2.0.0.526.g5318336

  reply	other threads:[~2014-07-15  9:46 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-15  9:46 [PATCH net-next 0/3] bonding: rcu cleanups Eric Dumazet
2014-07-15  9:46 ` Eric Dumazet [this message]
2014-07-15 10:24   ` [PATCH net-next 1/3] bonding: get rid of bond_option_active_slave_get() Veaceslav Falico
2014-07-15  9:46 ` [PATCH net-next 2/3] bonding: use rcu_access_pointer() in bonding_show_mii_status() Eric Dumazet
2014-07-15 10:32   ` Veaceslav Falico
2014-07-15  9:46 ` [PATCH net-next 3/3] bonding: add proper __rcu annotation for curr_active_slave Eric Dumazet
2014-07-15 10:38   ` Veaceslav Falico
2014-07-15 10:52     ` Eric Dumazet
2014-07-15 11:15       ` Veaceslav Falico
2014-07-15 10:55 ` [PATCH net-next 0/3] bonding: rcu cleanups Nikolay Aleksandrov
2014-07-15 11:51   ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1405417604-7828-2-git-send-email-edumazet@google.com \
    --to=edumazet@google$(echo .)com \
    --cc=andy@greyhouse$(echo .)net \
    --cc=davem@davemloft$(echo .)net \
    --cc=j.vosburgh@gmail$(echo .)com \
    --cc=maheshb@google$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nikolay@redhat$(echo .)com \
    --cc=vfalico@gmail$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox