Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1683572rwr; Fri, 5 May 2023 19:25:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6quHgyfjpYv3y2W8OyQ1ZFPemwhxR+KRsdvkbs4eA4Z/ZjV5tUIiO6PcXfn9dqh5rDCUcQ X-Received: by 2002:a05:6a00:84b:b0:643:cb0:2bbe with SMTP id q11-20020a056a00084b00b006430cb02bbemr4959429pfk.15.1683339908525; Fri, 05 May 2023 19:25:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683339908; cv=none; d=google.com; s=arc-20160816; b=agYdvlGaQQXWqYxxxVjfjdvMLSTx9S+5dfFNK6BHq3lO9YEjTd0ltX0gPSoZpnIM1S Hml1OotzJtOAREnBE0P2w8/xHMjayAotMrpyYqMa8RJ8G17yC5G3NrMvDuJhmC9qmz2U NQYv8ZSQDmKM/2cYqkyoIBWYS2wa0S0AxV1EhPcryL2u4yqcVQEvQRIoIm3ov+t1TbsW gWeQdQgQkzLOWPvgdU1dWniTZWyufBuKNdW2Q6fGz1dirxwYKBeq75bnEb+V1agxnIFs qe5Zg43rTobEhWB7B7HYxGWdyBMrpjspGzSYTFJE+JLUvIGhO03UJHVO7TBna9VHc4H8 pRuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=v8yDk15U3mr7fK48d01i10xzgAUrMkCk9Nck+E2kWb4=; b=Jgv4scP0cGxRvIWKm362RMccqi+eT15A9ltiaX+ndMcBvoHM9/4hEb4vTi7LMSseuh jdt/6+7lymwgVVNrwr47lxHcR2Je34MWOwwzj6WmeX+dxaNO1BjpRGP19ry1CxZ+U/2v vsewB8d2vYr3ixpXes5TxUbFc3HMoR0Hf9I8/U42CpKabg//i5qw0xDjrzZ40XCvlyjX rmge125wSujTJ91wtADGmU9Kg2NzK9cLcCaSZOn+aI98TEJ7xGPdAfl+GWvZiLJHrh6J CwxvmM4OfWsjgXC+lDaj0ujO8f7LYb9GyISRoOREizt8RoaeRTrHPxPMp+E/G6A91H99 zi3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m125-20020a625883000000b006439d46853dsi3283246pfb.364.2023.05.05.19.24.52; Fri, 05 May 2023 19:25:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231731AbjEFCPm (ORCPT + 99 others); Fri, 5 May 2023 22:15:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229942AbjEFCPk (ORCPT ); Fri, 5 May 2023 22:15:40 -0400 Received: from out28-76.mail.aliyun.com (out28-76.mail.aliyun.com [115.124.28.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C1B2976A5; Fri, 5 May 2023 19:15:37 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.2457787|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_system_inform|0.0424939-0.00109742-0.956409;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047203;MF=chenh@yusur.tech;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_---.SZYz9Ya_1683339330; Received: from localhost.localdomain(mailfrom:chenh@yusur.tech fp:SMTPD_---.SZYz9Ya_1683339330) by smtp.aliyun-inc.com; Sat, 06 May 2023 10:15:32 +0800 From: Hao Chen To: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , virtualization@lists.linux-foundation.org (open list:VIRTIO CORE AND NET DRIVERS), netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Cc: huangml@yusur.tech, zy@yusur.tech Subject: [PATCH] virtio_net: set default mtu to 1500 when 'Device maximum MTU' bigger than 1500 Date: Sat, 6 May 2023 10:15:29 +0800 Message-Id: <20230506021529.396812-1-chenh@yusur.tech> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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