Skip to contentSkip to conversation

net/af_xdp: fix custom program loading with multiple queues

PATCH Applied Junxiao Shi 4 participants 6 messages Mar 9, 2022 – Mar 14, 2022 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/af_xdp: fix custom program loading with multiple queues

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag is set for all XSK socket creations when custom XDP program is being used.

Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +12 -11
index 65479138d3..9920f49870 100644
@@ -1307,18 +1307,19 @@ xsk_configure(struct pmd_internals *internals, struct pkt_rx_queue *rxq,
 	cfg.bind_flags |= XDP_USE_NEED_WAKEUP;
 #endif
 
-	if (strnlen(internals->prog_path, PATH_MAX) &&
-				!internals->custom_prog_configured) {
-		ret = load_custom_xdp_prog(internals->prog_path,
-					   internals->if_index,
-					   &internals->map);
-		if (ret) {
-			AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
-					internals->prog_path);
-			goto out_umem;
+	if (strnlen(internals->prog_path, PATH_MAX)) {
+		if (!internals->custom_prog_configured) {
+			ret = load_custom_xdp_prog(internals->prog_path,
+							internals->if_index,
+							&internals->map);
+			if (ret) {
+				AF_XDP_LOG(ERR, "Failed to load custom XDP program %s\n",
+						internals->prog_path);
+				goto out_umem;
+			}
+			internals->custom_prog_configured = 1;
 		}
-		internals->custom_prog_configured = 1;
-		cfg.libbpf_flags = XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
+		cfg.libbpf_flags |= XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
 	}
 
 	if (internals->shared_umem)
Signature · 1 line
2.17.1
Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

Quoted 6 lines

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag is set for all XSK socket creations when custom XDP program is being used.

Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")

Thanks for the patch!
It's probably too late to make it into 22.03 but cc-ing stable as it should be backported to 21.11.x.

Quoted 47 lines
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +11 -11
index 65479138d3..9920f49870 100644
@@ -1307,18 +1307,19 @@ xsk_configure(struct pmd_internals *internals,
 struct pkt_rx_queue *rxq,
 	cfg.bind_flags |= XDP_USE_NEED_WAKEUP;
 #endif
 
-	if (strnlen(internals->prog_path, PATH_MAX) &&
-				!internals->custom_prog_configured) {
-		ret = load_custom_xdp_prog(internals->prog_path,
-					   internals->if_index,
-					   &internals->map);
-		if (ret) {
-			AF_XDP_LOG(ERR, "Failed to load custom XDP
 program %s\n",
-					internals->prog_path);
-			goto out_umem;
+	if (strnlen(internals->prog_path, PATH_MAX)) {
+		if (!internals->custom_prog_configured) {
+			ret = load_custom_xdp_prog(internals->prog_path,
+							internals->if_index,
+							&internals->map);
+			if (ret) {
+				AF_XDP_LOG(ERR, "Failed to load custom
 XDP program %s\n",
+						internals->prog_path);
+				goto out_umem;
+			}
+			internals->custom_prog_configured = 1;
 		}
-		internals->custom_prog_configured = 1;
-		cfg.libbpf_flags =

XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;

drivers/net/af_xdp/rte_eth_af_xdp.c +1 -0
+		cfg.libbpf_flags |=

XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;

drivers/net/af_xdp/rte_eth_af_xdp.c +0 -1
 	}
 
 	if (internals->shared_umem)
--

2.17.1

#2 lore raw

Hi Ciara/Junxiao,,

Quoted 9 lines · Ciara
Quoted 9 lines

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag is set for all XSK socket creations when custom XDP program is being used.

Quoted 7 lines
Quoted 3 lines
Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")

Thanks for the patch!
It's probably too late to make it into 22.03 but cc-ing stable as it should be backported to 21.11.x.

21.11.1 will take backports from 22.03. So it will be in a later 21.11.x release if it doesn't make 22.03. Please add the 'Cc: [email protected]' tag in the commit message.

Kevin.

Quoted 50 lines
Quoted 47 lines
---
  drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
  1 file changed, 12 insertions(+), 11 deletions(-)
drivers/net/af_xdp/rte_eth_af_xdp.c +11 -11
index 65479138d3..9920f49870 100644
@@ -1307,18 +1307,19 @@ xsk_configure(struct pmd_internals *internals,
 struct pkt_rx_queue *rxq,
  	cfg.bind_flags |= XDP_USE_NEED_WAKEUP;
  #endif
 
-	if (strnlen(internals->prog_path, PATH_MAX) &&
-				!internals->custom_prog_configured) {
-		ret = load_custom_xdp_prog(internals->prog_path,
-					   internals->if_index,
-					   &internals->map);
-		if (ret) {
-			AF_XDP_LOG(ERR, "Failed to load custom XDP
 program %s\n",
-					internals->prog_path);
-			goto out_umem;
+	if (strnlen(internals->prog_path, PATH_MAX)) {
+		if (!internals->custom_prog_configured) {
+			ret = load_custom_xdp_prog(internals->prog_path,
+							internals->if_index,
+							&internals->map);
+			if (ret) {
+				AF_XDP_LOG(ERR, "Failed to load custom
 XDP program %s\n",
+						internals->prog_path);
+				goto out_umem;
+			}
+			internals->custom_prog_configured = 1;
  		}
-		internals->custom_prog_configured = 1;
-		cfg.libbpf_flags =

XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;

drivers/net/af_xdp/rte_eth_af_xdp.c +1 -0
+		cfg.libbpf_flags |=

XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD;
}

if (internals->shared_umem)
--
2.17.1

#3 lore raw
In reply to Loftus, Ciara

10/03/2022 09:49, Loftus, Ciara:

Quoted 9 lines
Quoted 9 lines

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag is set for all XSK socket creations when custom XDP program is being used.

Quoted 8 lines
Quoted 3 lines
Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")

Thanks for the patch!
It's probably too late to make it into 22.03 but cc-ing stable as it should be backported to 21.11.x.

I can take it in -rc4. How much are you confident there is no regression?

#4 lore raw
Quoted 16 lines

10/03/2022 09:49, Loftus, Ciara:

Quoted 7 lines
Quoted 7 lines

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag

is

Quoted 6 lines
Quoted 5 lines

set for all XSK socket creations when custom XDP program is being used.

Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")
Quoted 8 lines
Quoted 2 lines

Thanks for the patch!
It's probably too late to make it into 22.03 but cc-ing stable as it should be

backported to 21.11.x.

Quoted 2 lines

I can take it in -rc4. How much are you confident there is no regression?

Thanks. I am confident there is no regression.

#5 lore raw

11/03/2022 12:12, Loftus, Ciara:

Quoted 18 lines
Quoted 18 lines

10/03/2022 09:49, Loftus, Ciara:

Quoted 7 lines
Quoted 7 lines

When the PMD is configured to load a custom XDP program, it sets XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag to prevent libbpf from loading its default XDP program. However, when queue_count is set to greater than 1, this flag is only set for the first XSK socket but not for subsequent XSK sockets. This causes XSK socket creation failure.

This commit ensures that XSK_LIBBPF_FLAGS__INHIBIT_PROG_LOAD flag

is

Quoted 8 lines
Quoted 5 lines

set for all XSK socket creations when custom XDP program is being used.

Fixes 01fa83c94d7e ("net/af_xdp: workaround custom program loading")

Thanks for the patch!
It's probably too late to make it into 22.03 but cc-ing stable as it should be

Quoted 8 lines
Quoted 6 lines

backported to 21.11.x.

Quoted 2 lines

I can take it in -rc4. How much are you confident there is no regression?

Thanks. I am confident there is no regression.

Applied, thanks.