summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorWang Liang <wangliang74@huawei.com>2025-02-27 16:10:52 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-04-10 14:44:41 +0200
commit7ada892ef9938666d5d2f5d39284bde7e3bfe394 (patch)
treead068137863f4c69e6b619bf8eafa553df6637fa /net
parent2afae03ca2dd353814b85c7fadce2192a0841c47 (diff)
downloadlinux-7ada892ef9938666d5d2f5d39284bde7e3bfe394.tar.gz
linux-7ada892ef9938666d5d2f5d39284bde7e3bfe394.tar.bz2
linux-7ada892ef9938666d5d2f5d39284bde7e3bfe394.zip
xsk: Fix __xsk_generic_xmit() error code when cq is full
[ Upstream commit 5d0b204654de25615cf712be86c3192eca68ed80 ] 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. The bug was at the very early implementation of xsk, so the Fixes tag targets the commit that introduced the changes in xsk_cq_reserve_addr_locked where this fix depends on. Fixes: e6c4047f5122 ("xsk: Use xsk_buff_pool directly for cq functions") Suggested-by: Magnus Karlsson <magnus.karlsson@gmail.com> Signed-off-by: Wang Liang <wangliang74@huawei.com> Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250227081052.4096337-1-wangliang74@huawei.com Signed-off-by: Alexei Starovoitov <ast@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/xdp/xsk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 41093ea63700..a373a7130d75 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -805,8 +805,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)) {