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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8A2EC43217 for ; Tue, 8 Feb 2022 08:26:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349374AbiBHIZ5 (ORCPT ); Tue, 8 Feb 2022 03:25:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349668AbiBHIZw (ORCPT ); Tue, 8 Feb 2022 03:25:52 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1B04FC03FEC0 for ; Tue, 8 Feb 2022 00:25:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644308750; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vK6N04AyX07pMpT7bwBFBL+2ctaA8ouHGk0qanbWuN4=; b=NU4Uk+H6vDLPr9KtLjREbNbG4ed04M4vxojLvSIV07AhRSN9AspH74i9Nms3ItFmcahiGa hsmG9iyJpprrMcSQpd6NRvwPZQGQJfwFV7R8k7d0wbbzXCXzC5L66VRXdjVtjSkATSx+lV 1KlMOUQjdrhqvtrqV5r5Zx04Kf359xs= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-529-1inVdJlxMqu0gbU8xnULhQ-1; Tue, 08 Feb 2022 03:25:49 -0500 X-MC-Unique: 1inVdJlxMqu0gbU8xnULhQ-1 Received: by mail-wr1-f70.google.com with SMTP id j8-20020adfa548000000b001e33074ac51so1342131wrb.11 for ; Tue, 08 Feb 2022 00:25:48 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=vK6N04AyX07pMpT7bwBFBL+2ctaA8ouHGk0qanbWuN4=; b=TVAiMiscbmGS8YHwLhKAuJ2QQWc5k2KaiDcy+nCRONmrYd0cu0cj2+xnvJQ7rLkFzP JhkFr6d6PooCRUGrKTEk7GtLSrgtBjwWPt/aP5/bWn+r05oL+Ra/M2+1hsv/zkNPMCzQ i/6WvvtGIlUPMcuN9UGFLueb7o9kEavGklNaVG3L5hwEaI/DYVUpe/cM3dG/12Wl0LJZ 3YXTpzJQuIoHOakigJeFSb3Zvqprohm4HvDDTotpyrLxwLvxWx1E+7hS4SA7viO24EUG jz6/oEFjPiLX++oI5mnaFV2g0wDplWpglriiuYD6X09Ys0a3ka++3kZ/N4Wr4mCxYdEL TG1w== X-Gm-Message-State: AOAM532N3RZRYi6LP7sHPybQ7sI26KQcMjWOQAJovRzi9yaTHYMRFaxZ CromvQP+oNOR2+Xe94Ncu+tdTfXLRqphNoWUtT1+B9ldihb5y8PG3RJTTSc/7QB/tBNhHEm8v1l sz7hWDVUhyURDQoDcgP9yFjIW X-Received: by 2002:a1c:f004:: with SMTP id a4mr92374wmb.1.1644308747829; Tue, 08 Feb 2022 00:25:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxwcIp4GwwlLjr351VgLNGexExdoCChF42UovxVNCbQl1Hb3RiYgQkMtyyft5+2jnWx1EvDaA== X-Received: by 2002:a1c:f004:: with SMTP id a4mr92362wmb.1.1644308747614; Tue, 08 Feb 2022 00:25:47 -0800 (PST) Received: from gerbillo.redhat.com (146-241-96-254.dyn.eolo.it. [146.241.96.254]) by smtp.gmail.com with ESMTPSA id e17sm13943510wrt.27.2022.02.08.00.25.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 00:25:47 -0800 (PST) Message-ID: <0300acca47b10384e6181516f32caddda043f3e4.camel@redhat.com> Subject: Re: [PATCH] net: fix wrong network header length From: Paolo Abeni To: Lina Wang , "David S . Miller" , Jakub Kicinski , Matthias Brugger , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , maze@google.com, willemb@google.com, edumazet@google.com Date: Tue, 08 Feb 2022 09:25:45 +0100 In-Reply-To: <20220208025511.1019-1-lina.wang@mediatek.com> References: <20220208025511.1019-1-lina.wang@mediatek.com> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.3 (3.42.3-1.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Tue, 2022-02-08 at 10:55 +0800, Lina Wang wrote: > When clatd starts with ebpf offloaing, and NETIF_F_GRO_FRAGLIST is enable, > several skbs are gathered in skb_shinfo(skb)->frag_list. The first skb's > ipv6 header will be changed to ipv4 after bpf_skb_proto_6_to_4, > network_header\transport_header\mac_header have been updated as ipv4 acts, > but other skbs in frag_list didnot update anything, just ipv6 packets. > > udp_queue_rcv_skb will call skb_segment_list to traverse other skbs in > frag_list and make sure right udp payload is delivered to user space. > Unfortunately, other skbs in frag_list who are still ipv6 packets are > updated like the first skb and will have wrong transport header length. > > e.g.before bpf_skb_proto_6_to_4,the first skb and other skbs in frag_list > has the same network_header(24)& transport_header(64), after > bpf_skb_proto_6_to_4, ipv6 protocol has been changed to ipv4, the first > skb's network_header is 44,transport_header is 64, other skbs in frag_list > didnot change.After skb_segment_list, the other skbs in frag_list has > different network_header(24) and transport_header(44), so there will be 20 > bytes difference,that is difference between ipv6 header and ipv4 header. > Actually, there are two solutions to fix it, one is traversing all skbs > and changing every skb header in bpf_skb_proto_6_to_4, the other is > modifying frag_list skb's header in skb_segment_list.  I don't think the above should be addressed into the GSO layer. The ebpf program is changing the GRO packet in arbitrary way violating the GSO packet constraint - arguably, it's corrupting the packet. I think it would be better change the bpf_skb_proto_6_to_4() to properly handle FRAGLIST GSO packets. If traversing the segments become too costly, you can try replacing GRO_FRAGLIST with GRO_UDP_FWD. Thanks! Paolo