Skip to content

Commit 4678adf

Browse files
borkmannPaolo Abeni
authored andcommitted
vmxnet3: Fix packet corruption in vmxnet3_xdp_xmit_frame
Andrew and Nikolay reported connectivity issues with Cilium's service load-balancing in case of vmxnet3. If a BPF program for native XDP adds an encapsulation header such as IPIP and transmits the packet out the same interface, then in case of vmxnet3 a corrupted packet is being sent and subsequently dropped on the path. vmxnet3_xdp_xmit_frame() which is called e.g. via vmxnet3_run_xdp() through vmxnet3_xdp_xmit_back() calculates an incorrect DMA address: page = virt_to_page(xdpf->data); tbi->dma_addr = page_pool_get_dma_addr(page) + VMXNET3_XDP_HEADROOM; dma_sync_single_for_device(&adapter->pdev->dev, tbi->dma_addr, buf_size, DMA_TO_DEVICE); The above assumes a fixed offset (VMXNET3_XDP_HEADROOM), but the XDP BPF program could have moved xdp->data. While the passed buf_size is correct (xdpf->len), the dma_addr needs to have a dynamic offset which can be calculated as xdpf->data - (void *)xdpf, that is, xdp->data - xdp->data_hard_start. Fixes: 54f00cc ("vmxnet3: Add XDP support.") Reported-by: Andrew Sauber <[email protected]> Reported-by: Nikolay Nikolaev <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Tested-by: Nikolay Nikolaev <[email protected]> Acked-by: Anton Protopopov <[email protected]> Cc: William Tu <[email protected]> Cc: Ronak Doshi <[email protected]> Link: https://patch.msgid.link/a0888656d7f09028f9984498cc698bb5364d89fc.1728931137.git.daniel@iogearbox.net Signed-off-by: Paolo Abeni <[email protected]>
1 parent 11d06f0 commit 4678adf

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/vmxnet3/vmxnet3_xdp.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ vmxnet3_xdp_xmit_frame(struct vmxnet3_adapter *adapter,
148148
} else { /* XDP buffer from page pool */
149149
page = virt_to_page(xdpf->data);
150150
tbi->dma_addr = page_pool_get_dma_addr(page) +
151-
VMXNET3_XDP_HEADROOM;
151+
(xdpf->data - (void *)xdpf);
152152
dma_sync_single_for_device(&adapter->pdev->dev,
153153
tbi->dma_addr, buf_size,
154154
DMA_TO_DEVICE);

0 commit comments

Comments
 (0)