From b238290b965f23ac5f8aeb64cd731aef18aa796c Mon Sep 17 00:00:00 2001 From: Neil Spring Date: Mon, 30 Aug 2021 20:33:56 -0700 Subject: 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 Signed-off-by: Andrii Nakryiko Acked-by: John Fastabend Link: https://lore.kernel.org/bpf/20210831033356.1459316-1-ntspring@fb.com --- tools/testing/selftests/bpf/progs/test_skb_ctx.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools/testing/selftests/bpf/progs/test_skb_ctx.c') 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; } -- cgit v1.2.3