* [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern
@ 2022-10-15 21:30 Gerhard Engleder
2022-10-17 1:43 ` Andy Gospodarek
2022-10-19 18:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Gerhard Engleder @ 2022-10-15 21:30 UTC (permalink / raw)
To: andrew.gospodarek, ast, daniel, davem, kuba, hawk, john.fastabend
Cc: bpf, netdev, Gerhard Engleder
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>
---
samples/bpf/xdp2_kern.c | 4 ++++
1 file changed, 4 insertions(+)
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;
}
--
2.30.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern
2022-10-15 21:30 [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern Gerhard Engleder
@ 2022-10-17 1:43 ` Andy Gospodarek
2022-10-19 18:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Andy Gospodarek @ 2022-10-17 1:43 UTC (permalink / raw)
To: Gerhard Engleder
Cc: andrew.gospodarek, ast, daniel, davem, kuba, hawk, john.fastabend,
bpf, netdev
On Sat, Oct 15, 2022 at 11:30:50PM +0200, Gerhard Engleder wrote:
> 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.
>
Nice catch! Thanks for posting this.
> 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>
> ---
> samples/bpf/xdp2_kern.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> 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;
> }
>
> --
> 2.30.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern
2022-10-15 21:30 [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern Gerhard Engleder
2022-10-17 1:43 ` Andy Gospodarek
@ 2022-10-19 18:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-10-19 18:20 UTC (permalink / raw)
To: Gerhard Engleder
Cc: andrew.gospodarek, ast, daniel, davem, kuba, hawk, john.fastabend,
bpf, netdev
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Martin KaFai Lau <martin.lau@kernel.org>:
On Sat, 15 Oct 2022 23:30:50 +0200 you wrote:
> 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.
>
> [...]
Here is the summary with links:
- [net-next] samples/bpf: Fix MAC address swapping in xdp2_kern
https://git.kernel.org/bpf/bpf-next/c/7a698edf954c
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-10-19 18:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-15 21:30 [PATCH net-next] samples/bpf: Fix MAC address swapping in xdp2_kern Gerhard Engleder
2022-10-17 1:43 ` Andy Gospodarek
2022-10-19 18:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).