From: sdf@google.com
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: mst@redhat.com, vladimir.oltean@nxp.com, ast@kernel.org,
edumazet@google.com, anthony.l.nguyen@intel.com,
daniel@iogearbox.net, andrii@kernel.org,
intel-wired-lan@lists.osuosl.org, simon.horman@corigine.com,
kuba@kernel.org, pabeni@redhat.com, aelior@marvell.com,
hawk@kernel.org, christophe.jaillet@wanadoo.fr, memxor@gmail.com,
john@phrozen.org, bjorn@kernel.org, bpf@vger.kernel.org,
magnus.karlsson@intel.com, leon@kernel.org,
netdev@vger.kernel.org, toke@redhat.com, martin.lau@linux.dev,
ecree.xilinx@gmail.com, alardam@gmail.com, gospo@broadcom.com,
saeedm@nvidia.com, davem@davemloft.net, nbd@nbd.name
Subject: Re: [Intel-wired-lan] [PATCH v3 bpf-next 7/8] selftests/bpf: add test for bpf_xdp_query xdp-features support
Date: Thu, 26 Jan 2023 10:28:02 -0800 [thread overview]
Message-ID: <Y9LGMha3+jPLBXsb@google.com> (raw)
In-Reply-To: <7c403a3a043554df3ebe4b4a94b8e0d97414cb7e.1674737592.git.lorenzo@kernel.org>
On 01/26, Lorenzo Bianconi wrote:
> 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).
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Acked-by: Stanislav Fomichev <sdf@google.com>
> ---
> .../bpf/prog_tests/xdp_do_redirect.c | 27 ++++++++++++++++++-
> .../selftests/bpf/prog_tests/xdp_info.c | 8 ++++++
> 2 files changed, 34 insertions(+), 1 deletion(-)
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> index a50971c6cf4a..e15fb3f0306c 100644
> --- a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> +++ b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c
> @@ -4,10 +4,12 @@
> #include <net/if.h>
> #include <linux/if_ether.h>
> #include <linux/if_packet.h>
> +#include <linux/if_link.h>
> #include <linux/ipv6.h>
> #include <linux/in6.h>
> #include <linux/udp.h>
> #include <bpf/bpf_endian.h>
> +#include <uapi/linux/netdev.h>
> #include "test_xdp_do_redirect.skel.h"
> #define SYS(fmt, ...) \
> @@ -92,7 +94,7 @@ void test_xdp_do_redirect(void)
> struct test_xdp_do_redirect *skel = NULL;
> struct nstoken *nstoken = NULL;
> struct bpf_link *link;
> -
> + LIBBPF_OPTS(bpf_xdp_query_opts, query_opts);
> struct xdp_md ctx_in = { .data = sizeof(__u32),
> .data_end = sizeof(data) };
> DECLARE_LIBBPF_OPTS(bpf_test_run_opts, opts,
> @@ -153,6 +155,29 @@ void test_xdp_do_redirect(void)
> !ASSERT_NEQ(ifindex_dst, 0, "ifindex_dst"))
> goto out;
> + /* Check xdp features supported by veth driver */
> + err = bpf_xdp_query(ifindex_src, XDP_FLAGS_DRV_MODE, &query_opts);
> + if (!ASSERT_OK(err, "veth_src bpf_xdp_query"))
> + goto out;
> +
> + if (!ASSERT_EQ(query_opts.fflags,
> + NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
> + NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG |
> + NETDEV_XDP_ACT_NDO_XMIT_SG,
> + "veth_src query_opts.fflags"))
> + goto out;
> +
> + err = bpf_xdp_query(ifindex_dst, XDP_FLAGS_DRV_MODE, &query_opts);
> + if (!ASSERT_OK(err, "veth_dst bpf_xdp_query"))
> + goto out;
> +
> + if (!ASSERT_EQ(query_opts.fflags,
> + NETDEV_XDP_ACT_BASIC | NETDEV_XDP_ACT_REDIRECT |
> + NETDEV_XDP_ACT_NDO_XMIT | NETDEV_XDP_ACT_RX_SG |
> + NETDEV_XDP_ACT_NDO_XMIT_SG,
> + "veth_dst query_opts.fflags"))
> + goto out;
> +
> memcpy(skel->rodata->expect_dst, &pkt_udp.eth.h_dest, ETH_ALEN);
> skel->rodata->ifindex_out = ifindex_src; /* redirect back to the same
> iface */
> skel->rodata->ifindex_in = ifindex_src;
> diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_info.c
> b/tools/testing/selftests/bpf/prog_tests/xdp_info.c
> index cd3aa340e65e..8397468a9e74 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.fflags = ~0;
> + err = bpf_xdp_query(IFINDEX_LO, XDP_FLAGS_DRV_MODE, &opts);
> + if (!ASSERT_OK(err, "bpf_xdp_query"))
> + goto out;
> +
> + ASSERT_EQ(opts.fflags, 0, "opts.fflags");
> out:
> bpf_xdp_detach(IFINDEX_LO, 0, NULL);
> out_close:
> --
> 2.39.1
_______________________________________________
Intel-wired-lan mailing list
Intel-wired-lan@osuosl.org
https://lists.osuosl.org/mailman/listinfo/intel-wired-lan
next prev parent reply other threads:[~2023-01-26 18:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-26 12:58 [Intel-wired-lan] [PATCH v3 bpf-next 0/8] xdp: introduce xdp-feature support Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 1/8] netdev-genl: create a simple family for netdev stuff Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 2/8] drivers: net: turn on XDP features Lorenzo Bianconi
2023-01-26 18:27 ` sdf
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 3/8] xsk: add usage of XDP features flags Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 4/8] libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 5/8] libbpf: add API to get XDP/XSK supported features Lorenzo Bianconi
2023-01-27 23:38 ` Andrii Nakryiko
2023-01-28 12:48 ` Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 6/8] bpf: devmap: check XDP features in __xdp_enqueue routine Lorenzo Bianconi
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 7/8] selftests/bpf: add test for bpf_xdp_query xdp-features support Lorenzo Bianconi
2023-01-26 18:28 ` sdf [this message]
2023-01-26 12:58 ` [Intel-wired-lan] [PATCH v3 bpf-next 8/8] selftests/bpf: introduce XDP compliance test tool Lorenzo Bianconi
2023-01-26 18:36 ` sdf
2023-01-27 8:19 ` Martin KaFai Lau
2023-01-27 17:26 ` Lorenzo Bianconi
2023-01-27 17:26 ` Lorenzo Bianconi
2023-01-27 17:41 ` Stanislav Fomichev
2023-01-27 17:52 ` Toke Høiland-Jørgensen
2023-01-27 17:58 ` Lorenzo Bianconi
2023-01-27 17:59 ` Stanislav Fomichev
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y9LGMha3+jPLBXsb@google.com \
--to=sdf@google.com \
--cc=aelior@marvell.com \
--cc=alardam@gmail.com \
--cc=andrii@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=christophe.jaillet@wanadoo.fr \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=ecree.xilinx@gmail.com \
--cc=edumazet@google.com \
--cc=gospo@broadcom.com \
--cc=hawk@kernel.org \
--cc=intel-wired-lan@lists.osuosl.org \
--cc=john@phrozen.org \
--cc=kuba@kernel.org \
--cc=leon@kernel.org \
--cc=lorenzo@kernel.org \
--cc=magnus.karlsson@intel.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=mst@redhat.com \
--cc=nbd@nbd.name \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=saeedm@nvidia.com \
--cc=simon.horman@corigine.com \
--cc=toke@redhat.com \
--cc=vladimir.oltean@nxp.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox