Skip to contentSkip to conversation

libbpf: Fixes incorrect rx_ring_setup_done

PATCH Applied Kev Jackson 4 participants 4 messages Jun 7, 2021 – Jun 8, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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.

---
 tools/lib/bpf/xsk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/lib/bpf/xsk.c +1 -1
index 6061431ee04c..e9b619aa0cdf 100644
@@ -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);
Signature · 1 line
2.30.2
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Kev Jackson

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.

#2 lore raw
Quoted 11 lines · Yonghong Song
Quoted 7 lines · Kev Jackson

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.

Quoted 5 lines
Quoted 3 lines

Multiple calls to this function is documented as supported.

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.

#3 lore raw
In reply to Kev Jackson
This patch was applied to bpf/bpf.git (refs/heads/master):

Hello:

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

Quoted 8 lines · 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