2021-06-07 13:11:04

by Kev Jackson

[permalink] [raw]
Subject: [PATCH] libbpf: Fixes incorrect rx_ring_setup_done

When calling xsk_socket__create_shared(), the logic at line 1097 marks a
boolean flag true within the xsk_umem structure to track setup progress
in order to support multiple calls to the function. However, instead of
marking umem->tx_ring_setup_done, the code incorrectly sets
umem->rx_ring_setup_done. This leads to improper behaviour when
creating and destroying xsk and umem structures.

Multiple calls to this function is documented as supported.

Signed-off-by: Kev Jackson <[email protected]>
---
tools/lib/bpf/xsk.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 6061431ee04c..e9b619aa0cdf 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -1094,7 +1094,7 @@ int xsk_socket__create_shared(struct xsk_socket **xsk_ptr,
goto out_put_ctx;
}
if (xsk->fd == umem->fd)
- umem->rx_ring_setup_done = true;
+ umem->tx_ring_setup_done = true;
}

err = xsk_get_mmap_offsets(xsk->fd, &off);
--
2.30.2


2021-06-07 15:06:12

by Yonghong Song

[permalink] [raw]
Subject: Re: [PATCH] libbpf: Fixes incorrect rx_ring_setup_done



On 6/7/21 6:08 AM, Kev Jackson wrote:
> When calling xsk_socket__create_shared(), the logic at line 1097 marks a
> boolean flag true within the xsk_umem structure to track setup progress
> in order to support multiple calls to the function. However, instead of
> marking umem->tx_ring_setup_done, the code incorrectly sets
> umem->rx_ring_setup_done. This leads to improper behaviour when
> creating and destroying xsk and umem structures.
>
> Multiple calls to this function is documented as supported.
>
> Signed-off-by: Kev Jackson <[email protected]>

Acked-by: Yonghong Song <[email protected]>

2021-06-08 00:49:30

by Andrii Nakryiko

[permalink] [raw]
Subject: Re: [PATCH] libbpf: Fixes incorrect rx_ring_setup_done

On Mon, Jun 7, 2021 at 8:04 AM Yonghong Song <[email protected]> wrote:
>
>
>
> On 6/7/21 6:08 AM, Kev Jackson wrote:
> > When calling xsk_socket__create_shared(), the logic at line 1097 marks a
> > boolean flag true within the xsk_umem structure to track setup progress
> > in order to support multiple calls to the function. However, instead of
> > marking umem->tx_ring_setup_done, the code incorrectly sets
> > umem->rx_ring_setup_done. This leads to improper behaviour when
> > creating and destroying xsk and umem structures.
> >
> > Multiple calls to this function is documented as supported.
> >
> > Signed-off-by: Kev Jackson <[email protected]>
>
> Acked-by: Yonghong Song <[email protected]>

Applied to bpf tree, thanks. Also added

Fixes: ca7a83e2487a ("libbpf: Only create rx and tx XDP rings when necessary")

Please don't forget Fixes: tag in the future.

2021-06-08 00:52:18

by patchwork-bot+netdevbpf

[permalink] [raw]
Subject: Re: [PATCH] libbpf: Fixes incorrect rx_ring_setup_done

Hello:

This patch was applied to bpf/bpf.git (refs/heads/master):

On Mon, 7 Jun 2021 14:08:35 +0100 you wrote:
> When calling xsk_socket__create_shared(), the logic at line 1097 marks a
> boolean flag true within the xsk_umem structure to track setup progress
> in order to support multiple calls to the function. However, instead of
> marking umem->tx_ring_setup_done, the code incorrectly sets
> umem->rx_ring_setup_done. This leads to improper behaviour when
> creating and destroying xsk and umem structures.
>
> [...]

Here is the summary with links:
- libbpf: Fixes incorrect rx_ring_setup_done
https://git.kernel.org/bpf/bpf/c/11fc79fc9f2e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html