linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] virtio-net: enable big mode correctly
@ 2021-11-25  6:05 Jason Wang
  2021-11-25  7:00 ` Michael S. Tsirkin
  2021-11-25  7:09 ` Eli Cohen
  0 siblings, 2 replies; 14+ messages in thread
From: Jason Wang @ 2021-11-25  6:05 UTC (permalink / raw)
  To: mst, jasowang; +Cc: virtualization, netdev, linux-kernel, Eli Cohen

When VIRTIO_NET_F_MTU feature is not negotiated, we assume a very
large max_mtu. In this case, using small packet mode is not correct
since it may breaks the networking when MTU is grater than
ETH_DATA_LEN.

To have a quick fix, simply enable the big packet mode when
VIRTIO_NET_F_MTU is not negotiated. We can do optimization on top.

Reported-by: Eli Cohen <elic@nvidia.com>
Cc: Eli Cohen <elic@nvidia.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
---
 drivers/net/virtio_net.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 7c43bfc1ce44..83ae3ef5eb11 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -3200,11 +3200,12 @@ static int virtnet_probe(struct virtio_device *vdev)
 		dev->mtu = mtu;
 		dev->max_mtu = mtu;
 
-		/* TODO: size buffers correctly in this case. */
-		if (dev->mtu > ETH_DATA_LEN)
-			vi->big_packets = true;
 	}
 
+	/* TODO: size buffers correctly in this case. */
+	if (dev->max_mtu > ETH_DATA_LEN)
+		vi->big_packets = true;
+
 	if (vi->any_header_sg)
 		dev->needed_headroom = vi->hdr_len;
 
-- 
2.25.1


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

end of thread, other threads:[~2021-11-25  8:15 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-25  6:05 [PATCH net] virtio-net: enable big mode correctly Jason Wang
2021-11-25  7:00 ` Michael S. Tsirkin
2021-11-25  7:11   ` Jason Wang
2021-11-25  7:14     ` Michael S. Tsirkin
2021-11-25  7:20       ` Jason Wang
2021-11-25  7:26         ` Michael S. Tsirkin
2021-11-25  7:28           ` Jason Wang
2021-11-25  8:13             ` Michael S. Tsirkin
2021-11-25  7:09 ` Eli Cohen
2021-11-25  7:15   ` Jason Wang
2021-11-25  7:20     ` Eli Cohen
2021-11-25  7:26       ` Jason Wang
2021-11-25  7:31         ` Michael S. Tsirkin
2021-11-25  7:41         ` Eli Cohen

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