netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] virtio_net: set default mtu to 1500 when 'Device maximum MTU' bigger than 1500
@ 2023-05-06  2:15 Hao Chen
  2023-05-06  2:50 ` Xuan Zhuo
  2023-05-07  5:59 ` Michael S. Tsirkin
  0 siblings, 2 replies; 16+ messages in thread
From: Hao Chen @ 2023-05-06  2:15 UTC (permalink / raw)
  To: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	open list:VIRTIO CORE AND NET DRIVERS,
	open list:NETWORKING DRIVERS, open list
  Cc: huangml, zy

When VIRTIO_NET_F_MTU(3) Device maximum MTU reporting is supported.
If offered by the device, device advises driver about the value of its
maximum MTU. If negotiated, the driver uses mtu as the maximum
MTU value. But there the driver also uses it as default mtu,
some devices may have a maximum MTU greater than 1500, this may
cause some large packages to be discarded, so I changed the MTU to a more
general 1500 when 'Device maximum MTU' bigger than 1500.

Signed-off-by: Hao Chen <chenh@yusur.tech>
---
 drivers/net/virtio_net.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 8d8038538fc4..e71c7d1b5f29 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -4040,7 +4040,10 @@ static int virtnet_probe(struct virtio_device *vdev)
 			goto free;
 		}
 
-		dev->mtu = mtu;
+		if (mtu > 1500)
+			dev->mtu = 1500;
+		else
+			dev->mtu = mtu;
 		dev->max_mtu = mtu;
 	}
 
-- 
2.27.0


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

end of thread, other threads:[~2023-05-09  1:54 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-06  2:15 [PATCH] virtio_net: set default mtu to 1500 when 'Device maximum MTU' bigger than 1500 Hao Chen
2023-05-06  2:50 ` Xuan Zhuo
2023-05-06  8:56   ` Hao Chen
2023-05-07  8:58     ` Michael S. Tsirkin
2023-05-08  2:01       ` Xuan Zhuo
2023-05-08  6:15         ` Michael S. Tsirkin
2023-05-08  6:18           ` Xuan Zhuo
2023-05-08  6:43             ` Michael S. Tsirkin
2023-05-08  7:41               ` Xuan Zhuo
2023-05-08 10:30                 ` Michael S. Tsirkin
2023-05-08 16:25                   ` Stephen Hemminger
2023-05-08 18:10                     ` Michael S. Tsirkin
2023-05-09  1:51                       ` Xuan Zhuo
2023-05-07  9:31     ` David Woodhouse
2023-05-07 13:38       ` Michael S. Tsirkin
2023-05-07  5:59 ` Michael S. Tsirkin

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).