Skip to contentSkip to conversation

bpf: fix the check that forwarding is enabled in bpf_ipv6_fib_lookup

PATCH Applied Anton Protopopov 4 participants 4 messages Jun 15, 2019 – Jun 17, 2019

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

PATCH 1/1 bpf: fix the check that forwarding is enabled in bpf_ipv6_fib_lookup

The bpf_ipv6_fib_lookup function should return BPF_FIB_LKUP_RET_FWD_DISABLED when forwarding is disabled for the input device. However instead of checking if forwarding is enabled on the input device, it checked the global net->ipv6.devconf_all->forwarding flag. Change it to behave as expected.

---
 net/core/filter.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/filter.c +1 -1
index f615e42cf4ef..3fdf1b21be36 100644
@@ -4737,7 +4737,7 @@ static int bpf_ipv6_fib_lookup(struct net *net, struct bpf_fib_lookup *params,
 		return -ENODEV;
 
 	idev = __in6_dev_get_safely(dev);
-	if (unlikely(!idev || !net->ipv6.devconf_all->forwarding))
+	if (unlikely(!idev || !idev->cnf.forwarding))
 		return BPF_FIB_LKUP_RET_FWD_DISABLED;
 
 	if (flags & BPF_FIB_LOOKUP_OUTPUT) {
Signature · 1 line
2.19.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Anton Protopopov

The bpf_ipv6_fib_lookup function should return BPF_FIB_LKUP_RET_FWD_DISABLED when forwarding is disabled for the input device. However instead of checking if forwarding is enabled on the input device, it checked the global net->ipv6.devconf_all->forwarding flag. Change it to behave as expected.

Thanks!

Reviewed-by
#2 lore raw
Quoted 7 lines · Toke Høiland-Jørgensen
Quoted 5 lines · Anton Protopopov

The bpf_ipv6_fib_lookup function should return BPF_FIB_LKUP_RET_FWD_DISABLED when forwarding is disabled for the input device. However instead of checking if forwarding is enabled on the input device, it checked the global net->ipv6.devconf_all->forwarding flag. Change it to behave as expected.

Quoted 6 lines
Quoted 1 line

Thanks!

Fixes 87f5fc7e48dd ("bpf: Provide helper to do forwarding lookups in

kernel FIB table")

maintainer Applied
#3 lore raw
In reply to Anton Protopopov
Quoted 6 lines · Anton Protopopov

The bpf_ipv6_fib_lookup function should return BPF_FIB_LKUP_RET_FWD_DISABLED when forwarding is disabled for the input device. However instead of checking if forwarding is enabled on the input device, it checked the global net->ipv6.devconf_all->forwarding flag. Change it to behave as expected.

Applied, thanks!