Skip to contentSkip to conversation

net: l3mdev: Set OIF flag only when an L3 master exists

PATCH In review Haon KIM 3 participants 3 messages Oct 24 – Oct 28

Subsystems (3)
lore
Share & tools
lore

Haon KIM

author
#0 lore raw

PATCH 1/1 net: l3mdev: Set OIF flag only when an L3 master exists

l3mdev_master_ifindex_rcu() may return 0 when the device is not associated with an L3 master. In that case, l3mdev_update_flow() currently sets FLOWI_FLAG_L3MDEV_OIF even though flowi_l3mdev remains 0.

Set FLOWI_FLAG_L3MDEV_OIF only when a non-zero L3 master ifindex is returned, keeping the flag consistent with flowi_l3mdev.

---
 net/l3mdev/l3mdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/l3mdev/l3mdev.c +2 -1
index 5432a5f2dfc8..92b48d6a4301 100644
@@ -279,7 +279,8 @@ void l3mdev_update_flow(struct net *net, struct flowi *fl)
 		if (dev) {
 			if (!fl->flowi_l3mdev) {
 				fl->flowi_l3mdev = l3mdev_master_ifindex_rcu(dev);
-				fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;
+				if (fl->flowi_l3mdev)
+					fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;
 			}
 
 			/* oif set to L3mdev directs lookup to its table;
Signature · 1 line
2.37.0
#1 lore raw

Hi Haon,

Quoted 18 lines

l3mdev_master_ifindex_rcu() may return 0 when the device is not associated with an L3 master. In that case, l3mdev_update_flow() currently sets FLOWI_FLAG_L3MDEV_OIF even though flowi_l3mdev remains 0.

Set FLOWI_FLAG_L3MDEV_OIF only when a non-zero L3 master ifindex is returned, keeping the flag consistent with flowi_l3mdev.

---
 net/l3mdev/l3mdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
net/l3mdev/l3mdev.c +0 -0
index 5432a5f2dfc8..92b48d6a4301 100644

net/l3mdev/l3mdev.c void l3mdev_update_flow(struct net *net, struct flowi *fl) · line 283

Quoted 6 lines
net/l3mdev/l3mdev.c +2 -1
@@ -279,7 +279,8 @@ void l3mdev_update_flow(struct net *net, struct flowi *fl)
 		if (dev) {
 			if (!fl->flowi_l3mdev) {
 				fl->flowi_l3mdev = l3mdev_master_ifindex_rcu(dev);
-				fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;
+				if (fl->flowi_l3mdev)
+					fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;

Looking at the readers of this flag, it does not look like this does much, so if anything this is a no-functional clean-up for net-next, I guess. The commit description could be more specific about this. Also, the target tree is missing.

Quoted 6 lines
net/l3mdev/l3mdev.c +0 -0
 			}
 
 			/* oif set to L3mdev directs lookup to its table;
Signature · 1 line
2.37.0

/Daniel

maintainer
#2 lore raw
Quoted 15 lines · Daniel Machon

Hi Haon,

Quoted 13 lines

l3mdev_master_ifindex_rcu() may return 0 when the device is not associated with an L3 master. In that case, l3mdev_update_flow() currently sets FLOWI_FLAG_L3MDEV_OIF even though flowi_l3mdev remains 0.

Set FLOWI_FLAG_L3MDEV_OIF only when a non-zero L3 master ifindex is returned, keeping the flag consistent with flowi_l3mdev.

---
 net/l3mdev/l3mdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 16 lines

net/l3mdev/l3mdev.c void l3mdev_update_flow(struct net *net, struct flowi *fl) · line 283

Quoted 11 lines
net/l3mdev/l3mdev.c +2 -1
index 5432a5f2dfc8..92b48d6a4301 100644
@@ -279,7 +279,8 @@ void l3mdev_update_flow(struct net *net, struct flowi *fl)
 		if (dev) {
 			if (!fl->flowi_l3mdev) {
 				fl->flowi_l3mdev = l3mdev_master_ifindex_rcu(dev);
-				fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;
+				if (fl->flowi_l3mdev)
+					fl->flowi_flags |= FLOWI_FLAG_L3MDEV_OIF;

Looking at the readers of this flag, it does not look like this does much, so if anything this is a no-functional clean-up for net-next, I guess. The commit description could be more specific about this. Also, the target tree is missing.

Example of a failing use case?