From: Andrii Nakryiko <andrii.nakryiko@gmail.com>
To: Lorenzo Bianconi <lorenzo@kernel.org>
Cc: bpf@vger.kernel.org, netdev@vger.kernel.org, ast@kernel.org,
daniel@iogearbox.net, andrii@kernel.org, davem@davemloft.net,
kuba@kernel.org, pabeni@redhat.com, edumazet@google.com,
hawk@kernel.org, toke@redhat.com, memxor@gmail.com,
alardam@gmail.com, saeedm@nvidia.com, anthony.l.nguyen@intel.com,
gospo@broadcom.com, vladimir.oltean@nxp.com, nbd@nbd.name,
john@phrozen.org, leon@kernel.org, simon.horman@corigine.com,
aelior@marvell.com, christophe.jaillet@wanadoo.fr,
ecree.xilinx@gmail.com, mst@redhat.com, bjorn@kernel.org,
magnus.karlsson@intel.com, maciej.fijalkowski@intel.com,
intel-wired-lan@lists.osuosl.org, lorenzo.bianconi@redhat.com,
martin.lau@linux.dev, sdf@google.com,
gerhard@engleder-embedded.com
Subject: Re: [PATCH v5 bpf-next 5/8] libbpf: add API to get XDP/XSK supported features
Date: Mon, 6 Feb 2023 14:42:29 -0800 [thread overview]
Message-ID: <CAEf4BzZS-MSen_1q4eotMe3hdkXUXxpwnfbLqEENzU1ogejxUQ@mail.gmail.com> (raw)
In-Reply-To: <a72609ef4f0de7fee5376c40dbf54ad7f13bfb8d.1675245258.git.lorenzo@kernel.org>
On Wed, Feb 1, 2023 at 2:25 AM Lorenzo Bianconi <lorenzo@kernel.org> wrote:
>
> Extend bpf_xdp_query routine in order to get XDP/XSK supported features
> of netdev over route netlink interface.
> Extend libbpf netlink implementation in order to support netlink_generic
> protocol.
>
> Co-developed-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
> Co-developed-by: Marek Majtyka <alardam@gmail.com>
> Signed-off-by: Marek Majtyka <alardam@gmail.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> tools/lib/bpf/libbpf.h | 3 +-
> tools/lib/bpf/netlink.c | 96 +++++++++++++++++++++++++++++++++++++++++
> tools/lib/bpf/nlattr.h | 12 ++++++
> 3 files changed, 110 insertions(+), 1 deletion(-)
>
[...]
> @@ -366,6 +433,10 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
> .ifinfo.ifi_family = AF_PACKET,
> };
> struct xdp_id_md xdp_id = {};
> + struct xdp_features_md md = {
> + .ifindex = ifindex,
> + };
> + __u16 id;
> int err;
>
> if (!OPTS_VALID(opts, bpf_xdp_query_opts))
> @@ -393,6 +464,31 @@ int bpf_xdp_query(int ifindex, int xdp_flags, struct bpf_xdp_query_opts *opts)
> OPTS_SET(opts, skb_prog_id, xdp_id.info.skb_prog_id);
> OPTS_SET(opts, attach_mode, xdp_id.info.attach_mode);
>
> + if (!OPTS_HAS(opts, feature_flags))
> + return 0;
> +
> + err = libbpf_netlink_resolve_genl_family_id("netdev", sizeof("netdev"), &id);
> + if (err < 0)
> + return libbpf_err(err);
> +
> + memset(&req, 0, sizeof(req));
> + req.nh.nlmsg_len = NLMSG_LENGTH(GENL_HDRLEN);
> + req.nh.nlmsg_flags = NLM_F_REQUEST;
> + req.nh.nlmsg_type = id;
> + req.gnl.cmd = NETDEV_CMD_DEV_GET;
> + req.gnl.version = 2;
> +
> + err = nlattr_add(&req, NETDEV_A_DEV_IFINDEX, &ifindex, sizeof(ifindex));
> + if (err < 0)
> + return err;
just noticed this, we need to use libbpf_err(err) here like in other
error cases to set errno properly. Can you please send a follow up?
> +
> + err = libbpf_netlink_send_recv(&req, NETLINK_GENERIC,
> + parse_xdp_features, NULL, &md);
> + if (err)
> + return libbpf_err(err);
> +
> + opts->feature_flags = md.flags;
> +
> return 0;
> }
>
[...]
next prev parent reply other threads:[~2023-02-06 22:42 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-01 10:24 [PATCH v5 bpf-next 0/8] xdp: introduce xdp-feature support Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 1/8] netdev-genl: create a simple family for netdev stuff Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 2/8] drivers: net: turn on XDP features Lorenzo Bianconi
2023-02-07 8:57 ` Martin Habets
2023-02-07 10:05 ` Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 3/8] xsk: add usage of XDP features flags Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 4/8] libbpf: add the capability to specify netlink proto in libbpf_netlink_send_recv Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 5/8] libbpf: add API to get XDP/XSK supported features Lorenzo Bianconi
2023-02-06 22:42 ` Andrii Nakryiko [this message]
2023-02-06 22:55 ` Lorenzo Bianconi
2023-02-27 20:38 ` Yonghong Song
2023-02-27 21:01 ` Andrii Nakryiko
2023-02-27 22:05 ` Yonghong Song
2023-02-27 22:49 ` Andrii Nakryiko
2023-02-01 10:24 ` [PATCH v5 bpf-next 6/8] bpf: devmap: check XDP features in __xdp_enqueue routine Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 7/8] selftests/bpf: add test for bpf_xdp_query xdp-features support Lorenzo Bianconi
2023-02-01 10:24 ` [PATCH v5 bpf-next 8/8] selftests/bpf: introduce XDP compliance test tool Lorenzo Bianconi
2023-02-01 19:31 ` Stanislav Fomichev
2023-02-03 5:05 ` Alexei Starovoitov
2023-02-03 17:36 ` Lorenzo Bianconi
2023-02-03 23:50 ` Alexei Starovoitov
2023-02-03 5:10 ` [PATCH v5 bpf-next 0/8] xdp: introduce xdp-feature support patchwork-bot+netdevbpf
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=CAEf4BzZS-MSen_1q4eotMe3hdkXUXxpwnfbLqEENzU1ogejxUQ@mail.gmail.com \
--to=andrii.nakryiko@gmail.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=gerhard@engleder-embedded.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.bianconi@redhat.com \
--cc=lorenzo@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--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=sdf@google.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;
as well as URLs for NNTP newsgroup(s).