From: Ding Tianhong <dingtianhong@huawei.com>
To: Veaceslav Falico <vfalico@redhat.com>
Cc: Jay Vosburgh <fubar@us.ibm.com>,
Andy Gospodarek <andy@greyhouse.net>,
"David S. Miller" <davem@davemloft.net>,
Nikolay Aleksandrov <nikolay@redhat.com>,
Netdev <netdev@vger.kernel.org>
Subject: Re: [PATCH net-next v3 5/10] bonding: create bond_first_slave_rcu()
Date: Tue, 12 Nov 2013 14:55:12 +0800 [thread overview]
Message-ID: <5281D0D0.9040704@huawei.com> (raw)
In-Reply-To: <20131111125917.GX19702@redhat.com>
On 2013/11/11 20:59, Veaceslav Falico wrote:
> On Mon, Nov 11, 2013 at 08:36:41PM +0800, Ding Tianhong wrote:
>> The bond_first_slave_rcu() will be used to instead of bond_first_slave()
>> in rcu_read_lock().
>>
>> So move the struct netdev_adjacent to the netdevice.h and make the
>> bond_first_slave_rcu() could use the struct.
>
> The whole point in netdev_adjacent functions was to hide it from the users
> who wanted to use it directly. See
>
> http://www.spinics.net/lists/netdev/msg248026.html
>
> for reference. Please try to avoid that.
>
Hi, Veaceslav
following the point, I rebuild the bond_first_slave_rcu(),
if you have no comments, I will move it in the patch set.
Regards
Ding
+/* Caller must have rcu_read_lock */
+#define bond_first_slave_rcu(bond) \
+ netdev_lower_get_first_private_rcu(bond->dev)
+
#define bond_is_first_slave(bond, pos) (pos == bond_first_slave(bond))
#define bond_is_last_slave(bond, pos) (pos == bond_last_slave(bond))
diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 15fa01c..abfcfad 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -2869,6 +2869,7 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,
priv = netdev_lower_get_next_private_rcu(dev, &(iter)))
void *netdev_adjacent_get_private(struct list_head *adj_list);
+void *netdev_lower_get_first_private_rcu(struct net_device *dev);
struct net_device *netdev_master_upper_dev_get(struct net_device *dev);
struct net_device *netdev_master_upper_dev_get_rcu(struct net_device *dev);
int netdev_upper_dev_link(struct net_device *dev, struct net_device *upper_dev);
diff --git a/net/core/dev.c b/net/core/dev.c
index 8ffc52e..39bc202 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4570,6 +4570,27 @@ void *netdev_lower_get_next_private_rcu(struct net_device *dev,
EXPORT_SYMBOL(netdev_lower_get_next_private_rcu);
/**
+ * netdev_lower_get_first_private_rcu - Get the first ->private from the
+ * lower neighbour list, RCU
+ * variant
+ * @dev: device
+ *
+ * Gets the first netdev_adjacent->private from the dev's lower neighbour
+ * list. The caller must hold RCU read lock.
+ */
+void *netdev_lower_get_first_private_rcu(struct net_device *dev)
+{
+ struct netdev_adjacent *lower;
+
+ lower = list_first_or_null_rcu(&dev->adj_list.lower,
+ struct netdev_adjacent, list);
+ if (lower)
+ return lower->private;
+ return NULL;
+}
+EXPORT_SYMBOL(netdev_lower_get_first_private_rcu);
prev parent reply other threads:[~2013-11-12 7:01 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-11 12:36 [PATCH net-next v3 5/10] bonding: create bond_first_slave_rcu() Ding Tianhong
2013-11-11 12:59 ` Veaceslav Falico
2013-11-12 6:55 ` Ding Tianhong [this message]
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=5281D0D0.9040704@huawei.com \
--to=dingtianhong@huawei.com \
--cc=andy@greyhouse.net \
--cc=davem@davemloft.net \
--cc=fubar@us.ibm.com \
--cc=netdev@vger.kernel.org \
--cc=nikolay@redhat.com \
--cc=vfalico@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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;
as well as URLs for NNTP newsgroup(s).