Skip to content

Commit

Permalink
samples/bpf: fix xdpsock l2fwd tx for unaligned mode
Browse files Browse the repository at this point in the history
Preserve the offset of the address of the received descriptor, and include
it in the address set for the tx descriptor, so the kernel can correctly
locate the start of the packet data.

Fixes: 03895e6 ("samples/bpf: add buffer recycling for unaligned chunks to xdpsock")
Signed-off-by: Ciara Loftus <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
  • Loading branch information
cloftus authored and borkmann committed Sep 16, 2019
1 parent 2e78fc6 commit 5a712e1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion samples/bpf/xdpsock_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,7 @@ static void l2fwd(struct xsk_socket_info *xsk, struct pollfd *fds)
for (i = 0; i < rcvd; i++) {
u64 addr = xsk_ring_cons__rx_desc(&xsk->rx, idx_rx)->addr;
u32 len = xsk_ring_cons__rx_desc(&xsk->rx, idx_rx++)->len;
u64 orig = xsk_umem__extract_addr(addr);
u64 orig = addr;

addr = xsk_umem__add_offset_to_addr(addr);
char *pkt = xsk_umem__get_data(xsk->umem->buffer, addr);
Expand Down

0 comments on commit 5a712e1

Please sign in to comment.