netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Veaceslav Falico <vfalico@redhat.com>
To: netdev@vger.kernel.org
Cc: Veaceslav Falico <vfalico@redhat.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>, Jiri Pirko <jiri@resnulli.us>,
	Alexander Duyck <alexander.h.duyck@intel.com>,
	Cong Wang <amwang@redhat.com>
Subject: [PATCH net-next v1 1/9] net: add netdev_upper_get_next_dev(dev, iter)
Date: Mon, 26 Aug 2013 22:32:34 +0200	[thread overview]
Message-ID: <1377549162-7522-2-git-send-email-vfalico@redhat.com> (raw)
In-Reply-To: <1377549162-7522-1-git-send-email-vfalico@redhat.com>

This function returns the next dev in the dev->upper_dev_list after the
struct list_head **iter position, and updates *iter accordingly. Returns
NULL if there are no devices left.

v1: new patch

CC: "David S. Miller" <davem@davemloft.net>
CC: Eric Dumazet <edumazet@google.com>
CC: Jiri Pirko <jiri@resnulli.us>
CC: Alexander Duyck <alexander.h.duyck@intel.com>
CC: Cong Wang <amwang@redhat.com>
Signed-off-by: Veaceslav Falico <vfalico@redhat.com>
---
 net/core/dev.c |   25 +++++++++++++++++++++++++
 1 files changed, 25 insertions(+), 0 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index 1ed2b66..566e99a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -4477,6 +4477,31 @@ struct net_device *netdev_master_upper_dev_get(struct net_device *dev)
 }
 EXPORT_SYMBOL(netdev_master_upper_dev_get);
 
+/* netdev_upper_get_next_dev - Get the next dev from upper list
+ * @dev: device
+ * @iter: list_head ** of the current position
+ *
+ * Gets the next device from the dev's upper list, starting from iter
+ * position. The caller must hold RCU read lock.
+ */
+struct net_device *netdev_upper_get_next_dev(struct net_device *dev,
+					     struct list_head **iter)
+{
+	struct netdev_upper *upper;
+
+	WARN_ON_ONCE(!rcu_read_lock_held());
+
+	upper = list_entry_rcu((*iter)->next, struct netdev_upper, list);
+
+	if (&upper->list == &dev->upper_dev_list)
+		return NULL;
+
+	*iter = &upper->list;
+
+	return upper->dev;
+}
+EXPORT_SYMBOL(netdev_upper_get_next_dev);
+
 /**
  * netdev_master_upper_dev_get_rcu - Get master upper device
  * @dev: device
-- 
1.7.1

  reply	other threads:[~2013-08-26 20:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-26 20:32 [PATCH net-next v1 0/9] bonding: remove vlan special handling Veaceslav Falico
2013-08-26 20:32 ` Veaceslav Falico [this message]
2013-08-26 20:57   ` [PATCH net-next v1 1/9] net: add netdev_upper_get_next_dev(dev, iter) Jiri Pirko
2013-08-27 10:42     ` Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 2/9] net: add netdev_for_each_upper_dev() Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 3/9] bonding: use netdev_upper list in bond_vlan_used Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 4/9] bonding: make bond_arp_send_all use upper device list Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 5/9] bonding: convert bond_has_this_ip() to use upper devices Veaceslav Falico
2013-08-26 20:53   ` Jiri Pirko
2013-08-27 11:16     ` Veaceslav Falico
2013-08-27 11:25       ` Jiri Pirko
2013-08-27 11:53         ` Veaceslav Falico
2013-08-27 18:10         ` Veaceslav Falico
2013-08-28 12:00           ` Veaceslav Falico
2013-08-28 14:56           ` Vlad Yasevich
2013-08-28 16:32             ` Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 6/9] bonding: use vlan_uses_dev() in __bond_release_one() Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 7/9] bonding: split alb_send_learning_packets() Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 8/9] bonding: make alb_send_learning_packets() use upper dev list Veaceslav Falico
2013-08-26 20:32 ` [PATCH net-next v1 9/9] bonding: remove vlan_list/current_alb_vlan Veaceslav Falico

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=1377549162-7522-2-git-send-email-vfalico@redhat.com \
    --to=vfalico@redhat.com \
    --cc=alexander.h.duyck@intel.com \
    --cc=amwang@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=jiri@resnulli.us \
    --cc=netdev@vger.kernel.org \
    /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).