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

Kevin Traynor ktraynor at redhat.com
Thu Dec 7 12:21:14 CET 2023


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(-)

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) {
-- 
2.43.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-12-07 11:19:00.123229717 +0000
+++ 0022-net-af_xdp-make-compatible-with-libbpf-0.8.0.patch	2023-12-07 11:18:59.651874009 +0000
@@ -1 +1 @@
-From 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc Mon Sep 17 00:00:00 2001
+From 770e7c27240d09571a62627c3bc90b8e6e9f6024 Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 1eb1846b1a2caaf77d0697747d3ecd1272ce0bfc ]
+
@@ -16,4 +18,3 @@
- doc/guides/rel_notes/release_22_11.rst |  4 +++
- drivers/net/af_xdp/meson.build         |  5 ++++
- drivers/net/af_xdp/rte_eth_af_xdp.c    | 38 +++++++++++++++++++++++++-
- 3 files changed, 46 insertions(+), 1 deletion(-)
+ drivers/net/af_xdp/meson.build      |  8 ++++++
+ drivers/net/af_xdp/rte_eth_af_xdp.c | 38 ++++++++++++++++++++++++++++-
+ 2 files changed, 45 insertions(+), 1 deletion(-)
@@ -21,13 +21,0 @@
-diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst
-index 5fbac5cfc1..aef2d622dd 100644
---- a/doc/guides/rel_notes/release_22_11.rst
-+++ b/doc/guides/rel_notes/release_22_11.rst
-@@ -101,4 +101,8 @@ New Features
-   directly to the kernel without software involvement.
- 
-+* **Updated AF_XDP driver.**
-+
-+  * Made compatible with libbpf v0.8.0 (when used with libxdp).
-+
- * **Updated Intel iavf driver.**
- 
@@ -35 +23 @@
-index 9d5ffab96b..858047989e 100644
+index 1e0de23705..2605086d0c 100644
@@ -38,3 +26,5 @@
-@@ -65,3 +65,8 @@ if build
-       cflags += ['-DRTE_NET_AF_XDP_LIBBPF_OBJ_OPEN']
-   endif
+@@ -56,2 +56,10 @@ else
+     reason = 'missing header, "linux/if_xdp.h"'
+ endif
++
++if build
@@ -46 +36 @@
- endif
++endif
@@ -48 +38 @@
-index f7c2321a18..b6ec9bf490 100644
+index 9918d3c5fd..6bc7178fc5 100644
@@ -51 +41 @@
-@@ -867,4 +867,38 @@ eth_stats_reset(struct rte_eth_dev *dev)
+@@ -859,7 +859,41 @@ eth_stats_reset(struct rte_eth_dev *dev)
@@ -82,0 +73,3 @@
+ #pragma GCC diagnostic push
+ #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ 
@@ -88 +81 @@
- static int
+ static void
@@ -90,2 +83,2 @@
-@@ -887,4 +921,6 @@ remove_xdp_program(struct pmd_internals *internals)
- }
+@@ -878,4 +912,6 @@ remove_xdp_program(struct pmd_internals *internals)
+ #pragma GCC diagnostic pop
@@ -97 +90 @@
-@@ -1206,5 +1242,5 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)
+@@ -1190,5 +1226,5 @@ load_custom_xdp_prog(const char *prog_path, int if_index, struct bpf_map **map)



More information about the stable mailing list