patch 'net/af_xdp: make compatible with libbpf 0.8.0' has been queued to stable release 21.11.6

Loftus, Ciara ciara.loftus at intel.com
Mon Dec 11 13:44:36 CET 2023


> 
> Hi Ciara,
> 
> On 07/12/2023 11:21, Kevin Traynor wrote:
> > Hi,
> >
> > FYI, your patch has been queued to stable release 21.11.6
> >
> > Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
> > It will be pushed if I get no objections before 12/12/23. So please
> > shout if anyone has objections.
> >
> > Also note that after the patch there's a diff of the upstream commit vs the
> > patch applied to the branch. This will indicate if there was any rebasing
> > needed to apply to the stable branch. If there were code changes for
> rebasing
> > (ie: not only metadata diffs), please double check that the rebase was
> > correctly done.
> >
> > Queued patches are on a temporary branch at:
> > https://github.com/kevintraynor/dpdk-stable
> >
> > This queued commit can be viewed at:
> > https://github.com/kevintraynor/dpdk-
> stable/commit/770e7c27240d09571a62627c3bc90b8e6e9f6024
> >
> > Thanks.
> >
> > Kevin
> >
> > ---
> >  From 770e7c27240d09571a62627c3bc90b8e6e9f6024 Mon Sep 17
> 00:00:00 2001
> > From: Ciara Loftus <ciara.loftus at intel.com>
> > Date: Thu, 6 Oct 2022 09:26:54 +0300
> > Subject: [PATCH] net/af_xdp: make compatible with libbpf 0.8.0
> >
> > [ upstream commit 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc ]
> >
> > libbpf v0.8.0 deprecates the bpf_get_link_xdp_id() and
> > bpf_set_link_xdp_fd() functions. Use meson to detect if
> > bpf_xdp_attach() is available and if so, use the recommended
> > replacement functions bpf_xdp_query_id(), bpf_xdp_attach()
> > and bpf_xdp_detach().
> >
> > Signed-off-by: Ciara Loftus <ciara.loftus at intel.com>
> > Signed-off-by: Andrew Rybchenko <andrew.rybchenko at oktetlabs.ru>
> > Reviewed-by: Ferruh Yigit <ferruh.yigit at xilinx.com>
> > ---
> >   drivers/net/af_xdp/meson.build      |  8 ++++++
> >   drivers/net/af_xdp/rte_eth_af_xdp.c | 38
> ++++++++++++++++++++++++++++-
> >   2 files changed, 45 insertions(+), 1 deletion(-)
> >
> 
> I saw that af_xdp driver was not building [0] on F38 with the libbpf and
> libxdp packages [1]. Previously I had squashed the deprecation warnings
> but now with newer package versions it seems that is not enough.
> 
> The meson.build file has changed a bit from 21.11 to DPDK main, so I
> tried to take the correct part from the above commit and it builds for
> F38 now.
> 
> I'm not sure if I missed some case, or there's some other commits that I
> should backport.
> 
> Can you have a look and if it's not right, send a patch or tell me which
> patches should be backported ? (you can see the diff and full file on
> the github link above).

Hi Kevin,

This patch was the final patch in a set of 6 from Andrew Rybchenko:
https://patches.dpdk.org/project/dpdk/cover/20221006062654.1420349-1-andrew.rybchenko@oktetlabs.ru/

On its own the patch is enough to support libbpf 0.8.0 and no other changes are necessary. The rebase looks good to me.
The rest of the patchset tidies up the meson file and removes version-based checks in favour of checking for the presence of functions in the library. It's not an essential change to backport IMO.

Thanks,
Ciara

> 
> thanks,
> Kevin.
> 
> 
> [0]
> [1126/3148] Compiling C object
> drivers/libtmp_rte_net_af_xdp.a.p/net_af_xdp_rte_eth_af_xdp.c.o
> ../drivers/net/af_xdp/rte_eth_af_xdp.c: In function ‘remove_xdp_program’:
> ../drivers/net/af_xdp/rte_eth_af_xdp.c:869:13: warning: implicit
> declaration of function ‘bpf_get_link_xdp_id’
> [-Wimplicit-function-declaration]
>    869 |         if (bpf_get_link_xdp_id(internals->if_index, &curr_prog_id,
>        |             ^~~~~~~~~~~~~~~~~~~
> ../drivers/net/af_xdp/rte_eth_af_xdp.c:869:13: warning: nested extern
> declaration of ‘bpf_get_link_xdp_id’ [-Wnested-externs]
> ../drivers/net/af_xdp/rte_eth_af_xdp.c:874:9: warning: implicit
> declaration of function ‘bpf_set_link_xdp_fd’; did you mean
> ‘bpf_link__fd’? [-Wimplicit-function-declaration]
>    874 |         bpf_set_link_xdp_fd(internals->if_index, -1,
>        |         ^~~~~~~~~~~~~~~~~~~
>        |         bpf_link__fd
> ../drivers/net/af_xdp/rte_eth_af_xdp.c:874:9: warning: nested extern
> declaration of ‘bpf_set_link_xdp_fd’ [-Wnested-externs]
> 
> 
> [1]
> $ rpm -qa | grep -e libbpf -e libxdp
> libbpf-1.1.0-2.fc38.x86_64
> libbpf-devel-1.1.0-2.fc38.x86_64
> libxdp-1.4.1-1.fc38.x86_64
> libxdp-devel-1.4.1-1.fc38.x86_64
> 
> 
> 
> 
> > diff --git a/drivers/net/af_xdp/meson.build
> b/drivers/net/af_xdp/meson.build
> > index 1e0de23705..2605086d0c 100644
> > --- a/drivers/net/af_xdp/meson.build
> > +++ b/drivers/net/af_xdp/meson.build
> > @@ -56,2 +56,10 @@ else
> >       reason = 'missing header, "linux/if_xdp.h"'
> >   endif
> > +
> > +if build
> > +  if cc.has_function('bpf_xdp_attach',
> > +                     prefix : '#include <bpf/libbpf.h>',
> > +                     dependencies : bpf_dep)
> > +      cflags += ['-DRTE_NET_AF_XDP_LIBBPF_XDP_ATTACH']
> > +  endif
> > +endif
> > diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> > index 9918d3c5fd..6bc7178fc5 100644
> > --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> > +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> > @@ -859,7 +859,41 @@ eth_stats_reset(struct rte_eth_dev *dev)
> >   }
> >
> > +#ifdef RTE_NET_AF_XDP_LIBBPF_XDP_ATTACH
> > +
> > +static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
> > +{
> > +	return bpf_xdp_attach(ifindex, fd, flags, NULL);
> > +}
> > +
> > +static int
> > +remove_xdp_program(struct pmd_internals *internals)
> > +{
> > +	uint32_t curr_prog_id = 0;
> > +	int ret;
> > +
> > +	ret = bpf_xdp_query_id(internals->if_index,
> XDP_FLAGS_UPDATE_IF_NOEXIST,
> > +			       &curr_prog_id);
> > +	if (ret != 0) {
> > +		AF_XDP_LOG(ERR, "bpf_xdp_query_id failed\n");
> > +		return ret;
> > +	}
> > +
> > +	ret = bpf_xdp_detach(internals->if_index,
> XDP_FLAGS_UPDATE_IF_NOEXIST,
> > +			     NULL);
> > +	if (ret != 0)
> > +		AF_XDP_LOG(ERR, "bpf_xdp_detach failed\n");
> > +	return ret;
> > +}
> > +
> > +#else
> > +
> >   #pragma GCC diagnostic push
> >   #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
> >
> > +static int link_xdp_prog_with_dev(int ifindex, int fd, __u32 flags)
> > +{
> > +	return bpf_set_link_xdp_fd(ifindex, fd, flags);
> > +}
> > +
> >   static void
> >   remove_xdp_program(struct pmd_internals *internals)
> > @@ -878,4 +912,6 @@ remove_xdp_program(struct pmd_internals
> *internals)
> >   #pragma GCC diagnostic pop
> >
> > +#endif
> > +
> >   static void
> >   xdp_umem_destroy(struct xsk_umem_info *umem)
> > @@ -1190,5 +1226,5 @@ load_custom_xdp_prog(const char *prog_path,
> int if_index, struct bpf_map **map)
> >
> >   	/* Link the program with the given network device */
> > -	ret = bpf_set_link_xdp_fd(if_index, prog_fd,
> > +	ret = link_xdp_prog_with_dev(if_index, prog_fd,
> >   					XDP_FLAGS_UPDATE_IF_NOEXIST);
> >   	if (ret) {



More information about the stable mailing list