From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.160.200 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796357418; b=HrWVk+FD76hbNXzSOMDVojk4v1mTHRzPUyxbyY8xO8f7JwMTDZtiifHSZjB3FcEbRnto LgiOHfz25Yyh9pZgeWmf4brgRtkYQLOXavPYszGJ+43H+d9aaEpo/R8Vb/lziO7X6dhSB h7xPTHRJKrxl0Rr+6Z1tFgrccgYR3KMm25VYchotuaKv350k5lrmvS+81PGVk8uNBbJC2 WDlh8v4gTq3ka7/7hC0mRzHLoE2cd9am0C0jVAFssP8QyORKnEyhsDIzkh2/OhWWXYXjs PFkfuF10Foghb1wNO42OS2OidgKHmX0Sm4mT61csujzQaciOGQwstqZ88Eh3f1TNudQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796357418; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Received:Date:In-Reply-To: Mime-Version:References:Message-ID:Subject:From:To:Cc:Content-Type; bh=vZ8VwaQwXscoig63IsJxQ3Iehu4ljtLhN9hgrGyRopI=; b=E/pfsSu+/Q4wr8Q6dDdTBk3/b0P0nLzJz68XwrWnfsUK1xjkHPxRg6BPsieqvtQrmkI8 4RWjPEHKdzsnDMz9lWJypw0G0yGUTswkt9F+QutaTBEGRkFk0JfaBuU4+ikXMIyxEhYTt U4DwTioOlWuj2KflNV91mT+JtTuS4uebzmcMmc2cbLcLDBNEtulNC1gmebM8CfagqjU/R qEyIemY9DjpfuTYSrjeyuNw/+y4COG7s6GBFY696aIQY8jCWwmPTIzH6RA2SJOJw/SOAV IoA/5L1nshHmgDCVBt1HfwaafA3q22jfhU2H35azV2eqVJ0KvN3A9pmUctTbsedg1OA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=google.com; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com; dkim=pass header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ZzAKKvj1; arc=none smtp.remote-ip=209.85.160.200 Received: from mail-qt1-f200.google.com (mail-qt1-f200.google.com [209.85.160.200]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0CA2606A32F for ; Fri, 4 Dec 2026 04:10:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org B0CA2606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--willemb.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20260707 header.b=ZzAKKvj1 Received: by mail-qt1-f200.google.com with SMTP id d75a77b69052e-536778a8137so9424581cf.2 for ; Thu, 03 Dec 2026 20:10:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20260707; t=1796357417; x=1796962217; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=vZ8VwaQwXscoig63IsJxQ3Iehu4ljtLhN9hgrGyRopI=; b=ZzAKKvj1pISfcKoEn35KhgYBmi8cLfEx/JNusyxF2CcjR/QvBFPIwCJe4afI8kCTMH d4edjlk0NhSzT1PH4xJDVy8T58sPgmTdJmGWcXZo0SW2Zy/QrbW4c/GHJwWmJ+RbEs3S zxFfJeyf1DChiOZgNN4lCf7HIspJjUUzKRW7+uGaL4rm/phtVjRZxu0nqsLgkmxrh+7L rFAC6CTk4Hng8EoGbggrj6rPSCyjPSDjUNzY9upPfRjW4hOWpsCVywxPAEdl5hgPu9pm pZD5IOwHC1x5dNqjQ6IzSrK3WPDaIqu4B+dkpRitLkuVxP8whdkmC6KDi8Y+XLhI//3K ammg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796357417; x=1796962217; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=vZ8VwaQwXscoig63IsJxQ3Iehu4ljtLhN9hgrGyRopI=; b=F09X5fw+nH1Dr8ZtfWHZKWzmkDa9gYwYcJVf/wxigcvUXoQV0YpQSOffOrXLKq6wl6 ePASg36gFg6ryz1oru/RlgmrMricqNbwVPbhc5cWrfQSnqViVWLxdC6WFFWbDTnCkkFY rRMwchKsU1yLjs6rHs26KdstFbISXJzY/ESuhivml/kexb+6maINDi4RTn6vOsozDs8A WvS9rYEtmxkvMmXBbzIfxnSa0igyt/C/hjSDj/QKdXRLVemr4QhBs4P+Yxua/Diy9K3V edaXSDUnd1wV4pYXsXYvOaQwc8P4bwhXg6xoRXIjedyJQ/ImLaDpyccON1OahhkdWUxX uZUw== X-Forwarded-Encrypted: i=1; AL+hErEdIZjXFCdLjIEdyIYj8JqVLkJ9EHWew3LZ9O85g+5xreSTEdJk5AThJAWTimlwr3FZRXv3/gV0RDv/@vger.kernel.org X-Gm-Message-State: APuU4Z+TCKMEkKc7+B/+nDlaNeMyc5l0HIdfvJ4zKVv8BqXjtnVgUzgP IBvOoMTPlln8QKLIHMqBTablQKVIivs9ERmb7hLtgAXRcj6uFfueQdQ0sU1yN3ivHyvov7KMA2I EWFdOn0bqMA== X-Received: from qvoj16.prod.google.com ([2002:a0c:f9d0:0:b0:921:d63c:3527]) (user=willemb job=prod-delivery.src-stubby-dispatcher) by 2002:a05:622a:986:b0:55d:1944:a2ab with SMTP id d75a77b69052e-55e38d6821fmr10377671cf.49.1796357416363; Thu, 03 Dec 2026 20:10:16 -0800 (PST) Date: Thu, 03 Dec 2026 23:10:15 -0500 In-Reply-To: X-Mailing-List: linux-rdma@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 References: Message-ID: Subject: Re: [PATCH net-next v4 1/2] net: keep the TCP fixed-ID flags on the header they describe From: willemb@google.com To: Julius Bairaktaris , netdev@vger.kernel.org Cc: davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com, horms@kernel.org, andrew+netdev@lunn.ch, dsahern@kernel.org, idosch@nvidia.com, ncardwell@google.com, kuniyu@google.com, steffen.klassert@secunet.com, herbert@gondor.apana.org.au, richardbgobert@gmail.com, ecree.xilinx@gmail.com, andy.moreton@amd.com, alex.austin@amd.com, linux-net-drivers@amd.com, saeedm@nvidia.com, tariqt@nvidia.com, mbloch@nvidia.com, leon@kernel.org, linux-rdma@vger.kernel.org, alexei.starovoitov@gmail.com, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com, ihor.solodrai@linux.dev, john.fastabend@gmail.com, sdf@fomichev.me, izaiahsun@gmail.com, zirajs7@gmail.com, corbet@lwn.net, skhan@linuxfoundation.org, rdunlap@infradead.org, shuah@kernel.org, bpf@vger.kernel.org, ipsec@lists.linux.dev, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8"; format=flowed; delsp=yes Julius Bairaktaris wrote: > Commit 3271f19bf7b9 ("net: gso: restore ids of outer ip headers > correctly") made SKB_GSO_TCP_FIXEDID describe the outermost IPv4 header > and added SKB_GSO_TCP_FIXEDID_INNER for the inner header of an > encapsulated packet. Every path that adds or removes a header then has to > move the flags, and none does. A TCP stream that GRO merged with fixed > IDs and that is forwarded into an IPIP tunnel, or into an ESP tunnel mode > SA with crypto offload, is segmented with one outer ID for all segments > and with incrementing inner IDs. A tunnel that decapsulates such a packet > in iptunnel_pull_offloads() leaves the state of the removed outer header > on the new outer one, and the inner header of a GRE or UDP tunnel, which > segmentation reads at encap_level 0, gets the state of the outer header. > Let SKB_GSO_TCP_FIXEDID describe the innermost IPv4 header again, as it > did before that commit, and replace SKB_GSO_TCP_FIXEDID_INNER with > SKB_GSO_TCP_FIXEDID_OUTER for the outermost header of an encapsulated > packet. Where a header is added in front of a GSO packet, in > iptunnel_handle_offloads() and in the BPF LWT encapsulation, clear the > outer flag, so that the new header gets incrementing IDs as it does on a > packet that was not encapsulated before. Clear it as well where > iptunnel_pull_offloads() and bpf_skb_net_shrink() remove the outer > header. ESP transport and BEET mode with crypto offload set > skb->encapsulation but keep the IPv4 header and its ID, so xfrm_output() > copies the inner flag to the outer one for them. Convert mlx5 and sfc, > the two drivers that use the inner flag. > GRO of an IPv6 TCP stream in an IPv4 tunnel (SIT, or VXLAN over IPv4) > records fixed outer IDs as it does for an IPv4 stream, but > tcp6_gro_complete() never turned that into a flag: set > SKB_GSO_TCP_FIXEDID_OUTER there as tcp4_gro_complete() does. As for an > IPv4 stream, a device without NETIF_F_TSO_MANGLEID then leaves such a > packet to software segmentation. > xfrm_output() segments a GSO packet for a tunnel mode SA with crypto > offload before ESP when skb->inner_protocol is set, as an encapsulated > packet, but a tunnel that decapsulated the packet leaves inner_protocol > set, and segmentation then reads the outer flag for its only IPv4 > header. Take that path only for a packet that is still encapsulated. > Two flags cannot describe a header between the outermost and the > innermost one of a packet with three IPv4 headers: software segmentation > uses SKB_GSO_TCP_FIXEDID for it, as it used SKB_GSO_TCP_FIXEDID_INNER > before. > Suggested-by: Alexei Starovoitov > Signed-off-by: Julius Bairaktaris > --- > v4: > - Set the outer flag in tcp6_gro_complete() for an IPv4 outer header > with fixed IDs in front of an IPv6 TCP stream (Sashiko). > - Take xfrm_output_gso() for a tunnel mode SA only for a packet that is > still encapsulated; a decapsulated one kept inner_protocol (Sashiko). > - Target net-next (Paolo), Fixes: tag dropped. > v3: > - Clear SKB_GSO_TCP_FIXEDID_OUTER in iptunnel_handle_offloads() and in > the BPF LWT encapsulation, where a header goes in front of an > encapsulated packet (Sashiko). > - Copy the inner flag to the outer one in xfrm_output() for ESP transport > and BEET mode with crypto offload (Sashiko). > - Name the paths that change the outer flag and the middle-header limit > in skbuff.h, segmentation-offloads.rst and the message; list the outer > flag in the bpf_skb_adjust_room() decap flags of the uAPI header > (Sashiko). > - Wrap lines at 80 columns (NIPA). > v2: > https://lore.kernel.org/netdev/f7d096c63c6a0b7a23a4dcea9a3de0915a48ac56.1794139176.git.julius@bairaktaris.de/ > v3: > https://lore.kernel.org/netdev/7c74b2076dc7dee1d481d39a135e0946d5e04145.1795284858.git.julius@bairaktaris.de/ > .../networking/segmentation-offloads.rst | 8 +++++--- > .../net/ethernet/mellanox/mlx5/core/en_rx.c | 8 ++------ > drivers/net/ethernet/sfc/ef100_tx.c | 12 +++--------- > include/linux/netdevice.h | 2 +- > include/linux/skbuff.h | 12 +++++++++++- > include/net/ip_tunnels.h | 1 + > include/uapi/linux/bpf.h | 16 +++++++++------- > net/core/filter.c | 1 + > net/core/lwt_bpf.c | 2 ++ > net/ipv4/af_inet.c | 9 ++++++--- > net/ipv4/ip_tunnel_core.c | 2 ++ > net/ipv4/tcp_offload.c | 7 +++++-- > net/ipv6/tcpv6_offload.c | 5 ++++- > net/xfrm/xfrm_output.c | 18 +++++++++++++++++- > tools/include/uapi/linux/bpf.h | 16 +++++++++------- > 15 files changed, 78 insertions(+), 41 deletions(-) > diff --git a/Documentation/networking/segmentation-offloads.rst > b/Documentation/networking/segmentation-offloads.rst > index 25a8b7eca847..45c1703d68b8 100644 > --- a/Documentation/networking/segmentation-offloads.rst > +++ b/Documentation/networking/segmentation-offloads.rst > @@ -49,9 +49,11 @@ The default behavior is to increment the IP ID with > every segment. If the > GSO type SKB_GSO_TCP_FIXEDID is specified then we will not increment the > IP > ID and all segments will use the same IP ID. > -For encapsulated packets, SKB_GSO_TCP_FIXEDID refers only to the outer > header. > -SKB_GSO_TCP_FIXEDID_INNER can be used to specify the same for the inner > header. > -Any combination of these two GSO types is allowed. > +For encapsulated packets, SKB_GSO_TCP_FIXEDID describes the innermost > header > +and SKB_GSO_TCP_FIXEDID_OUTER the outermost header. Any combination of > these > +two GSO types is allowed. A header added in front of a packet gets > incrementing > +IDs. A header between the outermost and the innermost one has no flag of > its > +own; software segmentation uses SKB_GSO_TCP_FIXEDID for it. > If a device has NETIF_F_TSO_MANGLEID set then the IP ID can be ignored > when > performing TSO and we will either increment the IP ID for all frames, or > leave > diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c > b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c > index 1586cb2404c0..e47b1232130c 100644 > --- a/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c > +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_rx.c > @@ -1175,12 +1175,8 @@ static void > mlx5e_shampo_update_ipv4_tcp_hdr(struct mlx5e_rq *rq, struct iphdr * > tcp->check = ~tcp_v4_check(skb->len - tcp_off, ipv4->saddr, > ipv4->daddr, 0); > skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4; > - if (ntohs(ipv4->id) == rq->hw_gro_data->second_ip_id) { > - bool encap = rq->hw_gro_data->fk.control.flags & > FLOW_DIS_ENCAPSULATION; > - > - skb_shinfo(skb)->gso_type |= encap ? SKB_GSO_TCP_FIXEDID_INNER : > - SKB_GSO_TCP_FIXEDID; > - } > + if (ntohs(ipv4->id) == rq->hw_gro_data->second_ip_id) > + skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_FIXEDID; > skb->csum_start = (unsigned char *)tcp - skb->head; > skb->csum_offset = offsetof(struct tcphdr, check); > diff --git a/drivers/net/ethernet/sfc/ef100_tx.c > b/drivers/net/ethernet/sfc/ef100_tx.c > index 03005757c060..162cfa54f2d0 100644 > --- a/drivers/net/ethernet/sfc/ef100_tx.c > +++ b/drivers/net/ethernet/sfc/ef100_tx.c > @@ -201,16 +201,10 @@ static void ef100_make_tso_desc(struct efx_nic *efx, > bool outer_csum; > u32 paylen; > - if (encap) { > - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID_INNER) > - mangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP; > - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID) > - mangleid_outer = ESE_GZ_TX_DESC_IP4_ID_NO_OP; > - } else { > - if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID) > - mangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP; > + if (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID) > + mangleid = ESE_GZ_TX_DESC_IP4_ID_NO_OP; > + if (!encap || (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID_OUTER)) > mangleid_outer = ESE_GZ_TX_DESC_IP4_ID_NO_OP; > - } > if (efx->net_dev->features & NETIF_F_HW_VLAN_CTAG_TX) > vlan_enable = skb_vlan_tag_present(skb); > diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h > index 694b6d29f680..9e0992afbbed 100644 > --- a/include/linux/netdevice.h > +++ b/include/linux/netdevice.h > @@ -5545,7 +5545,7 @@ static inline bool net_gso_ok(netdev_features_t > features, int gso_type) > { > netdev_features_t feature; > - if (gso_type & (SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_INNER)) > + if (gso_type & (SKB_GSO_TCP_FIXEDID | SKB_GSO_TCP_FIXEDID_OUTER)) > gso_type |= __SKB_GSO_TCP_FIXEDID; > feature = ((netdev_features_t)gso_type << NETIF_F_GSO_SHIFT) & > NETIF_F_GSO_MASK; > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index c609cafc7a14..caf374b452ca 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -724,9 +724,19 @@ enum { > /* These indirectly map onto the same netdev feature. > * If NETIF_F_TSO_MANGLEID is set it may mangle both inner and outer > IDs. > + * SKB_GSO_TCP_FIXEDID describes the innermost IPv4 header and > + * SKB_GSO_TCP_FIXEDID_OUTER the outermost one. Adding a header in > + * iptunnel_handle_offloads() or with BPF LWT clears the outer flag, and > + * so does removing one in iptunnel_pull_offloads() or in > + * bpf_skb_adjust_room() with a BPF_F_ADJ_ROOM_DECAP_L4_* or > + * BPF_F_ADJ_ROOM_DECAP_IPXIP* flag. xfrm_output() sets it from the > + * inner flag for ESP transport and BEET mode offload, which keep the > + * header. > + * Software segmentation uses SKB_GSO_TCP_FIXEDID for any header in > + * between. > */ > SKB_GSO_TCP_FIXEDID = 1 << 30, > - SKB_GSO_TCP_FIXEDID_INNER = 1 << 31, > + SKB_GSO_TCP_FIXEDID_OUTER = 1 << 31, > }; > #if BITS_PER_LONG > 32 > diff --git a/include/net/ip_tunnels.h b/include/net/ip_tunnels.h > index 5cccf4c0e691..a8e1cd7021fc 100644 > --- a/include/net/ip_tunnels.h > +++ b/include/net/ip_tunnels.h > @@ -667,6 +667,7 @@ static inline int iptunnel_pull_offloads(struct > sk_buff *skb) > return err; > skb_shinfo(skb)->gso_type &= ~(NETIF_F_GSO_ENCAP_ALL >> > NETIF_F_GSO_SHIFT); > + skb_shinfo(skb)->gso_type &= ~SKB_GSO_TCP_FIXEDID_OUTER; > } > skb->encapsulation = 0; > diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h > index 8d7228834305..e5aae5320af9 100644 > --- a/include/uapi/linux/bpf.h > +++ b/include/uapi/linux/bpf.h > @@ -3097,20 +3097,22 @@ union bpf_attr { > * > * * **BPF_F_ADJ_ROOM_DECAP_L4_GRE**: > * Clear GRE tunnel GSO flags (SKB_GSO_GRE and SKB_GSO_GRE_CSUM) > - * when decapsulating a GRE tunnel. > + * and SKB_GSO_TCP_FIXEDID_OUTER when decapsulating a GRE tunnel. > * > * * **BPF_F_ADJ_ROOM_DECAP_L4_UDP**: > * Clear UDP tunnel GSO flags (SKB_GSO_UDP_TUNNEL and > - * SKB_GSO_UDP_TUNNEL_CSUM) when decapsulating a UDP tunnel. > + * SKB_GSO_UDP_TUNNEL_CSUM) and SKB_GSO_TCP_FIXEDID_OUTER when > + * decapsulating a UDP tunnel. > * > * * **BPF_F_ADJ_ROOM_DECAP_IPXIP4**: > - * Clear IPIP/SIT tunnel GSO flag (SKB_GSO_IPXIP4) when decapsulating > - * a tunnel with an outer IPv4 header (IPv4-in-IPv4 or IPv6-in-IPv4). > + * Clear IPIP/SIT tunnel GSO flag (SKB_GSO_IPXIP4) and > + * SKB_GSO_TCP_FIXEDID_OUTER when decapsulating a tunnel with an > + * outer IPv4 header (IPv4-in-IPv4 or IPv6-in-IPv4). > * > * * **BPF_F_ADJ_ROOM_DECAP_IPXIP6**: > - * Clear IPv6 encapsulation tunnel GSO flag (SKB_GSO_IPXIP6) when > - * decapsulating a tunnel with an outer IPv6 header (IPv6-in-IPv6 > - * or IPv4-in-IPv6). > + * Clear IPv6 encapsulation tunnel GSO flag (SKB_GSO_IPXIP6) and > + * SKB_GSO_TCP_FIXEDID_OUTER when decapsulating a tunnel with an > + * outer IPv6 header (IPv6-in-IPv6 or IPv4-in-IPv6). > * > * When using the decapsulation flags above, the skb->encapsulation > * flag is automatically cleared if all tunnel-specific GSO flags > diff --git a/net/core/filter.c b/net/core/filter.c > index d6a6dd9c9547..5a7957c21d17 100644 > --- a/net/core/filter.c > +++ b/net/core/filter.c > @@ -3856,6 +3856,7 @@ static int bpf_skb_net_shrink(struct sk_buff *skb, > u32 off, u32 len_diff, > /* Clear encapsulation flag only when no tunnel GSO flags remain */ > if (flags & (BPF_F_ADJ_ROOM_DECAP_L4_MASK | > BPF_F_ADJ_ROOM_DECAP_IPXIP_MASK)) { > + shinfo->gso_type &= ~SKB_GSO_TCP_FIXEDID_OUTER; > if (!(shinfo->gso_type & (SKB_GSO_UDP_TUNNEL | > SKB_GSO_UDP_TUNNEL_CSUM | > SKB_GSO_GRE | > diff --git a/net/core/lwt_bpf.c b/net/core/lwt_bpf.c > index 484cd3b53dea..a7d6fda69f60 100644 > --- a/net/core/lwt_bpf.c > +++ b/net/core/lwt_bpf.c > @@ -585,6 +585,8 @@ static int handle_gso_type(struct sk_buff *skb, > unsigned int gso_type, > struct skb_shared_info *shinfo = skb_shinfo(skb); > gso_type |= SKB_GSO_DODGY; > + /* The outer flag described the header below the new one. */ > + shinfo->gso_type &= ~SKB_GSO_TCP_FIXEDID_OUTER; > shinfo->gso_type |= gso_type; > skb_decrease_gso_size(shinfo, encap_len); > shinfo->gso_segs = 0; > diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c > index 5d03a9149b40..c4541c924aaf 100644 > --- a/net/ipv4/af_inet.c > +++ b/net/ipv4/af_inet.c > @@ -1404,10 +1404,13 @@ struct sk_buff *inet_gso_segment(struct sk_buff > *skb, > segs = ERR_PTR(-EPROTONOSUPPORT); > - fixedid = !!(skb_shinfo(skb)->gso_type & (SKB_GSO_TCP_FIXEDID << > encap)); > - > - if (!skb->encapsulation || encap) > + if (!skb->encapsulation || encap) { > udpfrag = !!(skb_shinfo(skb)->gso_type & SKB_GSO_UDP); > + fixedid = !!(skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID); > + } else { > + fixedid = !!(skb_shinfo(skb)->gso_type & > + SKB_GSO_TCP_FIXEDID_OUTER); > + } > ops = rcu_dereference(inet_offloads[proto]); > if (likely(ops && ops->callbacks.gso_segment)) { > diff --git a/net/ipv4/ip_tunnel_core.c b/net/ipv4/ip_tunnel_core.c > index 6c2855adff28..dbf6bbf25114 100644 > --- a/net/ipv4/ip_tunnel_core.c > +++ b/net/ipv4/ip_tunnel_core.c > @@ -193,6 +193,8 @@ int iptunnel_handle_offloads(struct sk_buff *skb, > err = skb_header_unclone(skb, GFP_ATOMIC); > if (unlikely(err)) > return err; > + /* The outer flag described the header below the new one. */ > + skb_shinfo(skb)->gso_type &= ~SKB_GSO_TCP_FIXEDID_OUTER; > skb_shinfo(skb)->gso_type |= gso_type_mask; > return 0; > } > diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c > index 7691be01da4d..93ea20b90550 100644 > --- a/net/ipv4/tcp_offload.c > +++ b/net/ipv4/tcp_offload.c > @@ -463,6 +463,8 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct > sk_buff *skb, int thoff) > { > const u16 offset = > NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation]; > const struct iphdr *iph = (struct iphdr *)(skb->data + offset); > + const u8 fixedid = NAPI_GRO_CB(skb)->ip_fixedid; > + const u8 encap = skb->encapsulation; > struct tcphdr *th = tcp_hdr(skb); > if (unlikely(NAPI_GRO_CB(skb)->is_flist)) { > @@ -477,9 +479,10 @@ INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct > sk_buff *skb, int thoff) > th->check = ~tcp_v4_check(skb->len - thoff, iph->saddr, > iph->daddr, 0); > - BUILD_BUG_ON(SKB_GSO_TCP_FIXEDID << 1 != SKB_GSO_TCP_FIXEDID_INNER); > + /* Bit 0 of ip_fixedid is the outermost header, bit 1 the inner one. */ > skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV4 | > - (NAPI_GRO_CB(skb)->ip_fixedid * SKB_GSO_TCP_FIXEDID); > + (((fixedid >> encap) & 1) * SKB_GSO_TCP_FIXEDID) | > + ((fixedid & encap) * SKB_GSO_TCP_FIXEDID_OUTER); > tcp_gro_complete(skb); > return 0; > diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c > index 71feb92aeac2..f232d5b38bbf 100644 > --- a/net/ipv6/tcpv6_offload.c > +++ b/net/ipv6/tcpv6_offload.c > @@ -96,7 +96,10 @@ static __always_inline int tcp6_gro_complete(struct > sk_buff *skb, int thoff) > th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr, > &iph->daddr, 0); > - skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6; > + /* Only an IPv4 outer header sets bit 0 of ip_fixedid. */ > + skb_shinfo(skb)->gso_type |= SKB_GSO_TCPV6 | > + ((NAPI_GRO_CB(skb)->ip_fixedid & skb->encapsulation) * > + SKB_GSO_TCP_FIXEDID_OUTER); > tcp_gro_complete(skb); > return 0; > diff --git a/net/xfrm/xfrm_output.c b/net/xfrm/xfrm_output.c > index f1f612cd7b43..e5bcb845e9ac 100644 > --- a/net/xfrm/xfrm_output.c > +++ b/net/xfrm/xfrm_output.c > @@ -791,6 +791,7 @@ int xfrm_output(struct sock *sk, struct sk_buff *skb) > secpath_reset(skb); > if (xfrm_dev_offload_ok(skb, x)) { > + bool encap = skb->encapsulation; > struct sec_path *sp; > sp = secpath_set(skb); > @@ -805,10 +806,25 @@ int xfrm_output(struct sock *sk, struct sk_buff > *skb) > xfrm_state_hold(x); > xfrm_get_inner_ipproto(skb, x); > + /* > + * Transport and BEET mode keep the IPv4 header and its ID, so > + * the header that SKB_GSO_TCP_FIXEDID describes is the outer > + * one as well. > + */ > + if (!encap && > + (x->props.mode == XFRM_MODE_TRANSPORT || > + x->props.mode == XFRM_MODE_BEET) && > + (skb_shinfo(skb)->gso_type & SKB_GSO_TCP_FIXEDID)) > + skb_shinfo(skb)->gso_type |= SKB_GSO_TCP_FIXEDID_OUTER; > skb->encapsulation = 1; > if (skb_is_gso(skb)) { > - if (skb->inner_protocol && x->props.mode == XFRM_MODE_TUNNEL) > + /* > + * inner_protocol is only valid on an encapsulated skb: > + * a tunnel that decapsulated the packet leaves it set. > + */ > + if (encap && skb->inner_protocol && > + x->props.mode == XFRM_MODE_TUNNEL) > return xfrm_output_gso(net, sk, skb); > skb_shinfo(skb)->gso_type |= SKB_GSO_ESP; Please respond to the sashiko finding: [Severity: Medium] When !encap and a stale skb->inner_protocol remains from an earlier tunnel decapsulation, does skipping xfrm_output_gso() without clearing skb->inner_protocol cause xfrm4_tunnel_encap_add() and xfrm6_tunnel_encap_add() to skip saving the inner header offsets? net/xfrm/xfrm_output.c:xfrm4_tunnel_encap_add() { ... if (!skb->inner_protocol) { skb_set_inner_network_header(skb, skb_network_offset(skb)); skb_set_inner_transport_header(skb, skb_transport_offset(skb)); } ... } For a decapsulated SKB_GSO_FRAGLIST GRO packet (where inet_gro_complete() set skb->inner_protocol, while tcp4_gro_complete() returned early on is_flist without calling tcp_gro_complete() to set inner_transport_header), inner_transport_header is left unset when xfrm4_tunnel_encap_add() pushes the outer IP header. qdisc_pkt_len_segs_init() then sees a negative or invalid skb_inner_transport_offset(skb) on the offloaded SKB_GSO_ESP packet and drops it with SKB_DROP_REASON_SKB_BAD_GSO. https://lore.kernel.org/all/sashiko-outbox-239682@kernel.org/#t