Skip to content

Commit 5d0b204

Browse files
Wang LiangAlexei Starovoitov
authored andcommitted
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. 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: e6c4047 ("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>
1 parent a1b5bd4 commit 5d0b204

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

net/xdp/xsk.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,8 +806,11 @@ static int __xsk_generic_xmit(struct sock *sk)
806806
* if there is space in it. This avoids having to implement
807807
* any buffering in the Tx path.
808808
*/
809-
if (xsk_cq_reserve_addr_locked(xs->pool, desc.addr))
809+
err = xsk_cq_reserve_addr_locked(xs->pool, desc.addr);
810+
if (err) {
811+
err = -EAGAIN;
810812
goto out;
813+
}
811814

812815
skb = xsk_build_skb(xs, &desc);
813816
if (IS_ERR(skb)) {

0 commit comments

Comments
 (0)