From mboxrd@z Thu Jan 1 00:00:00 1970 From: Veaceslav Falico Subject: [PATCH v3 net-next 21/27] net: add a function to get the next private Date: Tue, 17 Sep 2013 02:46:46 +0200 Message-ID: <1379378812-18346-22-git-send-email-vfalico@redhat.com> References: <1379378812-18346-1-git-send-email-vfalico@redhat.com> Cc: jiri@resnulli.us, Veaceslav Falico , "David S. Miller" , Eric Dumazet , Alexander Duyck To: netdev@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:51813 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752126Ab3IQAr2 (ORCPT ); Mon, 16 Sep 2013 20:47:28 -0400 In-Reply-To: <1379378812-18346-1-git-send-email-vfalico@redhat.com> Sender: netdev-owner@vger.kernel.org List-ID: It searches for the provided private and returns the next one. If private is not found or next list element is list head - returns NULL. CC: "David S. Miller" CC: Eric Dumazet CC: Jiri Pirko CC: Alexander Duyck Signed-off-by: Veaceslav Falico --- Notes: v2 -> v3: No change. v1 -> v2: No changes. RFC -> v1: Drop the bool switch - it only goes to ->next now, and rework it so that it doesn't go over the head, but rather returns NULL. include/linux/netdevice.h | 2 ++ net/core/dev.c | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h index 72d1631..b487302 100644 --- a/include/linux/netdevice.h +++ b/include/linux/netdevice.h @@ -2866,6 +2866,8 @@ extern void *netdev_lower_dev_get_private_rcu(struct net_device *dev, struct net_device *lower_dev); extern void *netdev_lower_dev_get_private(struct net_device *dev, struct net_device *lower_dev); +extern void *netdev_lower_dev_get_next_private(struct net_device *dev, + void *private); extern int skb_checksum_help(struct sk_buff *skb); extern struct sk_buff *__skb_gso_segment(struct sk_buff *skb, netdev_features_t features, bool tx_path); diff --git a/net/core/dev.c b/net/core/dev.c index 24c7d17..d58ca53 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -5055,6 +5055,33 @@ void *netdev_lower_dev_get_private(struct net_device *dev, } EXPORT_SYMBOL(netdev_lower_dev_get_private); +/* netdev_lower_dev_get_next_private - return the ->private of the list + * element whos ->private == private. + * @dev - device to search + * @private - private pointer to search for. + * + * Returns the next ->private pointer, if ->next is not head and private is + * found. + */ +extern void *netdev_lower_dev_get_next_private(struct net_device *dev, + void *private) +{ + struct netdev_adjacent *lower; + + list_for_each_entry(lower, &dev->adj_list.lower, list) { + if (lower->private == private) { + lower = list_entry(lower->list.next, + struct netdev_adjacent, list); + if (&lower->list == &dev->adj_list.lower) + return NULL; + return lower->private; + } + } + + return NULL; +} +EXPORT_SYMBOL(netdev_lower_dev_get_next_private); + static void dev_change_rx_flags(struct net_device *dev, int flags) { const struct net_device_ops *ops = dev->netdev_ops; -- 1.8.4