diff options
author | Neil Spring <ntspring@fb.com> | 2021-08-30 20:33:56 -0700 |
---|---|---|
committer | Andrii Nakryiko <andrii@kernel.org> | 2021-09-07 16:55:32 -0700 |
commit | b238290b965f23ac5f8aeb64cd731aef18aa796c (patch) | |
tree | b3b69bb8f8be36d9453cc1bedba161e3c68ead80 /tools/testing/selftests/bpf/progs/test_skb_ctx.c | |
parent | 27151f177827d478508e756c7657273261aaf8a9 (diff) | |
download | linux-b238290b965f23ac5f8aeb64cd731aef18aa796c.tar.gz linux-b238290b965f23ac5f8aeb64cd731aef18aa796c.tar.bz2 linux-b238290b965f23ac5f8aeb64cd731aef18aa796c.zip |
bpf: Permit ingress_ifindex in bpf_prog_test_run_xattr
bpf_prog_test_run_xattr takes a struct __sk_buff, but did not permit
that __skbuff to include an nonzero ingress_ifindex.
This patch updates to allow ingress_ifindex, convert the __sk_buff field to
sk_buff (skb_iif) and back, and tests that the value is present from on BPF
program side. The test sets an unlikely distinct value for ingress_ifindex
(11) from ifindex (1), which is in line with the rest of the synthetic field
tests.
Adding this support allows testing BPF that operates differently on
incoming and outgoing skbs by discriminating on this field.
Signed-off-by: Neil Spring <ntspring@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: John Fastabend <john.fastabend@gmail.com>
Link: https://lore.kernel.org/bpf/20210831033356.1459316-1-ntspring@fb.com
Diffstat (limited to 'tools/testing/selftests/bpf/progs/test_skb_ctx.c')
-rw-r--r-- | tools/testing/selftests/bpf/progs/test_skb_ctx.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/progs/test_skb_ctx.c b/tools/testing/selftests/bpf/progs/test_skb_ctx.c index b02ea589ce7e..bbd5a9c1c4df 100644 --- a/tools/testing/selftests/bpf/progs/test_skb_ctx.c +++ b/tools/testing/selftests/bpf/progs/test_skb_ctx.c @@ -25,6 +25,10 @@ int process(struct __sk_buff *skb) return 1; if (skb->gso_size != 10) return 1; + if (skb->ingress_ifindex != 11) + return 1; + if (skb->ifindex != 1) + return 1; return 0; } |