git: d03e991d067d - stable/15 - vtnet: honor the advertised MTU limit on attach
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 13 Nov 2026 18:33:44 UTC
The branch stable/15 has been updated by novel:
URL: https://cgit.FreeBSD.org/src/commit/?id=d03e991d067da14a4fb290ccc10a2a46324d9a8b
commit d03e991d067da14a4fb290ccc10a2a46324d9a8b
Author: Roman Bogorodskiy <novel@FreeBSD.org>
AuthorDate: 2026-10-29 18:24:15 +0000
Commit: Roman Bogorodskiy <novel@FreeBSD.org>
CommitDate: 2026-11-13 17:54:34 +0000
vtnet: honor the advertised MTU limit on attach
When VIRTIO_NET_F_MTU is negotiated, virtio_net_config.mtu specifies
the maximum MTU the driver may use. vtnet_ioctl_mtu() enforces this
limit for subsequent MTU changes, but ether_ifattach() unconditionally
initializes the interface MTU to ETHERMTU (1500).
So a device advertising a maximum below 1500 starts with an MTU above
its limit. So make sure to set the initial MTU no larger than
vtnet_max_mtu. That is, for vtnet_max_mtu less than 1500
interface MTU will be set to this value, otherwise the current behaviour
is preserved, MTU will be set to 1500.
Reviewed by: kfv, tuexen
Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks
Differential Revision: https://reviews.freebsd.org/D60980
(cherry picked from commit 0974ef03b43f279f16289ad4d5be3a03923983ea)
---
sys/dev/virtio/network/if_vtnet.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sys/dev/virtio/network/if_vtnet.c b/sys/dev/virtio/network/if_vtnet.c
index 05cc51f16228..180f128717a7 100644
--- a/sys/dev/virtio/network/if_vtnet.c
+++ b/sys/dev/virtio/network/if_vtnet.c
@@ -1338,6 +1338,8 @@ vtnet_setup_interface(struct vtnet_softc *sc)
}
ether_ifattach(ifp, sc->vtnet_hwaddr);
+ if (if_getmtu(ifp) > sc->vtnet_max_mtu)
+ if_setmtu(ifp, sc->vtnet_max_mtu);
/* Tell the upper layer(s) we support long frames. */
if_setifheaderlen(ifp, sizeof(struct ether_vlan_header));