Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp512132pxa; Thu, 27 Aug 2020 08:17:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk3gp7f6i8LN0ev09I0djaZHLCTwPqz9ClxI+FyRLAEDdy9EQGhcyIB/OlJr8Adn6qH+Oi X-Received: by 2002:a17:906:fcdc:: with SMTP id qx28mr17629654ejb.289.1598541472363; Thu, 27 Aug 2020 08:17:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598541472; cv=none; d=google.com; s=arc-20160816; b=qaGXgB5vCjMPJrfW1FRVIQ96ZkMqzvQUaGUOQDvG3UZZzRfc6wbVEy5rLv7+H/kUu1 WvpSYBhBfnR9bCUUEi9vkEh1J3UNoFs6muYbNZRg6Vx/aqfVSeSDSIpVj21+qbsB+lJz 3W7rcEQ3pa6VYvJaOeb8fJ+BmA1oSCt/mk3eyPSKV85PppsoRZY1Ie0ao2tgaBebCZvl GTFoLa1hsSwq1CSbPlqxuseXGNjWR+DPdr0e0QJtm9nUqUWbCB2CrSjjar5azcMTY0Ik rc7XIZnBB2nH3Sl0xTDxXOBvrwWSHrLWkW7QUptieuWOFSfnD38K+wFAB06umXV8yOqt mCHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=rcg4TIxpS2XrDTWj8mS51Tf2vGitjPKgU895pVtnQkw=; b=fOHX2TBqGf0wX2b/o8OsRhFCNUERzrJkxhL7G8tVyQcsWfWqbMj0ka3dlbvrbihMOi RyYCGJTLWcBLDW0z+0l1w3h8p2TMlf7ngnT0OX7UQirYLpACsp4jspAPjBBoKds8OJnL zmEHKIyHrMNs4FHgmnAX9KKpphP4QINdJh4yBoI/UdlHZnfZPwBJ3UkkSCwZ0gBxQzOD piGabGb3a8VFCnTiSOxtni1t9cunp1/fz0UUPaGsRXFHjuD1CK+lL+4MMPHfL2BcLk5a rxlkKFncmC6Vv6+xKEN/fdD6Iqx4e/ZCFzJqM/ZvY1ElBWZuRaa6HkFQTcz9qKqzQkbj UBGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SgvKEzvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si1626352ejr.369.2020.08.27.08.17.29; Thu, 27 Aug 2020 08:17:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=SgvKEzvY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728292AbgH0PPx (ORCPT + 99 others); Thu, 27 Aug 2020 11:15:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728400AbgH0Lia (ORCPT ); Thu, 27 Aug 2020 07:38:30 -0400 Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com [IPv6:2607:f8b0:4864:20::d43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1F1FCC0611E0 for ; Thu, 27 Aug 2020 04:37:20 -0700 (PDT) Received: by mail-io1-xd43.google.com with SMTP id d18so5394694iop.13 for ; Thu, 27 Aug 2020 04:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=rcg4TIxpS2XrDTWj8mS51Tf2vGitjPKgU895pVtnQkw=; b=SgvKEzvYUaEchSKyXnlDf9/rSQtJ8+7m+0GJkn97LKTQl5LEu9FPK9m43svxpmEfgt iH/oN1s764d2JTNj/xWEXaVNL2GB4vqgkruQ1yKEpPqo0ll0EXg+VvWLG5Tl53EbjGJw +OGgWYITwpB0yMLuSqdCB89dDAVwtP1BY+5CjKOb93e42M+8JUnLQcusWy6fNs59V4aj fd7LomJjV6nuXESt9E5JoDX4+oTnHpvJgRWMGzbDO0efG3Xp49x3kgCDbQ4mLt/wG/gf OWHDOiNvcZ2LxXvkoqrEFfIUTur/0rz60hcbbp+NYII6e87FUy2OcA34+YMh5WAjVxKN N/Ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=rcg4TIxpS2XrDTWj8mS51Tf2vGitjPKgU895pVtnQkw=; b=QJIL+CSooimhX9RpitNHUe+NF2obozOOMRcBaBdDG1D2uO0mHTUlKdxIwZup/CNbun HErywq/BB4nXQcWADVRhi4E3pHglNO4kReNW3kDtGwqj4JSPPrctugxnFBLtMt/3YJ5S mzIF+LqNwjHQYsFmCCRWcqCU6ol4HtFvXtVyWKdya34N+PmThUUVxT0sMhcrNsOhp0+7 Yq/k/SUgifZMBIIlQ4gcR+9PtLQcpFTp16ovlHJeef9hAgAj8HoLMw2/ImLA3sqZ1+/e BRZLXspeBJXkwqVEkYHTlxPeslGOyGj+3insRR9V8wEOuQxMieXfZYZBYHvtRHvlLzYN lpdA== X-Gm-Message-State: AOAM531E2y+Epa8pdP4bsEmOXaxnfsXPoZPgKPqWPgnPS4w/WDdAjAzf PjS1rbgyAj9WCTXG0xxle9visuvJwMVx6TAsSMCGtw== X-Received: by 2002:a6b:7846:: with SMTP id h6mr16736497iop.145.1598528239275; Thu, 27 Aug 2020 04:37:19 -0700 (PDT) MIME-Version: 1.0 References: <20200827112342.44526-1-linmiaohe@huawei.com> In-Reply-To: <20200827112342.44526-1-linmiaohe@huawei.com> From: Eric Dumazet Date: Thu, 27 Aug 2020 04:37:08 -0700 Message-ID: Subject: Re: [PATCH] net: exit immediately when off = 0 in skb_headers_offset_update() To: Miaohe Lin Cc: David Miller , Jakub Kicinski , Pravin B Shelar , Florian Westphal , martin.varghese@nokia.com, Davide Caratti , Steffen Klassert , Paolo Abeni , shmulik@metanetworks.com, kyk.segfault@gmail.com, netdev , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 4:25 AM Miaohe Lin wrote: > > In the case of off = 0, skb_headers_offset_update() do nothing indeed. > > Signed-off-by: Miaohe Lin > --- > net/core/skbuff.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/net/core/skbuff.c b/net/core/skbuff.c > index 18ed56316e56..f67f0da20a5b 100644 > --- a/net/core/skbuff.c > +++ b/net/core/skbuff.c > @@ -1459,6 +1459,8 @@ EXPORT_SYMBOL(skb_clone); > > void skb_headers_offset_update(struct sk_buff *skb, int off) > { > + if (unlikely(off == 0)) > + return; If this is unlikely, I doubt adding a test is going to save anything. This will instead add a conditional test for the 'likely' cases.