Received: by 2002:ab2:7104:0:b0:1f7:f6c3:9cb1 with SMTP id z4csp55935lql; Tue, 7 May 2024 09:34:37 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXY6Zr7oQgMSEJg0S5wmHb33Ok1btrhHQQzlzFDTgDcQ6FrNBlYJx74I50sj/fIX41J8xHowvPMzmrXGqjqxUsOHo/gBt7nyx1T4dZK5w== X-Google-Smtp-Source: AGHT+IHeKnkSZF1hcsRGPF06wwKxLBHD9SZWjcbyVF+lGYFANEfS8/kfC8wDhBRPSw+EfP0rjyfg X-Received: by 2002:a17:907:60e:b0:a59:a431:a8ce with SMTP id a640c23a62f3a-a59fb94a3fdmr328766b.2.1715099677588; Tue, 07 May 2024 09:34:37 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715099677; cv=pass; d=google.com; s=arc-20160816; b=aAgwj1Ii7rpGbU+LnL3vAOMstV0GesQiJev2ys+l2yaEh9ZeP8RUZ4KDrbLW/Xx3XU /IhWd1h7Zo1tLOILM0WOrEt85DBT2HQ5fEejqyHOIzTYVIerD41TJ/tDUbK+TnEz+29z rFU4ucdh0zlu4kSFgcFx5VULZlt2ki+UtCtHaXGH0ry7oF59iYSMj1euyE0OysIOoqgT /EDzm9OSeVlib/K6Sh0xz1EKS/rYefhqjcNkCi+NBbwHShzeVZ3Eniq+P1mmjmAcBE2W NavmTrrImfIJ7LAyOiIM4tgML1LDr1owQcAeziR+ni1x7esTktugALufxyx/IqHfwNQP fhHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=EEZf3QdtDW8MX2mGFJXyG0+aloiqU19g1Raki3JNYco=; fh=w7UGIXZsqWj2qPJGUr57DJ+CU7Sk/2H61PITwOwmYjU=; b=S3SG01jHDE9fj1CSqA7Wiox4/6smkKVVSmdkanHv2CQ7oDPk3UG71/8/04SP7Mxa1U PkG+skiHdOTIjKlqvdng3XL92mb5P5uX4wEQLEjFWQsrnfWLrVa5yzTKHB7GyyvncYhs zX2vLJVsE6F/Y2sMvcHpNV4aaKjAjL4Rg31iKLSV74pAlGCX12zYq8dFVI0ghJar1KZ1 U0hVetOb0j416gsd5UmJJizDfYJvUmR1QNSMFlC+/kRhozU0DpszQnW4ibCMTMTyp7SK 4H6Vk43FV3Enh3bVTUMMw1i3lkO1GVgDGupr7P8JQr68Fl1+dvMz0UKp4JlLpbWvQRS5 BNgA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="aursnnQ/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-171821-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171821-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g9-20020a17090670c900b00a59f600a1e8si368537ejk.483.2024.05.07.09.34.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 09:34:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171821-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="aursnnQ/"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-171821-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171821-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 12A751F2212D for ; Tue, 7 May 2024 16:34:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B387516D9A3; Tue, 7 May 2024 16:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aursnnQ/" Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 661C416D304; Tue, 7 May 2024 16:29:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715099365; cv=none; b=SY/ZkPJdyYVFHlzc1xGE9kngwYlW9QCWGSaf8sp2GN4xW5coy1OvBQgjJnYskqiu/N2HQxG8rugthaEwrMaGqweZHNWxuOe0cG+XRFJaqG41f7yYUw2W8xbXD0jYAZ1VssXHtSV2KHVM+APbzOJa5raVuGUK+U6QziD3wwmeObU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715099365; c=relaxed/simple; bh=JzWG+TVT24xjUV+BtqvHafFb5mVQUUD55uKYF3ryVwk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Jkw533WSiWA3FEEnQVqc+38yLDZ+cQCMVEKsddiRJIJhCzRwLsvDZok8bBTXsTpstmGCka/T9uo4C3rHNsIN1VoEolqiZpyvHhMMsV0qdLBpFFPWBD7lcYvVyP/ksGRz4XQ9n54H5Yy9Q0T3BBmaTeHI2cBdixpbiuY2MKtBeDc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aursnnQ/; arc=none smtp.client-ip=209.85.221.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-34d96054375so2047128f8f.2; Tue, 07 May 2024 09:29:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715099362; x=1715704162; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EEZf3QdtDW8MX2mGFJXyG0+aloiqU19g1Raki3JNYco=; b=aursnnQ/ixMLBGtPF248OSuCMa046/dp7Hy2XhmeFXRmHniZkrwQ8wc/EgmslYQ2qS 96sWQA23uI9A7dQP1G17Z4DxJL2H+XPeJeCT1WyKsS3lB8m6wHln5pvyfCta8nKnlP6t 2sb7OP8a7zQ9Pt3RuQSEoE9ia2L1VnsFggWjPQuYCs0W78rAJr+07OkdlrlhqnZfABpD hMuHSan+xycKN/IgP3qcwo5D3HDvjEekLt1ivM9RmrDVU0+54Ds3/3VqgNuPaGA8GKRQ l+PbTDV1dQdsV5w58F3pAwWENnrVHzBX1BMLslDisa3JlnmiP/tZo0ZxR955PBzf3qXk gWzQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715099362; x=1715704162; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EEZf3QdtDW8MX2mGFJXyG0+aloiqU19g1Raki3JNYco=; b=VLV0NzZSKWfUvyw9BY1XvI4Wgp2egk4T94Zjj6W/048kK8Ns6PLYFNjICK/Tm8phA/ COVGe3aIF6gFUdzonjeE5KZq72r+dLZ0+Mh/8f2MgzKJjrLJETjn3ufQLqYSwctlh8Wq jaRqGqCV0PmMY9+l6XzPus658dNcPIwi8GigwzFXydXwkZDE17yj2utm+2y5xIAS10X2 wgbWa5Wu1zWoMIkPL5mh2WNsWeTQUrGIr0vIJzIcOLfx1bqGwIyV446ewOzBIS6sObbb BebteNyeC50Skep9Z9hE2guhPNXLcm/EYHqVPLXO9y6Lrh4CzQPxdgocvKYJeIgkLQKN OSPg== X-Forwarded-Encrypted: i=1; AJvYcCVoPNm0c0LRGtlueQdP8KjnP7wo9zwfDcfeFFZ1+lGshouDeDfq1S3PsDo+3/dsSzsQjlik4iFAWsaMyjJiEm5AJAW229bUQJzGN/qWiCPuH4kOEXzWM1HHxJw4p4KCOACZVOu5izN0yZdKpUHXvdfIuGt6rGZ+eJ+/6Qcv3emxuJ8os3Uv X-Gm-Message-State: AOJu0Yw2Cy7gxekqD4G7tSz0/elZfwtWrbj/W0FuLpioP3jkTMbOgcRt E+AVClHTBnHObk/xosJp03VsQZUsDtyA9oN1D76pf8tZEak5mPSV X-Received: by 2002:adf:f4c3:0:b0:34f:5d07:ebd1 with SMTP id ffacd0b85a97d-34fca6214d3mr194693f8f.56.1715099361786; Tue, 07 May 2024 09:29:21 -0700 (PDT) Received: from localhost ([146.70.204.204]) by smtp.gmail.com with ESMTPSA id o10-20020a5d47ca000000b0034d9e5411ebsm13371417wrc.45.2024.05.07.09.29.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 09:29:21 -0700 (PDT) From: Richard Gobert To: richardbgobert@gmail.com Cc: alexander.duyck@gmail.com, davem@davemloft.net, dsahern@kernel.org, edumazet@google.com, kuba@kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, netdev@vger.kernel.org, pabeni@redhat.com, shuah@kernel.org, willemdebruijn.kernel@gmail.com Subject: [PATCH net-next v9 1/3] net: gro: use cb instead of skb->network_header Date: Tue, 7 May 2024 18:28:07 +0200 Message-Id: <20240507162807.130396-1-richardbgobert@gmail.com> In-Reply-To: <20240507162349.130277-1-richardbgobert@gmail.com> References: <20240507162349.130277-1-richardbgobert@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit This patch converts references of skb->network_header to napi_gro_cb's network_offset and inner_network_offset. Signed-off-by: Richard Gobert --- include/net/gro.h | 9 +++++++-- net/ipv4/af_inet.c | 4 ---- net/ipv4/tcp_offload.c | 3 ++- net/ipv6/ip6_offload.c | 5 ++--- net/ipv6/tcpv6_offload.c | 3 ++- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/include/net/gro.h b/include/net/gro.h index c1d4ca0463a1..3dafa0f31ae1 100644 --- a/include/net/gro.h +++ b/include/net/gro.h @@ -181,12 +181,17 @@ static inline void *skb_gro_header(struct sk_buff *skb, unsigned int hlen, return ptr; } +static inline int skb_gro_receive_network_offset(const struct sk_buff *skb) +{ + return NAPI_GRO_CB(skb)->network_offsets[NAPI_GRO_CB(skb)->encap_mark]; +} + static inline void *skb_gro_network_header(const struct sk_buff *skb) { if (skb_gro_may_pull(skb, skb_gro_offset(skb))) - return skb_gro_header_fast(skb, skb_network_offset(skb)); + return skb_gro_header_fast(skb, skb_gro_receive_network_offset(skb)); - return skb_network_header(skb); + return skb->data + skb_gro_receive_network_offset(skb); } static inline __wsum inet_gro_compute_pseudo(const struct sk_buff *skb, diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index a7bad18bc8b5..428196e1541f 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c @@ -1569,10 +1569,6 @@ struct sk_buff *inet_gro_receive(struct list_head *head, struct sk_buff *skb) NAPI_GRO_CB(skb)->is_atomic = !!(iph->frag_off & htons(IP_DF)); NAPI_GRO_CB(skb)->flush |= flush; - skb_set_network_header(skb, off); - /* The above will be needed by the transport layer if there is one - * immediately following this IP hdr. - */ NAPI_GRO_CB(skb)->inner_network_offset = off; /* Note : No need to call skb_gro_postpull_rcsum() here, diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c index fab0973f995b..b70ae50e658d 100644 --- a/net/ipv4/tcp_offload.c +++ b/net/ipv4/tcp_offload.c @@ -330,7 +330,8 @@ struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb) INDIRECT_CALLABLE_SCOPE int tcp4_gro_complete(struct sk_buff *skb, int thoff) { - const struct iphdr *iph = ip_hdr(skb); + const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation]; + const struct iphdr *iph = (struct iphdr *)(skb->data + offset); struct tcphdr *th = tcp_hdr(skb); th->check = ~tcp_v4_check(skb->len - thoff, iph->saddr, diff --git a/net/ipv6/ip6_offload.c b/net/ipv6/ip6_offload.c index c8b909a9904f..288c7c6ea50f 100644 --- a/net/ipv6/ip6_offload.c +++ b/net/ipv6/ip6_offload.c @@ -67,7 +67,7 @@ static int ipv6_gro_pull_exthdrs(struct sk_buff *skb, int off, int proto) off += len; } - skb_gro_pull(skb, off - skb_network_offset(skb)); + skb_gro_pull(skb, off - skb_gro_receive_network_offset(skb)); return proto; } @@ -236,7 +236,6 @@ INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head, if (unlikely(!iph)) goto out; - skb_set_network_header(skb, off); NAPI_GRO_CB(skb)->inner_network_offset = off; flush += ntohs(iph->payload_len) != skb->len - hlen; @@ -260,7 +259,7 @@ INDIRECT_CALLABLE_SCOPE struct sk_buff *ipv6_gro_receive(struct list_head *head, NAPI_GRO_CB(skb)->proto = proto; flush--; - nlen = skb_network_header_len(skb); + nlen = skb_gro_offset(skb) - off; list_for_each_entry(p, head, list) { const struct ipv6hdr *iph2; diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c index 4b07d1e6c952..e70d60e0f86f 100644 --- a/net/ipv6/tcpv6_offload.c +++ b/net/ipv6/tcpv6_offload.c @@ -29,7 +29,8 @@ struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb) INDIRECT_CALLABLE_SCOPE int tcp6_gro_complete(struct sk_buff *skb, int thoff) { - const struct ipv6hdr *iph = ipv6_hdr(skb); + const u16 offset = NAPI_GRO_CB(skb)->network_offsets[skb->encapsulation]; + const struct ipv6hdr *iph = (struct ipv6hdr *)(skb->data + offset); struct tcphdr *th = tcp_hdr(skb); th->check = ~tcp_v6_check(skb->len - thoff, &iph->saddr, -- 2.36.1