Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp622068pxb; Tue, 5 Apr 2022 16:15:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwt7vwdAxdTXSb7dgl5w/c548vGNPEQLF5l1xjuQPMeRpm+7wLLgE9IDlD7NPpEiQHvjlo2 X-Received: by 2002:a17:902:9304:b0:155:eb5a:8dd4 with SMTP id bc4-20020a170902930400b00155eb5a8dd4mr5804542plb.117.1649200524276; Tue, 05 Apr 2022 16:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649200524; cv=none; d=google.com; s=arc-20160816; b=Ndq7QH67otFiWc6eM4+ae0SHDHtnN87eOcmDsq5tnfooaWiQpmmea3tno/ag0s6VKj PepHQtcmsr53lLBMex16F12aEBMKemiAWXrSWh33UYAhOck1wEhDkA1javSSNYShZs9f sC13aCybwpTj6aEwGym5/7ZjJWepm7gLE+mORjhxJ8I1jyHM1zoWdnQ0t3qRKdpQGQPi 2YCMhxFXXZO7OxJsONfV6MPeR/AhrTUfBpCkhnh/o4/U1dG+UJge8q/OFzgJwjtQW1NU EppHa7VYtuIkjsrdA43plHZfvjTfeFMwG/mz0ctrVFzxRYNw0hIhAoI2JMxdEjK6AKjg m4xg== 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:message-id:date:subject:cc:to :from:dkim-signature; bh=tUxdo6YJKs/OpqQ1nlnmjOryfSpLAADEfDnXV9Z8njY=; b=d7Qm1WVP85hfTYQQDI7by5PIRMrI0cdyv8bwIBz99FSDC9AttZx7PhbW1PxnI0DRVt aO7Q950evTo4FiUPoIDROzwxUI3h34c2sS+28CWltNzAWeNWbAVKp8JI7HsFUM//E3aS eknAfXpv4IFuhOLYnWWlamzMpXbW5z+JW22wv9cFM5kGM36M71rh1Mhk+8HsWw+2Quog Q+vA3fqK2DABi+HPqCnU3Y1OxOhXjObc6cLgNertr3hjsfZUOnHDHVDnEZ35KfcqYawW szbdElvSCdPigYFtnJypmjkGOJ3rzBWbaM8PqQ36qajbAHIiB6ahicidW/5pNWoFCYwK lAzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MmQyfqgC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id d7-20020a056a0010c700b004fa3a8dffccsi14898402pfu.131.2022.04.05.16.15.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Apr 2022 16:15:24 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MmQyfqgC; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 7986521F762; Tue, 5 Apr 2022 16:00:08 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241421AbiDEN6P (ORCPT + 99 others); Tue, 5 Apr 2022 09:58:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347787AbiDEJ2S (ORCPT ); Tue, 5 Apr 2022 05:28:18 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0B80BDFDF0; Tue, 5 Apr 2022 02:15:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 601BCB81B14; Tue, 5 Apr 2022 09:15:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A799AC385A0; Tue, 5 Apr 2022 09:15:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1649150139; bh=96oNeD33rHbyUhWlGPfvyGgsBdc7m1lgLLFr8IoWAsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmQyfqgCbs8W6HmsP02Tsw0scoQw9Ffx61df9K0Ww2ehQ54iTcf1g/76x4Qhmlnhv ThuafJCFlXORaLHNBBvs5DyJetqhI7/BrEIm5dMHq9GVq03hsRpOchjgbpg3mMp9Jd t1B6RvKWPEzPLqYymmeORG9EFuJpbpMDmEy3uwBU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Jakub Kicinski Subject: [PATCH 5.16 0969/1017] net: add skb_set_end_offset() helper Date: Tue, 5 Apr 2022 09:31:22 +0200 Message-Id: <20220405070422.968941177@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220405070354.155796697@linuxfoundation.org> References: <20220405070354.155796697@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 From: Eric Dumazet commit 763087dab97547230a6807c865a6a5ae53a59247 upstream. We have multiple places where this helper is convenient, and plan using it in the following patch. Signed-off-by: Eric Dumazet Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- include/linux/skbuff.h | 10 ++++++++++ net/core/skbuff.c | 19 +++++-------------- 2 files changed, 15 insertions(+), 14 deletions(-) --- a/include/linux/skbuff.h +++ b/include/linux/skbuff.h @@ -1446,6 +1446,11 @@ static inline unsigned int skb_end_offse { return skb->end; } + +static inline void skb_set_end_offset(struct sk_buff *skb, unsigned int offset) +{ + skb->end = offset; +} #else static inline unsigned char *skb_end_pointer(const struct sk_buff *skb) { @@ -1456,6 +1461,11 @@ static inline unsigned int skb_end_offse { return skb->end - skb->head; } + +static inline void skb_set_end_offset(struct sk_buff *skb, unsigned int offset) +{ + skb->end = skb->head + offset; +} #endif /* Internal */ --- a/net/core/skbuff.c +++ b/net/core/skbuff.c @@ -201,7 +201,7 @@ static void __build_skb_around(struct sk skb->head = data; skb->data = data; skb_reset_tail_pointer(skb); - skb->end = skb->tail + size; + skb_set_end_offset(skb, size); skb->mac_header = (typeof(skb->mac_header))~0U; skb->transport_header = (typeof(skb->transport_header))~0U; @@ -1738,11 +1738,10 @@ int pskb_expand_head(struct sk_buff *skb skb->head = data; skb->head_frag = 0; skb->data += off; + + skb_set_end_offset(skb, size); #ifdef NET_SKBUFF_DATA_USES_OFFSET - skb->end = size; off = nhead; -#else - skb->end = skb->head + size; #endif skb->tail += off; skb_headers_offset_update(skb, nhead); @@ -6138,11 +6137,7 @@ static int pskb_carve_inside_header(stru skb->head = data; skb->data = data; skb->head_frag = 0; -#ifdef NET_SKBUFF_DATA_USES_OFFSET - skb->end = size; -#else - skb->end = skb->head + size; -#endif + skb_set_end_offset(skb, size); skb_set_tail_pointer(skb, skb_headlen(skb)); skb_headers_offset_update(skb, 0); skb->cloned = 0; @@ -6280,11 +6275,7 @@ static int pskb_carve_inside_nonlinear(s skb->head = data; skb->head_frag = 0; skb->data = data; -#ifdef NET_SKBUFF_DATA_USES_OFFSET - skb->end = size; -#else - skb->end = skb->head + size; -#endif + skb_set_end_offset(skb, size); skb_reset_tail_pointer(skb); skb_headers_offset_update(skb, 0); skb->cloned = 0;