Skip to contentSkip to conversation

xsk: fix __xsk_generic_xmit() error code when cq is full

PATCH Applied Wang Liang 3 participants 3 messages Feb 27, 2025 – Mar 3, 2025

Subsystems (4)
lore
Share & tools
lore

Wang Liang

author
#0 lore raw

PATCH v2 1/1 xsk: fix __xsk_generic_xmit() error code when cq is full

When the cq reservation is failed, the error code is not set which is initialized to zero in __xsk_generic_xmit(). That means the packet is not send successfully but sendto() return ok.

Considering the impact on uapi, return -EAGAIN is a good idea. The cq is full usually because it is not released in time, try to send msg again is appropriate.

---
 net/xdp/xsk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/xdp/xsk.c +4 -1
index 89d2bef96469..e04809a4c5d3 100644
@@ -802,8 +802,11 @@ static int __xsk_generic_xmit(struct sock *sk)
 		 * if there is space in it. This avoids having to implement
 		 * any buffering in the Tx path.
 		 */
-		if (xsk_cq_reserve_addr_locked(xs->pool, desc.addr))
+		err = xsk_cq_reserve_addr_locked(xs->pool, desc.addr);
+		if (err) {
+			err = -EAGAIN;
 			goto out;
+		}
 
 		skb = xsk_build_skb(xs, &desc);
 		if (IS_ERR(skb)) {
Signature · 1 line
2.34.1
Acked-by on v2 1/1
#1 lore raw
Quoted 10 lines · Wang Liang

When the cq reservation is failed, the error code is not set which is initialized to zero in __xsk_generic_xmit(). That means the packet is not send successfully but sendto() return ok.

Considering the impact on uapi, return -EAGAIN is a good idea. The cq is full usually because it is not released in time, try to send msg again is appropriate.

#2 lore raw
In reply to Wang Liang
This patch was applied to bpf/bpf.git (master) by Martin KaFai Lau <[email protected]>:

Hello:

This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <[email protected]>:

Quoted 9 lines · On Thu, 27 Feb 2025 16:10:52 +0800 you wrote:

When the cq reservation is failed, the error code is not set which is initialized to zero in __xsk_generic_xmit(). That means the packet is not send successfully but sendto() return ok.

Considering the impact on uapi, return -EAGAIN is a good idea. The cq is full usually because it is not released in time, try to send msg again is appropriate.

[...]

Here is the summary with links:
- [net,v2] xsk: fix __xsk_generic_xmit() error code when cq is full

    https://git.kernel.org/bpf/bpf/c/6ccf6adb05d0

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html