netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v3 1/1] ip6_tunnel: Correct mistake in if statement.
@ 2022-11-07  8:31 Jamie Gloudon
  2022-11-07  8:58 ` Leon Romanovsky
  0 siblings, 1 reply; 3+ messages in thread
From: Jamie Gloudon @ 2022-11-07  8:31 UTC (permalink / raw)
  To: netdev; +Cc: pabeni, davem, edumazet, kuba, yoshfuji, dsahern

Make sure t->dev->flags & IFF_UP is check first for logical reason.

Fixes: 6c1cb4393cc7 ("ip6_tunnel: fix ip6 tunnel lookup in collect_md
mode")
Signed-off-by: Jamie Gloudon <jamie.gloudon@gmx.fr>
---
 net/ipv6/ip6_tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
index 2fb4c6ad7243..22c71f991bb7 100644
--- a/net/ipv6/ip6_tunnel.c
+++ b/net/ipv6/ip6_tunnel.c
@@ -162,7 +162,7 @@ ip6_tnl_lookup(struct net *net, int link,
 		return cand;
 
 	t = rcu_dereference(ip6n->collect_md_tun);
-	if (t && t->dev->flags & IFF_UP)
+	if (t && (t->dev->flags & IFF_UP))
 		return t;
 
 	t = rcu_dereference(ip6n->tnls_wc[0]);
-- 
2.28.0


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

* Re: [PATCH net v3 1/1] ip6_tunnel: Correct mistake in if statement.
  2022-11-07  8:31 [PATCH net v3 1/1] ip6_tunnel: Correct mistake in if statement Jamie Gloudon
@ 2022-11-07  8:58 ` Leon Romanovsky
  2022-11-07 17:54   ` Jamie Gloudon
  0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2022-11-07  8:58 UTC (permalink / raw)
  To: Jamie Gloudon; +Cc: netdev, pabeni, davem, edumazet, kuba, yoshfuji, dsahern

On Mon, Nov 07, 2022 at 04:31:22AM -0400, Jamie Gloudon wrote:
> Make sure t->dev->flags & IFF_UP is check first for logical reason.
> 
> Fixes: 6c1cb4393cc7 ("ip6_tunnel: fix ip6 tunnel lookup in collect_md
> mode")
> Signed-off-by: Jamie Gloudon <jamie.gloudon@gmx.fr>
> ---
>  net/ipv6/ip6_tunnel.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> index 2fb4c6ad7243..22c71f991bb7 100644
> --- a/net/ipv6/ip6_tunnel.c
> +++ b/net/ipv6/ip6_tunnel.c
> @@ -162,7 +162,7 @@ ip6_tnl_lookup(struct net *net, int link,
>  		return cand;
>  
>  	t = rcu_dereference(ip6n->collect_md_tun);
> -	if (t && t->dev->flags & IFF_UP)
> +	if (t && (t->dev->flags & IFF_UP))

While this change makes is less ambiguous for reader, the C precedence
rules are clear and & evaluated before &&.
https://en.cppreference.com/w/c/language/operator_precedence

There is nothing to fix here.

Thanks

>  		return t;
>  
>  	t = rcu_dereference(ip6n->tnls_wc[0]);
> -- 
> 2.28.0
> 

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

* Re: [PATCH net v3 1/1] ip6_tunnel: Correct mistake in if statement.
  2022-11-07  8:58 ` Leon Romanovsky
@ 2022-11-07 17:54   ` Jamie Gloudon
  0 siblings, 0 replies; 3+ messages in thread
From: Jamie Gloudon @ 2022-11-07 17:54 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: netdev, pabeni, davem, edumazet, kuba, yoshfuji, dsahern

On Mon, Nov 07, 2022 at 10:58:13AM +0200, Leon Romanovsky wrote:
> On Mon, Nov 07, 2022 at 04:31:22AM -0400, Jamie Gloudon wrote:
> > Make sure t->dev->flags & IFF_UP is check first for logical reason.
> > 
> > Fixes: 6c1cb4393cc7 ("ip6_tunnel: fix ip6 tunnel lookup in collect_md
> > mode")
> > Signed-off-by: Jamie Gloudon <jamie.gloudon@gmx.fr>
> > ---
> >  net/ipv6/ip6_tunnel.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
> > index 2fb4c6ad7243..22c71f991bb7 100644
> > --- a/net/ipv6/ip6_tunnel.c
> > +++ b/net/ipv6/ip6_tunnel.c
> > @@ -162,7 +162,7 @@ ip6_tnl_lookup(struct net *net, int link,
> >  		return cand;
> >  
> >  	t = rcu_dereference(ip6n->collect_md_tun);
> > -	if (t && t->dev->flags & IFF_UP)
> > +	if (t && (t->dev->flags & IFF_UP))
> 
> While this change makes is less ambiguous for reader, the C precedence
> rules are clear and & evaluated before &&.
> https://en.cppreference.com/w/c/language/operator_precedence
> 
> There is nothing to fix here.
> 
> Thanks
> 
> >  		return t;
> >  
> >  	t = rcu_dereference(ip6n->tnls_wc[0]);
> > -- 
> > 2.28.0
> >
Thanks for taking the time to review the patch.

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

end of thread, other threads:[~2022-11-07 17:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07  8:31 [PATCH net v3 1/1] ip6_tunnel: Correct mistake in if statement Jamie Gloudon
2022-11-07  8:58 ` Leon Romanovsky
2022-11-07 17:54   ` Jamie Gloudon

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).