OSDN Git Service

bpf: Permit ingress_ifindex in bpf_prog_test_run_xattr
authorNeil Spring <ntspring@fb.com>
Tue, 31 Aug 2021 03:33:56 +0000 (20:33 -0700)
committerAndrii Nakryiko <andrii@kernel.org>
Tue, 7 Sep 2021 23:55:32 +0000 (16:55 -0700)
commitb238290b965f23ac5f8aeb64cd731aef18aa796c
treeb3b69bb8f8be36d9453cc1bedba161e3c68ead80
parent27151f177827d478508e756c7657273261aaf8a9
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
net/bpf/test_run.c
tools/testing/selftests/bpf/prog_tests/skb_ctx.c
tools/testing/selftests/bpf/progs/test_skb_ctx.c