netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full
@ 2025-02-27  8:10 Wang Liang
  2025-03-02  0:05 ` Stanislav Fomichev
  2025-03-03 22:40 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Wang Liang @ 2025-02-27  8:10 UTC (permalink / raw)
  To: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, davem,
	edumazet, kuba, pabeni, horms, ast, daniel, hawk, john.fastabend
  Cc: yuehaibing, zhangchangzhong, wangliang74, netdev, bpf,
	linux-kernel

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.

Suggested-by: Magnus Karlsson <magnus.karlsson@gmail.com>
Signed-off-by: Wang Liang <wangliang74@huawei.com>
---
 net/xdp/xsk.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 89d2bef96469..e04809a4c5d3 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -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)) {
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full
  2025-02-27  8:10 [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full Wang Liang
@ 2025-03-02  0:05 ` Stanislav Fomichev
  2025-03-03 22:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Stanislav Fomichev @ 2025-03-02  0:05 UTC (permalink / raw)
  To: Wang Liang
  Cc: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, davem,
	edumazet, kuba, pabeni, horms, ast, daniel, hawk, john.fastabend,
	yuehaibing, zhangchangzhong, netdev, bpf, linux-kernel

On 02/27, Wang Liang 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.
> 
> Suggested-by: Magnus Karlsson <magnus.karlsson@gmail.com>
> Signed-off-by: Wang Liang <wangliang74@huawei.com>

Acked-by: Stanislav Fomichev <sdf@fomichev.me>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full
  2025-02-27  8:10 [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full Wang Liang
  2025-03-02  0:05 ` Stanislav Fomichev
@ 2025-03-03 22:40 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-03-03 22:40 UTC (permalink / raw)
  To: Wang Liang
  Cc: bjorn, magnus.karlsson, maciej.fijalkowski, jonathan.lemon, davem,
	edumazet, kuba, pabeni, horms, ast, daniel, hawk, john.fastabend,
	yuehaibing, zhangchangzhong, netdev, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-03-03 22:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-27  8:10 [PATCH net v2] xsk: fix __xsk_generic_xmit() error code when cq is full Wang Liang
2025-03-02  0:05 ` Stanislav Fomichev
2025-03-03 22:40 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).