Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp1957944rwr; Sat, 6 May 2023 02:03:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ufApnHaAoWV3nuNbTinHc7h3Vq78hcqVTt+sihfE5sL2XU0OFRxy9EinK0a1CKpejRaSA X-Received: by 2002:a05:6a20:6a15:b0:f3:57b2:79e2 with SMTP id p21-20020a056a206a1500b000f357b279e2mr5826193pzk.12.1683363820520; Sat, 06 May 2023 02:03:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683363820; cv=none; d=google.com; s=arc-20160816; b=n7pmuu6U5UR2fSX5fl2XdRJD5iz3tozxVI3HuTWSRmS0M3UL+sbSa0hA1pI2eerVvG 6pS2yhPlH74DiYrC3WabL3HObH0/gjhsfJNQtEaIKb1tvjOR7vSSbODJ9CO5pyow9fOf Et9i4o7oor1qtmWh17l6orEZPDMW0MkCVRiaVuTdehuIJSfcsJU2BH0jMF49TYecmSmN y8hn25L8b3646aKYLgX8roeu9ELa2dgj3LZskB6gRsGai0nBg2wLgE+8xCZDUrPHzLUS 4g63FokoRqg44zvf0dHpifTkbhc4WR4XMyILu7zZcSl3x/vbh/KNJU0RA7UigIZwV8sO eNcA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:subject:user-agent:mime-version:date:message-id; bh=h8XAkaDLRib+bH+COhqEQ7j9WgG1Tt2rvSiofFg/GDA=; b=egqOCD2GctvaYzy2knNUp1/SKaq8cBXpZIs2aAzcx1qEZNdrk0BvdoBpnmx3NBdyQp DyfXHfhIk6qGIi1nHtE+5dPRzay1WUuF6K829SdaAhW4zL+LJS+oeiOlD67ki74P8taw MRKOb5WXsebIcPeXakp5dXInEkBGfiwAeOZFUC4lRRuhmIzAIB/IRd7R45iK/xHPE7de hFaDhW20eRsewz2DS7r/Ol7VBBZKPpFXrZdhR2rwclsaGPlIG7E3K3dUbPa0m9oB4yFi PrIu4L+juhg9mA7iPxiQoc84MLslogn4FI7Ir6yOe8+0K1Ru0Q8tK2Ob5suLym87Ulpp Slaw== 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 a21-20020a63e855000000b0050f817c6c82si3875408pgk.232.2023.05.06.02.03.28; Sat, 06 May 2023 02:03:40 -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 S231748AbjEFI4s (ORCPT + 99 others); Sat, 6 May 2023 04:56:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229898AbjEFI4p (ORCPT ); Sat, 6 May 2023 04:56:45 -0400 Received: from out28-100.mail.aliyun.com (out28-100.mail.aliyun.com [115.124.28.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645C78A45; Sat, 6 May 2023 01:56:43 -0700 (PDT) X-Alimail-AntiSpam: AC=CONTINUE;BC=0.07761823|-1;CH=green;DM=|CONTINUE|false|;DS=CONTINUE|ham_regular_dialog|0.0977971-0.00181422-0.900389;FP=0|0|0|0|0|-1|-1|-1;HT=ay29a033018047188;MF=chenh@yusur.tech;NM=1;PH=DS;RN=12;RT=12;SR=0;TI=SMTPD_---.SZt-zKM_1683363395; Received: from 10.2.24.238(mailfrom:chenh@yusur.tech fp:SMTPD_---.SZt-zKM_1683363395) by smtp.aliyun-inc.com; Sat, 06 May 2023 16:56:37 +0800 Message-ID: <07b6b325-9a15-222f-e618-d149b57cbac2@yusur.tech> Date: Sat, 6 May 2023 16:56:35 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.1 Subject: Re: [PATCH] virtio_net: set default mtu to 1500 when 'Device maximum MTU' bigger than 1500 To: Xuan Zhuo Cc: huangml@yusur.tech, zy@yusur.tech, "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "open list:VIRTIO CORE AND NET DRIVERS" , "open list:NETWORKING DRIVERS" , open list References: <20230506021529.396812-1-chenh@yusur.tech> <1683341417.0965195-4-xuanzhuo@linux.alibaba.com> From: Hao Chen In-Reply-To: <1683341417.0965195-4-xuanzhuo@linux.alibaba.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 在 2023/5/6 10:50, Xuan Zhuo 写道: > On Sat, 6 May 2023 10:15:29 +0800, Hao Chen wrote: >> 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, > > You mean tx packet? Yes. > > If yes, I do not think this is the problem of driver. > > Maybe you should give more details about the discard. > In the current code, if the maximum MTU supported by the virtio net hardware is 9000, the default MTU of the virtio net driver will also be set to 9000. When sending packets through "ping -s 5000", if the peer router does not support negotiating a path MTU through ICMP packets, the packets will be discarded. If the peer router supports negotiating path mtu through ICMP packets, the host side will perform packet sharding processing based on the negotiated path mtu, which is generally within 1500. This is not a bugfix patch, I think setting the default mtu to within 1500 would be more suitable here.Thanks. >> 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) > > s/1500/ETH_DATA_LEN/ > > Thanks. > >> + dev->mtu = 1500; >> + else >> + dev->mtu = mtu; >> dev->max_mtu = mtu; >> } >> >> -- >> 2.27.0 >>