Skip to contentSkip to conversation

ip6_tunnel: Correct mistake in if statement.

PATCH In review Jamie Gloudon 2 participants 3 messages Nov 7, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 ip6_tunnel: Correct mistake in if statement.

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

---
 net/ipv6/ip6_tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_tunnel.c +1 -1
index 2fb4c6ad7243..22c71f991bb7 100644
@@ -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]);
Signature · 1 line
2.28.0
#1 lore raw
Quoted 14 lines · Jamie Gloudon

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

---
 net/ipv6/ip6_tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_tunnel.c +0 -0
index 2fb4c6ad7243..22c71f991bb7 100644

net/ipv6/ip6_tunnel.c ip6_tnl_lookup(struct net *net, int link, · line 165

Quoted 5 lines
net/ipv6/ip6_tunnel.c +1 -1
@@ -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

Quoted 6 lines
net/ipv6/ip6_tunnel.c +0 -0
 		return t;
 
 	t = rcu_dereference(ip6n->tnls_wc[0]);
Signature · 1 line
2.28.0
#2 lore raw
Quoted 25 lines · Leon Romanovsky
Quoted 14 lines · Jamie Gloudon

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

---
 net/ipv6/ip6_tunnel.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/ipv6/ip6_tunnel.c +0 -0
index 2fb4c6ad7243..22c71f991bb7 100644

net/ipv6/ip6_tunnel.c ip6_tnl_lookup(struct net *net, int link, · line 165

Quoted 5 lines
net/ipv6/ip6_tunnel.c +1 -1
@@ -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

Quoted 10 lines

There is nothing to fix here.

Thanks

Quoted 6 lines
net/ipv6/ip6_tunnel.c +0 -0
 		return t;
 
 	t = rcu_dereference(ip6n->tnls_wc[0]);
Signature · 1 line
2.28.0

Thanks for taking the time to review the patch.