From ce714625ce60195bce6865346df1acaca0d250bd Mon Sep 17 00:00:00 2001 From: Jesper Dangaard Brouer Date: Mon, 21 Feb 2022 19:03:49 +0100 Subject: [PATCH] AF_XDP-interaction: Fix function tx_pkt If there were more transmit slots, then we umem free the packet, but we continued sending it anyhow. The places tx_pkt() is currently used this never happened. Still fix the bug. Signed-off-by: Jesper Dangaard Brouer --- AF_XDP-interaction/af_xdp_user.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AF_XDP-interaction/af_xdp_user.c b/AF_XDP-interaction/af_xdp_user.c index a19db2c..b69b608 100644 --- a/AF_XDP-interaction/af_xdp_user.c +++ b/AF_XDP-interaction/af_xdp_user.c @@ -884,8 +884,9 @@ static int tx_pkt(struct config *cfg, struct xsk_socket_info *xsk) if (ret != 1) { /* No more transmit slots, drop the packet */ mem_free_umem_frame(&umem->mem, pkt_addr); - fprintf(stderr, "ERR - %s() failed transmit\n", + fprintf(stderr, "ERR: %s() failed transmit, no slots\n", __func__); + return ENOSPC; } xsk_ring_prod__tx_desc(&xsk->tx, tx_idx)->addr = pkt_addr;