From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 525E0C2BA83 for ; Thu, 13 Feb 2020 16:23:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2D0852082F for ; Thu, 13 Feb 2020 16:23:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbgBMQXd (ORCPT ); Thu, 13 Feb 2020 11:23:33 -0500 Received: from ivanoab7.miniserver.com ([37.128.132.42]:48512 "EHLO www.kot-begemot.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727772AbgBMQXd (ORCPT ); Thu, 13 Feb 2020 11:23:33 -0500 Received: from tun252.jain.kot-begemot.co.uk ([192.168.18.6] helo=jain.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j2HGw-0000Pf-Tt; Thu, 13 Feb 2020 16:23:27 +0000 Received: from jain.kot-begemot.co.uk ([192.168.3.3]) by jain.kot-begemot.co.uk with esmtp (Exim 4.92) (envelope-from ) id 1j2HGu-0006m0-Mt; Thu, 13 Feb 2020 16:23:26 +0000 Subject: Re: [PATCH] virtio: Work around frames incorrectly marked as gso To: "Michael S. Tsirkin" , Eric Dumazet Cc: netdev@vger.kernel.org, Jason Wang , virtualization@lists.linux-foundation.org, linux-um@lists.infradead.org References: <20191209104824.17059-1-anton.ivanov@cambridgegreys.com> <57230228-7030-c65f-a24f-910ca52bbe9e@cambridgegreys.com> <918222d9-816a-be70-f8af-b8dfcb586240@cambridgegreys.com> <20200211053502-mutt-send-email-mst@kernel.org> <9547228b-aa93-f2b6-6fdc-8d33cde3716a@cambridgegreys.com> <20200213045937-mutt-send-email-mst@kernel.org> <94fb9656-99ee-a001-e428-9d76c3620e61@gmail.com> <20200213105010-mutt-send-email-mst@kernel.org> From: Anton Ivanov Message-ID: <35510da7-08f1-4aa5-c6d6-6bffbccaee0c@cambridgegreys.com> Date: Thu, 13 Feb 2020 16:23:24 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200213105010-mutt-send-email-mst@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Clacks-Overhead: GNU Terry Pratchett Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org On 13/02/2020 15:53, Michael S. Tsirkin wrote: > On Thu, Feb 13, 2020 at 07:44:06AM -0800, Eric Dumazet wrote: >> >> On 2/13/20 2:00 AM, Michael S. Tsirkin wrote: >>> On Wed, Feb 12, 2020 at 05:38:09PM +0000, Anton Ivanov wrote: >>>> >>>> On 11/02/2020 10:37, Michael S. Tsirkin wrote: >>>>> On Tue, Feb 11, 2020 at 07:42:37AM +0000, Anton Ivanov wrote: >>>>>> On 11/02/2020 02:51, Jason Wang wrote: >>>>>>> On 2020/2/11 上午12:55, Anton Ivanov wrote: >>>>>>>> >>>>>>>> On 09/12/2019 10:48, anton.ivanov@cambridgegreys.com wrote: >>>>>>>>> From: Anton Ivanov >>>>>>>>> >>>>>>>>> Some of the frames marked as GSO which arrive at >>>>>>>>> virtio_net_hdr_from_skb() have no GSO_TYPE, no >>>>>>>>> fragments (data_len = 0) and length significantly shorter >>>>>>>>> than the MTU (752 in my experiments). >>>>>>>>> >>>>>>>>> This is observed on raw sockets reading off vEth interfaces >>>>>>>>> in all 4.x and 5.x kernels I tested. >>>>>>>>> >>>>>>>>> These frames are reported as invalid while they are in fact >>>>>>>>> gso-less frames. >>>>>>>>> >>>>>>>>> This patch marks the vnet header as no-GSO for them instead >>>>>>>>> of reporting it as invalid. >>>>>>>>> >>>>>>>>> Signed-off-by: Anton Ivanov >>>>>>>>> --- >>>>>>>>>   include/linux/virtio_net.h | 8 ++++++-- >>>>>>>>>   1 file changed, 6 insertions(+), 2 deletions(-) >>>>>>>>> >>>>>>>>> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h >>>>>>>>> index 0d1fe9297ac6..d90d5cff1b9a 100644 >>>>>>>>> --- a/include/linux/virtio_net.h >>>>>>>>> +++ b/include/linux/virtio_net.h >>>>>>>>> @@ -112,8 +112,12 @@ static inline int >>>>>>>>> virtio_net_hdr_from_skb(const struct sk_buff *skb, >>>>>>>>>               hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV4; >>>>>>>>>           else if (sinfo->gso_type & SKB_GSO_TCPV6) >>>>>>>>>               hdr->gso_type = VIRTIO_NET_HDR_GSO_TCPV6; >>>>>>>>> -        else >>>>>>>>> -            return -EINVAL; >>>>>>>>> +        else { >>>>>>>>> +            if (skb->data_len == 0) >>>>>>>>> +                hdr->gso_type = VIRTIO_NET_HDR_GSO_NONE; >>>>>>>>> +            else >>>>>>>>> +                return -EINVAL; >>>>>>>>> +        } >>>>>>>>>           if (sinfo->gso_type & SKB_GSO_TCP_ECN) >>>>>>>>>               hdr->gso_type |= VIRTIO_NET_HDR_GSO_ECN; >>>>>>>>>       } else >>>>>>>>> >>>>>>>> ping. >>>>>>>> >>>>>>> Do you mean gso_size is set but gso_type is not? Looks like a bug >>>>>>> elsewhere. >>>>>>> >>>>>>> Thanks >>>>>>> >>>>>>> >>>>>> Yes. >>>>>> >>>>>> I could not trace it where it is coming from. >>>>>> >>>>>> I see it when doing recvmmsg on raw sockets in the UML vector network >>>>>> drivers. >>>>>> >>>>> I think we need to find the culprit and fix it there, lots of other things >>>>> can break otherwise. >>>>> Just printing out skb->dev->name should do the trick, no? >>>> The printk in virtio_net_hdr_from_skb says NULL. >>>> >>>> That is probably normal for a locally originated frame. >>>> >>>> I cannot reproduce this with network traffic by the way - it happens only if the traffic is locally originated on the host. >>>> >>>> A, >>> OK so is it code in __tcp_transmit_skb that sets gso_size to non-null >>> when gso_type is 0? >>> >> Correct way to determine if a packet is a gso one is by looking at gso_size. >> Then only it is legal looking at gso_type >> >> >> static inline bool skb_is_gso(const struct sk_buff *skb) >> { >> return skb_shinfo(skb)->gso_size; >> } >> >> /* Note: Should be called only if skb_is_gso(skb) is true */ >> static inline bool skb_is_gso_v6(const struct sk_buff *skb) >> ... >> >> >> There is absolutely no relation between GSO and skb->data_len, skb can be linearized >> for various orthogonal reasons. > The reported problem is that virtio gets a packet where gso_size > is !0 but gso_type is 0. > > It currently drops these on the assumption that it's some type > of a gso packet it does not know how to handle. > > > So you are saying if skb_is_gso we can still have gso_type set to 0, > and that's an expected configuration? > > So the patch should just be: > > > - if (skb_is_gso(skb)) { > + if (skb_is_gso(skb) && sinfo->gso_type) { > Yes, provided that skb_is_gso(skb) and sinfo->gso_type == 0 is a valid state. I agree with Jason, there may be something wrong going on here and we need to find the source which creates these packets. A. > > ? > > > _______________________________________________ > linux-um mailing list > linux-um@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-um -- Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/