bpf: Support specifying ingress via xdp_md context in BPF_PROG_TEST_RUN
authorZvi Effron <zeffron@riotgames.com>
Wed, 7 Jul 2021 22:16:56 +0000 (22:16 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Thu, 8 Jul 2021 02:51:13 +0000 (19:51 -0700)
commitec94670fcb3bdeaf3baaa8d86f54e90a5557f53b
tree9ad4217c171c09e5b3b4a5d135b75a579ea53244
parent47316f4a305367794fc04f23e5c778678d8f1d8e
bpf: Support specifying ingress via xdp_md context in BPF_PROG_TEST_RUN

Support specifying the ingress_ifindex and rx_queue_index of xdp_md
contexts for BPF_PROG_TEST_RUN.

The intended use case is to allow testing XDP programs that make decisions
based on the ingress interface or RX queue.

If ingress_ifindex is specified, look up the device by the provided index
in the current namespace and use its xdp_rxq for the xdp_buff. If the
rx_queue_index is out of range, or is non-zero when the ingress_ifindex is
0, return -EINVAL.

Co-developed-by: Cody Haas <chaas@riotgames.com>
Co-developed-by: Lisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: Cody Haas <chaas@riotgames.com>
Signed-off-by: Lisa Watanabe <lwatanabe@riotgames.com>
Signed-off-by: Zvi Effron <zeffron@riotgames.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210707221657.3985075-4-zeffron@riotgames.com
net/bpf/test_run.c