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 B07E4C433F5 for ; Tue, 8 Feb 2022 16:01:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382622AbiBHQBV (ORCPT ); Tue, 8 Feb 2022 11:01:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1381165AbiBHQBQ (ORCPT ); Tue, 8 Feb 2022 11:01:16 -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 CF208C061579 for ; Tue, 8 Feb 2022 08:01:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644336075; 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=I1wYQcALmzzp3eC1Kv9MyB7va4H/QkIUUQ+lvknf2po=; b=D6+v8o9Edw7YJtFKgWNsZ3A0EsrlWP7OTw3ayhqv+MWG5LG9jHVCoq3jHKOBmqViyeuLiq TKrNCCChouc7uJO4bL9mD++mI3WwYH03V0BH7LzRf2kL1EK3DA5VeuSbhBnCQ/oxAxUsXg ZUt8PRknK0CkElmD4eMQXlzcP/0137Q= Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-27-O1p2V5o3OU2ptM5wxX8MqQ-1; Tue, 08 Feb 2022 11:01:14 -0500 X-MC-Unique: O1p2V5o3OU2ptM5wxX8MqQ-1 Received: by mail-qt1-f200.google.com with SMTP id s1-20020ac85ec1000000b002cf7c93d56dso13819065qtx.21 for ; Tue, 08 Feb 2022 08:01:13 -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=I1wYQcALmzzp3eC1Kv9MyB7va4H/QkIUUQ+lvknf2po=; b=5YoyepipBJ88JkvEeBew66RT2VpoqmApQuQkD9gA3sAsyjtAWvtEUfiH/jOmk/eVo+ KsyWUK8P4OXvLf78+cZvDRMOVQKfvNI+tRAxV4zoG+KNu3+x+jLw1wiy0lVnEJQ0cNxt tZEq9oh8CnnO4XsULrq0HvrQvnl/PYibWOwKLmQHiTEtSjBYcN6ujy1AHK0x0BRnrY+o zXQPQo8lgI3WRLnhIZdTaAChcoBeuRgOI5wmvNvQ5068oinU955y6O7k3u5Mc10aUNSY E7mIcODNmTZw21CVH6b/Ww2NmuKMsEqlrUzxKWhPS5EiVeH85uuGQqqzVdhDqeoYmqUl 2Eew== X-Gm-Message-State: AOAM530liXi6Q/9UfWvTlxyoM2cggxSPTY/oQN42RUA8KSSTEk8ef1DW LbFE5KRz/Yo6z3Ty3cTvpX3OTFaPTpXGg8jeOHGLErBPs7TSG1yUNX/UgADGcJhfRnmLf/ei3V2 LWvK6urByz/M28PrL5vbR21uw X-Received: by 2002:a05:6214:2402:: with SMTP id fv2mr3581322qvb.9.1644336073337; Tue, 08 Feb 2022 08:01:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9xYpQIzQXvKpdRdFAJVedmOkOWIXhZG1xIX9Mpv3pOBzgATnhlRQx/QiOqbkA6Pc8H2YY6w== X-Received: by 2002:a05:6214:2402:: with SMTP id fv2mr3581250qvb.9.1644336072750; Tue, 08 Feb 2022 08:01:12 -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 b10sm7585437qtb.34.2022.02.08.08.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 08:01:12 -0800 (PST) Message-ID: Subject: Re: [PATCH] net: fix wrong network header length From: Paolo Abeni To: Maciej =?UTF-8?Q?=C5=BBenczykowski?= , Steffen Klassert Cc: Lina Wang , "David S . Miller" , Jakub Kicinski , Matthias Brugger , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Linux NetDev , Kernel hackers , bpf , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Willem Bruijn , Eric Dumazet Date: Tue, 08 Feb 2022 17:01:07 +0100 In-Reply-To: References: <20220208025511.1019-1-lina.wang@mediatek.com> <0300acca47b10384e6181516f32caddda043f3e4.camel@redhat.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 + Steffen On Tue, 2022-02-08 at 04:57 -0800, Maciej Żenczykowski wrote: > On Tue, Feb 8, 2022 at 12:25 AM Paolo Abeni wrote: > > > > 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. > > Yeah, I don't know... > > I've considered that we could perhaps fix the 6to4 helper, and 4to6 helper... > but then I think every *other* helper / code path that plays games > with the packet header needs fixing as well, > ie. everything dealing with encap/decap, vlan, etc.. > > At that point it seems to me like it's worth fixing here rather than > in all those other places. > > In general it seems gro fraglist as implemented is just a bad idea... > Packets (and things we treat like packets) really should only have 1 header. > GRO fraglist - as implemented - violates this pretty fundamental assumption. > As such it seems to be on the gro fraglist implementation to deal with it. > That to me seems to mean it should be fixed here, and not elsewhere. @Steffen: IIRC GRO_FRAGLIST was originally added to support some forwarding scenarios. Now we have GRO_UDP_FWD which should be quite comparable. I'm wondering if the latter feature addresses your use case, too. If so, could we consider deprecating (and in a longer run, drop) the GRO_FRAGLIST feature? Thanks! Paolo