public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH net] eth: fbnic: Add validation for MTU changes
@ 2026-02-14 17:19 Dimitri Daskalakis
  2026-02-16 12:18 ` Simon Horman
  2026-02-18  6:33 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Dimitri Daskalakis @ 2026-02-14 17:19 UTC (permalink / raw)
  To: David S . Miller
  Cc: Alexander Duyck, Jakub Kicinski, Eric Dumazet, Paolo Abeni,
	Andrew Lunn, Simon Horman, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Mohsin Bashir, netdev, bpf, linux-kselftest

Increasing the MTU beyond the HDS threshold causes the hardware to
fragment packets across multiple buffers. If a single-buffer XDP program
is attached, the driver will drop all multi-frag frames. While we can't
prevent a remote sender from sending non-TCP packets larger than the MTU,
this will prevent users from inadvertently breaking new TCP streams.

Traditionally, drivers supported XDP with MTU less than 4Kb
(packet per page). Fbnic currently prevents attaching XDP when MTU is too high.
But it does not prevent increasing MTU after XDP is attached.

Fixes: 1b0a3950dbd4 ("eth: fbnic: Add XDP pass, drop, abort support")
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>
---
 drivers/net/ethernet/meta/fbnic/fbnic_netdev.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
index 81c9d5c9a4b2..e3ca5fcfabef 100644
--- a/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
+++ b/drivers/net/ethernet/meta/fbnic/fbnic_netdev.c
@@ -262,6 +262,23 @@ static int fbnic_set_mac(struct net_device *netdev, void *p)
 	return 0;
 }
 
+static int fbnic_change_mtu(struct net_device *dev, int new_mtu)
+{
+	struct fbnic_net *fbn = netdev_priv(dev);
+
+	if (fbnic_check_split_frames(fbn->xdp_prog, new_mtu, fbn->hds_thresh)) {
+		dev_err(&dev->dev,
+			"MTU %d is larger than HDS threshold %d in XDP mode\n",
+			new_mtu, fbn->hds_thresh);
+
+		return -EINVAL;
+	}
+
+	WRITE_ONCE(dev->mtu, new_mtu);
+
+	return 0;
+}
+
 void fbnic_clear_rx_mode(struct fbnic_dev *fbd)
 {
 	struct net_device *netdev = fbd->netdev;
@@ -533,6 +550,7 @@ static const struct net_device_ops fbnic_netdev_ops = {
 	.ndo_start_xmit		= fbnic_xmit_frame,
 	.ndo_features_check	= fbnic_features_check,
 	.ndo_set_mac_address	= fbnic_set_mac,
+	.ndo_change_mtu		= fbnic_change_mtu,
 	.ndo_set_rx_mode	= fbnic_set_rx_mode,
 	.ndo_get_stats64	= fbnic_get_stats64,
 	.ndo_bpf		= fbnic_bpf,
-- 
2.47.3


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

* Re: [PATCH net] eth: fbnic: Add validation for MTU changes
  2026-02-14 17:19 [PATCH net] eth: fbnic: Add validation for MTU changes Dimitri Daskalakis
@ 2026-02-16 12:18 ` Simon Horman
  2026-02-18  6:33 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Simon Horman @ 2026-02-16 12:18 UTC (permalink / raw)
  To: Dimitri Daskalakis
  Cc: David S . Miller, Alexander Duyck, Jakub Kicinski, Eric Dumazet,
	Paolo Abeni, Andrew Lunn, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, Stanislav Fomichev,
	Mohsin Bashir, netdev, bpf, linux-kselftest

On Sat, Feb 14, 2026 at 09:19:49AM -0800, Dimitri Daskalakis wrote:
> Increasing the MTU beyond the HDS threshold causes the hardware to
> fragment packets across multiple buffers. If a single-buffer XDP program
> is attached, the driver will drop all multi-frag frames. While we can't
> prevent a remote sender from sending non-TCP packets larger than the MTU,
> this will prevent users from inadvertently breaking new TCP streams.
> 
> Traditionally, drivers supported XDP with MTU less than 4Kb
> (packet per page). Fbnic currently prevents attaching XDP when MTU is too high.
> But it does not prevent increasing MTU after XDP is attached.
> 
> Fixes: 1b0a3950dbd4 ("eth: fbnic: Add XDP pass, drop, abort support")
> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
> Signed-off-by: Dimitri Daskalakis <dimitri.daskalakis1@gmail.com>

Reviewed-by: Simon Horman <horms@kernel.org>


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

* Re: [PATCH net] eth: fbnic: Add validation for MTU changes
  2026-02-14 17:19 [PATCH net] eth: fbnic: Add validation for MTU changes Dimitri Daskalakis
  2026-02-16 12:18 ` Simon Horman
@ 2026-02-18  6:33 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-18  6:33 UTC (permalink / raw)
  To: Dimitri Daskalakis
  Cc: davem, alexanderduyck, kuba, edumazet, pabeni, andrew+netdev,
	horms, ast, daniel, hawk, john.fastabend, sdf, mohsin.bashr,
	netdev, bpf, linux-kselftest

Hello:

This patch was applied to netdev/net.git (main)
by David S. Miller <davem@davemloft.net>:

On Sat, 14 Feb 2026 09:19:49 -0800 you wrote:
> Increasing the MTU beyond the HDS threshold causes the hardware to
> fragment packets across multiple buffers. If a single-buffer XDP program
> is attached, the driver will drop all multi-frag frames. While we can't
> prevent a remote sender from sending non-TCP packets larger than the MTU,
> this will prevent users from inadvertently breaking new TCP streams.
> 
> Traditionally, drivers supported XDP with MTU less than 4Kb
> (packet per page). Fbnic currently prevents attaching XDP when MTU is too high.
> But it does not prevent increasing MTU after XDP is attached.
> 
> [...]

Here is the summary with links:
  - [net] eth: fbnic: Add validation for MTU changes
    https://git.kernel.org/netdev/net/c/ccd8e87748ad

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-02-18  6:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-14 17:19 [PATCH net] eth: fbnic: Add validation for MTU changes Dimitri Daskalakis
2026-02-16 12:18 ` Simon Horman
2026-02-18  6:33 ` 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