net/af_xdp: fix custom program loading with multiple queues

Message ID 2c42e3e23c18fd60@cs.arizona.edu (mailing list archive)
State Accepted, archived
Delegated to: Ferruh Yigit
Headers
Series net/af_xdp: fix custom program loading with multiple queues |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Junxiao Shi March 9, 2022, 9:18 p.m. UTC
  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")

Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
---
 drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
  

Comments

Loftus, Ciara March 10, 2022, 8:49 a.m. UTC | #1
> 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")
> 
> Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>

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.

Acked-by: Ciara Loftus <ciara.loftus@intel.com>

> ---
>  drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
>  1 file changed, 12 insertions(+), 11 deletions(-)
> 
> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
> b/drivers/net/af_xdp/rte_eth_af_xdp.c
> index 65479138d3..9920f49870 100644
> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
> @@ -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)
> --
> 2.17.1
  
Kevin Traynor March 10, 2022, 9:41 a.m. UTC | #2
Hi Ciara/Junxiao,,

On 10/03/2022 08:49, Loftus, Ciara wrote:
>> 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")
>>
>> Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
> 
> 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: stable@dpdk.com' 
tag in the commit message.

Kevin.

> Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> 
>> ---
>>   drivers/net/af_xdp/rte_eth_af_xdp.c | 23 ++++++++++++-----------
>>   1 file changed, 12 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c
>> b/drivers/net/af_xdp/rte_eth_af_xdp.c
>> index 65479138d3..9920f49870 100644
>> --- a/drivers/net/af_xdp/rte_eth_af_xdp.c
>> +++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
>> @@ -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)
>> --
>> 2.17.1
>
  
Thomas Monjalon March 11, 2022, 8:01 a.m. UTC | #3
10/03/2022 09:49, Loftus, Ciara:
> > 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")
> > 
> > Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
> 
> 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.
> 
> Acked-by: Ciara Loftus <ciara.loftus@intel.com>

I can take it in -rc4. How much are you confident there is no regression?
  
Loftus, Ciara March 11, 2022, 11:12 a.m. UTC | #4
> 
> 10/03/2022 09:49, Loftus, Ciara:
> > > 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")
> > >
> > > Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
> >
> > 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.
> >
> > Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> 
> I can take it in -rc4. How much are you confident there is no regression?
> 

Thanks. I am confident there is no regression.
  
Thomas Monjalon March 14, 2022, 8:41 a.m. UTC | #5
11/03/2022 12:12, Loftus, Ciara:
> > 
> > 10/03/2022 09:49, Loftus, Ciara:
> > > > 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")
> > > >
> > > > Signed-off-by: Junxiao Shi <git@mail1.yoursunny.com>
> > >
> > > 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.
> > >
> > > Acked-by: Ciara Loftus <ciara.loftus@intel.com>
> > 
> > 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.
  

Patch

diff --git a/drivers/net/af_xdp/rte_eth_af_xdp.c b/drivers/net/af_xdp/rte_eth_af_xdp.c
index 65479138d3..9920f49870 100644
--- a/drivers/net/af_xdp/rte_eth_af_xdp.c
+++ b/drivers/net/af_xdp/rte_eth_af_xdp.c
@@ -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)