Skip to content

Commit b69e56c

Browse files
weqaarborkmann
authored andcommitted
samples/bpf: Fix to xdpsock to avoid recycling frames
The txpush program in the xdpsock sample application is supposed to send out all packets in the umem in a round-robin fashion. The problem is that it only cycled through the first BATCH_SIZE worth of packets. Fixed this so that it cycles through all buffers in the umem as intended. Fixes: 248c7f9 ("samples/bpf: convert xdpsock to use libbpf for AF_XDP access") Signed-off-by: Weqaar Janjua <weqaar.a.janjua@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Acked-by: Björn Töpel <bjorn.topel@intel.com> Link: https://lore.kernel.org/bpf/20200828161717.42705-1-weqaar.a.janjua@intel.com
1 parent c8a039a commit b69e56c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

‎samples/bpf/xdpsock_user.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,7 +1010,7 @@ static void rx_drop_all(void)
10101010
}
10111011
}
10121012

1013-
static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
1013+
static void tx_only(struct xsk_socket_info *xsk, u32 *frame_nb, int batch_size)
10141014
{
10151015
u32 idx;
10161016
unsigned int i;
@@ -1023,14 +1023,14 @@ static void tx_only(struct xsk_socket_info *xsk, u32 frame_nb, int batch_size)
10231023
for (i = 0; i < batch_size; i++) {
10241024
struct xdp_desc *tx_desc = xsk_ring_prod__tx_desc(&xsk->tx,
10251025
idx + i);
1026-
tx_desc->addr = (frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
1026+
tx_desc->addr = (*frame_nb + i) << XSK_UMEM__DEFAULT_FRAME_SHIFT;
10271027
tx_desc->len = PKT_SIZE;
10281028
}
10291029

10301030
xsk_ring_prod__submit(&xsk->tx, batch_size);
10311031
xsk->outstanding_tx += batch_size;
1032-
frame_nb += batch_size;
1033-
frame_nb %= NUM_FRAMES;
1032+
*frame_nb += batch_size;
1033+
*frame_nb %= NUM_FRAMES;
10341034
complete_tx_only(xsk, batch_size);
10351035
}
10361036

@@ -1086,7 +1086,7 @@ static void tx_only_all(void)
10861086
}
10871087

10881088
for (i = 0; i < num_socks; i++)
1089-
tx_only(xsks[i], frame_nb[i], batch_size);
1089+
tx_only(xsks[i], &frame_nb[i], batch_size);
10901090

10911091
pkt_cnt += batch_size;
10921092

0 commit comments

Comments
 (0)