summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
diff options
context:
space:
mode:
authorDmitry Yakunin <zeil@yandex-team.ru>2020-08-03 12:05:45 +0300
committerDaniel Borkmann <daniel@iogearbox.net>2020-08-03 23:32:23 +0200
commit21594c44083c375697d418729c4b2e4522cf9f70 (patch)
tree44983546541e5292a69e16c4b3f4f94180b9e0e4 /tools/testing/selftests/bpf/prog_tests/skb_ctx.c
parentfa5cb548ced61b9d3095f32f8a7e427a248c65ee (diff)
bpf: Allow to specify ifindex for skb in bpf_prog_test_run_skb
Now skb->dev is unconditionally set to the loopback device in current net namespace. But if we want to test bpf program which contains code branch based on ifindex condition (eg filters out localhost packets) it is useful to allow specifying of ifindex from userspace. This patch adds such option through ctx_in (__sk_buff) parameter. Signed-off-by: Dmitry Yakunin <zeil@yandex-team.ru> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Link: https://lore.kernel.org/bpf/20200803090545.82046-3-zeil@yandex-team.ru
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/skb_ctx.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/skb_ctx.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
index 7021b92af313..25de86af2d03 100644
--- a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
+++ b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
@@ -11,6 +11,7 @@ void test_skb_ctx(void)
.cb[3] = 4,
.cb[4] = 5,
.priority = 6,
+ .ifindex = 1,
.tstamp = 7,
.wire_len = 100,
.gso_segs = 8,
@@ -92,6 +93,10 @@ void test_skb_ctx(void)
"ctx_out_priority",
"skb->priority == %d, expected %d\n",
skb.priority, 7);
+ CHECK_ATTR(skb.ifindex != 1,
+ "ctx_out_ifindex",
+ "skb->ifindex == %d, expected %d\n",
+ skb.ifindex, 1);
CHECK_ATTR(skb.tstamp != 8,
"ctx_out_tstamp",
"skb->tstamp == %lld, expected %d\n",