mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 03:01:39 -04:00
UPSTREAM: 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. Change-Id: Ia56479984ad24f3e0deb878c30dc42a6377bfb0b Signed-off-by: Dmitry Yakunin <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
This commit is contained in:
parent
1fc9939754
commit
64e25a5d35
2 changed files with 25 additions and 2 deletions
|
|
@ -10,6 +10,7 @@ void test_skb_ctx(void)
|
|||
.cb[3] = 4,
|
||||
.cb[4] = 5,
|
||||
.priority = 6,
|
||||
.ifindex = 1,
|
||||
.tstamp = 7,
|
||||
.wire_len = 100,
|
||||
.gso_segs = 8,
|
||||
|
|
@ -90,6 +91,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",
|
||||
|
|
|
|||
Loading…
Reference in a new issue