All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: core: Traverse the adjacency list from first entry
@ 2016-10-26  6:39 idosch
  2016-10-26 15:05 ` David Ahern
  0 siblings, 1 reply; 3+ messages in thread
From: idosch @ 2016-10-26  6:39 UTC (permalink / raw)
  To: davem; +Cc: netdev, mlxsw, dsa, Ido Schimmel

From: Ido Schimmel <idosch@mellanox.com>

netdev_next_lower_dev() returns NULL when we finished traversing the
adjacency list ('iter' points to the list's head). Therefore, we must
start traversing the list from the first entry and not its head.

Fixes: 1a3f060c1a47 ("net: Introduce new api for walking upper and lower devices")
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
---
 net/core/dev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index f55fb45..d9c937f 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5419,7 +5419,7 @@ int netdev_walk_all_lower_dev(struct net_device *dev,
 	struct list_head *iter;
 	int ret;
 
-	for (iter = &dev->adj_list.lower,
+	for (iter = dev->adj_list.lower.next,
 	     ldev = netdev_next_lower_dev(dev, &iter);
 	     ldev;
 	     ldev = netdev_next_lower_dev(dev, &iter)) {
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: Traverse the adjacency list from first entry
  2016-10-26  6:39 [PATCH net-next] net: core: Traverse the adjacency list from first entry idosch
@ 2016-10-26 15:05 ` David Ahern
  2016-10-26 15:52   ` Ido Schimmel
  0 siblings, 1 reply; 3+ messages in thread
From: David Ahern @ 2016-10-26 15:05 UTC (permalink / raw)
  To: idosch, davem; +Cc: netdev, mlxsw, Ido Schimmel

On 10/26/16 12:39 AM, idosch@idosch.org wrote:
> From: Ido Schimmel <idosch@mellanox.com>
> 
> netdev_next_lower_dev() returns NULL when we finished traversing the
> adjacency list ('iter' points to the list's head). Therefore, we must
> start traversing the list from the first entry and not its head.
> 
> Fixes: 1a3f060c1a47 ("net: Introduce new api for walking upper and lower devices")
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> ---
>  net/core/dev.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index f55fb45..d9c937f 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5419,7 +5419,7 @@ int netdev_walk_all_lower_dev(struct net_device *dev,
>  	struct list_head *iter;
>  	int ret;
>  
> -	for (iter = &dev->adj_list.lower,
> +	for (iter = dev->adj_list.lower.next,
>  	     ldev = netdev_next_lower_dev(dev, &iter);
>  	     ldev;
>  	     ldev = netdev_next_lower_dev(dev, &iter)) {
> 

How about this instead? It keeps the 3 walk functions in sync modulo the rcu reference:


diff --git a/net/core/dev.c b/net/core/dev.c
index f55fb4536016..6aa43cd8cbb5 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -5400,12 +5400,12 @@ static struct net_device *netdev_next_lower_dev(struct net_device *dev,
 {
	struct netdev_adjacent *lower;

-	lower = list_entry(*iter, struct netdev_adjacent, list);
+	lower = list_entry((*iter)->next, struct netdev_adjacent, list);

 	if (&lower->list == &dev->adj_list.lower)
 		return NULL;

-	*iter = lower->list.next;
+	*iter = &lower->list;

 	return lower->dev;
 }

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net-next] net: core: Traverse the adjacency list from first entry
  2016-10-26 15:05 ` David Ahern
@ 2016-10-26 15:52   ` Ido Schimmel
  0 siblings, 0 replies; 3+ messages in thread
From: Ido Schimmel @ 2016-10-26 15:52 UTC (permalink / raw)
  To: David Ahern; +Cc: davem, netdev, mlxsw, Ido Schimmel

On Wed, Oct 26, 2016 at 09:05:35AM -0600, David Ahern wrote:
> On 10/26/16 12:39 AM, idosch@idosch.org wrote:
> > From: Ido Schimmel <idosch@mellanox.com>
> > 
> > netdev_next_lower_dev() returns NULL when we finished traversing the
> > adjacency list ('iter' points to the list's head). Therefore, we must
> > start traversing the list from the first entry and not its head.
> > 
> > Fixes: 1a3f060c1a47 ("net: Introduce new api for walking upper and lower devices")
> > Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> > ---
> >  net/core/dev.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/core/dev.c b/net/core/dev.c
> > index f55fb45..d9c937f 100644
> > --- a/net/core/dev.c
> > +++ b/net/core/dev.c
> > @@ -5419,7 +5419,7 @@ int netdev_walk_all_lower_dev(struct net_device *dev,
> >  	struct list_head *iter;
> >  	int ret;
> >  
> > -	for (iter = &dev->adj_list.lower,
> > +	for (iter = dev->adj_list.lower.next,
> >  	     ldev = netdev_next_lower_dev(dev, &iter);
> >  	     ldev;
> >  	     ldev = netdev_next_lower_dev(dev, &iter)) {
> > 
> 
> How about this instead? It keeps the 3 walk functions in sync modulo the rcu reference:

I don't see any problem, so I guess it will work as well. I simply
preferred to use the same convention employed prior to your patchset.

Please submit yours formally, if you prefer.

> 
> 
> diff --git a/net/core/dev.c b/net/core/dev.c
> index f55fb4536016..6aa43cd8cbb5 100644
> --- a/net/core/dev.c
> +++ b/net/core/dev.c
> @@ -5400,12 +5400,12 @@ static struct net_device *netdev_next_lower_dev(struct net_device *dev,
>  {
> 	struct netdev_adjacent *lower;
> 
> -	lower = list_entry(*iter, struct netdev_adjacent, list);
> +	lower = list_entry((*iter)->next, struct netdev_adjacent, list);
> 
>  	if (&lower->list == &dev->adj_list.lower)
>  		return NULL;
> 
> -	*iter = lower->list.next;
> +	*iter = &lower->list;
> 
>  	return lower->dev;
>  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-26 15:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-10-26  6:39 [PATCH net-next] net: core: Traverse the adjacency list from first entry idosch
2016-10-26 15:05 ` David Ahern
2016-10-26 15:52   ` Ido Schimmel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.