]> git.baikalelectronics.ru Git - kernel.git/commit
bpf: Allow to specify ifindex for skb in bpf_prog_test_run_skb
authorDmitry Yakunin <zeil@yandex-team.ru>
Mon, 3 Aug 2020 09:05:45 +0000 (12:05 +0300)
committerDaniel Borkmann <daniel@iogearbox.net>
Mon, 3 Aug 2020 21:32:23 +0000 (23:32 +0200)
commitbc608c3bae6482aa490cb73c4ae62027f23754a4
tree44983546541e5292a69e16c4b3f4f94180b9e0e4
parentfad5aacaf676d9fea2f4b5a3447a78396965e80d
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
net/bpf/test_run.c
tools/testing/selftests/bpf/prog_tests/skb_ctx.c