[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c029e5bb-68b4-322f-f7b5-9ada9e5915ac@cumulusnetworks.com>
Date: Wed, 19 Oct 2016 08:33:19 -0600
From: David Ahern <dsa@...ulusnetworks.com>
To: idosch@...sch.org, davem@...emloft.net
Cc: netdev@...r.kernel.org, jiri@...lanox.com, eladr@...lanox.com,
yotamg@...lanox.com, nogahf@...lanox.com, ogerlitz@...lanox.com,
Ido Schimmel <idosch@...lanox.com>
Subject: Re: [PATCH net] net: core: Correctly iterate over lower adjacency
list
On 10/19/16 7:57 AM, idosch@...sch.org wrote:
> diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
> index 136ae6bb..465e128 100644
> --- a/include/linux/netdevice.h
> +++ b/include/linux/netdevice.h
> @@ -3877,7 +3877,7 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
> ldev = netdev_all_lower_get_next(dev, &(iter)))
>
> #define netdev_for_each_all_lower_dev_rcu(dev, ldev, iter) \
> - for (iter = (dev)->all_adj_list.lower.next, \
> + for (iter = &(dev)->all_adj_list.lower, \
> ldev = netdev_all_lower_get_next_rcu(dev, &(iter)); \
> ldev; \
> ldev = netdev_all_lower_get_next_rcu(dev, &(iter)))
> diff --git a/net/core/dev.c b/net/core/dev.c
> index f1fe26f..b09ac57 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5511,10 +5511,14 @@ struct net_device *netdev_all_lower_get_next_rcu(struct net_device *dev,
> {
> struct netdev_adjacent *lower;
>
> - lower = list_first_or_null_rcu(&dev->all_adj_list.lower,
> - struct netdev_adjacent, list);
> + lower = list_entry_rcu((*iter)->next, struct netdev_adjacent, list);
> +
> + if (&lower->list == &dev->all_adj_list.lower)
> + return NULL;
> +
> + *iter = &lower->list;
>
> - return lower ? lower->dev : NULL;
> + return lower->dev;
> }
> EXPORT_SYMBOL(netdev_all_lower_get_next_rcu);
When I converted this function in my series I wondered how the current code worked at all. I guess I didn't. This is inline with what I did and matches the form used for the all_upper variant, so for 4.9 and 4.8.x
Acked-by: David Ahern <dsa@...ulusnetworks.com>
I would like to see my series applied to 4.9 at some point.
Powered by blists - more mailing lists