summaryrefslogtreecommitdiff
path: root/tools/testing/selftests/bpf/prog_tests/xdp_info.c
diff options
context:
space:
mode:
authorLorenzo Bianconi <lorenzo@kernel.org>2023-02-01 11:24:23 +0100
committerAlexei Starovoitov <ast@kernel.org>2023-02-02 20:48:24 -0800
commit84050074e51b68e6f1d3e89ebe8f8f6d73472ec3 (patch)
tree593d009fd00eb910b7ba28af7288673a9269e145 /tools/testing/selftests/bpf/prog_tests/xdp_info.c
parentb9d460c9245541b13de2369e79688f8e0acc0c3d (diff)
selftests/bpf: add test for bpf_xdp_query xdp-features support
Introduce a self-test to verify libbpf bpf_xdp_query capability to dump the xdp-features supported by the device (lo and veth in this case). Acked-by: Stanislav Fomichev <sdf@google.com> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org> Link: https://lore.kernel.org/r/534550318a2c883e174811683909544c63632f05.1675245258.git.lorenzo@kernel.org Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/xdp_info.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/xdp_info.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_info.c b/tools/testing/selftests/bpf/prog_tests/xdp_info.c
index cd3aa340e65e..286c21ecdc65 100644
--- a/tools/testing/selftests/bpf/prog_tests/xdp_info.c
+++ b/tools/testing/selftests/bpf/prog_tests/xdp_info.c
@@ -8,6 +8,7 @@ void serial_test_xdp_info(void)
{
__u32 len = sizeof(struct bpf_prog_info), duration = 0, prog_id;
const char *file = "./xdp_dummy.bpf.o";
+ LIBBPF_OPTS(bpf_xdp_query_opts, opts);
struct bpf_prog_info info = {};
struct bpf_object *obj;
int err, prog_fd;
@@ -61,6 +62,13 @@ void serial_test_xdp_info(void)
if (CHECK(prog_id, "prog_id_drv", "unexpected prog_id=%u\n", prog_id))
goto out;
+ /* Check xdp features supported by lo device */
+ opts.feature_flags = ~0;
+ err = bpf_xdp_query(IFINDEX_LO, XDP_FLAGS_DRV_MODE, &opts);
+ if (!ASSERT_OK(err, "bpf_xdp_query"))
+ goto out;
+
+ ASSERT_EQ(opts.feature_flags, 0, "opts.feature_flags");
out:
bpf_xdp_detach(IFINDEX_LO, 0, NULL);
out_close: