mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] veth: fix stale peer max_mtu on XDP program replacement
@ 2026-10-20  2:01 yanxia
  2026-10-20 13:14 ` Xia Yan
  2026-10-23 23:10 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: yanxia @ 2026-10-20  2:01 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, ast, daniel, hawk,
	john.fastabend, sdf, linux-kernel, bpf, lorenzo, stable

veth_xdp_set() calculates the peer MTU limit from the incoming program's
XDP fragment capability, but only stores it when no program was attached.
Replacing a program with one having a different fragment capability
therefore leaves the peer's max_mtu stale.

Replacing a regular program with an xdp.frags program keeps rejecting
otherwise valid jumbo MTUs. The opposite replacement leaves a larger
limit in place and permits MTUs which a fresh attachment of the regular
program would reject.

Update peer->max_mtu after every successful attachment or replacement.
Keep the GSO feature update conditional on the first attachment.

Found during review of the XDP replacement path and confirmed with
native XDP on an isolated veth pair. Before the fix, direct replacement
rejects MTU 9000 after switching to xdp.frags, and accepts it after
switching back to a regular program. Detaching and attaching instead
produces the expected results in both directions.

UML tests on net reproduce the problem before this change and match the
detach/attach controls afterwards, with both devices up or down and
with either endpoint receiving XDP. Failed replacements preserve the
previous state; same-type replacements and detach also behave as
expected. Small-frame traffic passes in the devices-up cases.

Fixes: 7cda76d858a4 ("veth: Allow jumbo frames in xdp mode")
Cc: stable@vger.kernel.org
Signed-off-by: yanxia <yanxia@cmss.chinamobile.com>
---
 drivers/net/veth.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/net/veth.c b/drivers/net/veth.c
index 643b97dc..7db389ae 100644
--- a/drivers/net/veth.c
+++ b/drivers/net/veth.c
@@ -1622,10 +1622,9 @@ static int veth_xdp_set(struct net_device *dev, struct bpf_prog *prog,
 			}
 		}
 
-		if (!old_prog) {
+		if (!old_prog)
 			peer->hw_features &= ~NETIF_F_GSO_SOFTWARE;
-			peer->max_mtu = max_mtu;
-		}
+		peer->max_mtu = max_mtu;
 
 		xdp_features_set_redirect_target(peer, true);
 	}

base-commit: 78731b46967e3e7102b5cd5062bef185f3404b5c
-- 
2.43.0




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] veth: fix stale peer max_mtu on XDP program replacement
  2026-10-20  2:01 [PATCH net] veth: fix stale peer max_mtu on XDP program replacement yanxia
@ 2026-10-20 13:14 ` Xia Yan
  2026-10-23 23:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Xia Yan @ 2026-10-20 13:14 UTC (permalink / raw)
  To: netdev
  Cc: andrew+netdev, davem, edumazet, kuba, pabeni, ast, daniel, hawk,
	john.fastabend, sdf, linux-kernel, bpf, lorenzo, stable, toke,
	yana06070

Hi Toke,

Adding you to Cc; I missed you on the original submission.

The patch refreshes peer max_mtu when replacing an XDP program with
one that has different fragment support:

https://lore.kernel.org/netdev/20261020020147.790274-1-yanxia@cmss.chinamobile.com/

Best regards,
Xia Yan



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] veth: fix stale peer max_mtu on XDP program replacement
  2026-10-20  2:01 [PATCH net] veth: fix stale peer max_mtu on XDP program replacement yanxia
  2026-10-20 13:14 ` Xia Yan
@ 2026-10-23 23:10 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-23 23:10 UTC (permalink / raw)
  To: Xia Yan
  Cc: netdev, andrew+netdev, davem, edumazet, kuba, pabeni, ast,
	daniel, hawk, john.fastabend, sdf, linux-kernel, bpf, lorenzo,
	stable

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 20 Oct 2026 10:01:47 +0800 you wrote:
> veth_xdp_set() calculates the peer MTU limit from the incoming program's
> XDP fragment capability, but only stores it when no program was attached.
> Replacing a program with one having a different fragment capability
> therefore leaves the peer's max_mtu stale.
> 
> Replacing a regular program with an xdp.frags program keeps rejecting
> otherwise valid jumbo MTUs. The opposite replacement leaves a larger
> limit in place and permits MTUs which a fresh attachment of the regular
> program would reject.
> 
> [...]

Here is the summary with links:
  - [net] veth: fix stale peer max_mtu on XDP program replacement
    https://git.kernel.org/netdev/net/c/c955325db639

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:[~2026-10-23 23:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-20  2:01 [PATCH net] veth: fix stale peer max_mtu on XDP program replacement yanxia
2026-10-20 13:14 ` Xia Yan
2026-10-23 23:10 ` 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

all inboxes | Powered by JetHome®