summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorGerhard Engleder <gerhard@engleder-embedded.com>2022-10-16 00:30:50 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2022-12-31 15:32:03 +0300
commit05d55bbd8d27ab79925df24d918fa14d08c81dde (patch)
tree421deb68155d38ef86f1992a8b900c6fe6993dc3 /samples
parent818b68651cde02a94444d1ac56cf4afb12e6d9db (diff)
downloadlinux-05d55bbd8d27ab79925df24d918fa14d08c81dde.tar.xz
samples/bpf: Fix MAC address swapping in xdp2_kern
[ Upstream commit 7a698edf954cb3f8b6e8dacdb77615355170420c ] xdp2_kern rewrites and forwards packets out on the same interface. Forwarding still works but rewrite got broken when xdp multibuffer support has been added. With xdp multibuffer a local copy of the packet has been introduced. The MAC address is now swapped in the local copy, but the local copy in not written back. Fix MAC address swapping be adding write back of modified packet. Fixes: 772251742262 ("samples/bpf: fixup some tools to be able to support xdp multibuffer") Signed-off-by: Gerhard Engleder <gerhard@engleder-embedded.com> Reviewed-by: Andy Gospodarek <gospo@broadcom.com> Link: https://lore.kernel.org/r/20221015213050.65222-1-gerhard@engleder-embedded.com Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'samples')
-rw-r--r--samples/bpf/xdp2_kern.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/samples/bpf/xdp2_kern.c b/samples/bpf/xdp2_kern.c
index 3332ba6bb95f..67804ecf7ce3 100644
--- a/samples/bpf/xdp2_kern.c
+++ b/samples/bpf/xdp2_kern.c
@@ -112,6 +112,10 @@ int xdp_prog1(struct xdp_md *ctx)
if (ipproto == IPPROTO_UDP) {
swap_src_dst_mac(data);
+
+ if (bpf_xdp_store_bytes(ctx, 0, pkt, sizeof(pkt)))
+ return rc;
+
rc = XDP_TX;
}