Skip to content

Commit 1d3860a

Browse files
Wang LiangNipaLocal
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. Set the error code and make xskq_prod_reserve_addr()/xskq_prod_reserve() return values more meaningful when the queue is full. Signed-off-by: Wang Liang <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent f712793 commit 1d3860a

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

net/xdp/xsk.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -805,7 +805,8 @@ static int __xsk_generic_xmit(struct sock *sk)
805805
* if there is space in it. This avoids having to implement
806806
* any buffering in the Tx path.
807807
*/
808-
if (xsk_cq_reserve_addr_locked(xs->pool, desc.addr))
808+
err = xsk_cq_reserve_addr_locked(xs->pool, desc.addr);
809+
if (err)
809810
goto out;
810811

811812
skb = xsk_build_skb(xs, &desc);

net/xdp/xsk_queue.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ static inline void xskq_prod_cancel_n(struct xsk_queue *q, u32 cnt)
371371
static inline int xskq_prod_reserve(struct xsk_queue *q)
372372
{
373373
if (xskq_prod_is_full(q))
374-
return -ENOSPC;
374+
return -ENOBUFS;
375375

376376
/* A, matches D */
377377
q->cached_prod++;
@@ -383,7 +383,7 @@ static inline int xskq_prod_reserve_addr(struct xsk_queue *q, u64 addr)
383383
struct xdp_umem_ring *ring = (struct xdp_umem_ring *)q->ring;
384384

385385
if (xskq_prod_is_full(q))
386-
return -ENOSPC;
386+
return -ENOBUFS;
387387

388388
/* A, matches D */
389389
ring->desc[q->cached_prod++ & q->ring_mask] = addr;

0 commit comments

Comments
 (0)