Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1534692pxb; Tue, 8 Feb 2022 21:25:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJzzpoLRmABMZj5wusWh4iYEMQ+ozTS5YmHJHebiZzp0KMxt4evACCXq0u5ZsWbrdxfMWIPH X-Received: by 2002:a17:902:da84:: with SMTP id j4mr531258plx.108.1644384316244; Tue, 08 Feb 2022 21:25:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644384316; cv=none; d=google.com; s=arc-20160816; b=MaWLe5iQyFGs5Gj4mxL6PLsadrYWp9VA4rh/P4h5DiuQjWRq0nNqbgQtQeGEMHyfnF 6pH7sl6jNWtFvaeWF74UaixS+AJJb7rUGF+YkYztlS3IacR/ONQF4IQjt4ZR2h5xVik4 YkF41hpaSlIslbSZT5QxRYWLWlCwbnePIxNzgXArgqm3mpQMFxBwkSGd2S0/CXQLPHrF Oynny/J1QR9pwAb7jpDyurj6JOJjQQtE7JtnKKeC4dUjqKw2QP/DMlEV+Pkc9fj0sZcQ vFQ2DG7mr8YFYIQA6wH9b8hTRnroE69RIBDOFoaAkadTiVxLULV/3OZJm2uFNiLmKYex 9g8w== 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 :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=vK6N04AyX07pMpT7bwBFBL+2ctaA8ouHGk0qanbWuN4=; b=Rk8FpYUYcuyxzNgA5F5uijPhxFeEVLhrvpS28m5PkF7VScad+ynVH03x1b34f9TAUM JNFbSx+BhE+Q40dW123DloWVo/WmtCbaMzRU8W4Dx6oj6Cv9xLqQh3qT7YX30Lsm6trF b14BOxwB3nIFFu09Br/IEkHExVQGmZeBWz1uBtELcr06oiQMtVnegepHdlojfAJHZuGz 6lYLYdRfieixqzveDs7YlFPAhFHRfGwJ+n7KTEWLTtBIyyxkLhNkGOGoOQs32MhxpXCQ +yXHvuSMVJZC6p8DTqSCF3yEKEzu1w9VA7+H6vFdiNgbXY7zL97FB1rJSzSUpny7iSWa gtmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NU4Uk+H6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id s21si13730127plr.187.2022.02.08.21.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Feb 2022 21:25:16 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NU4Uk+H6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id BA9C2C02B66C; Tue, 8 Feb 2022 21:24:24 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1349355AbiBHIZz (ORCPT + 99 others); Tue, 8 Feb 2022 03:25:55 -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-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 X-Spam-Status: No, score=-7.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 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