Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp657077rwj; Sat, 29 Oct 2022 08:46:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AdE6G32XQXcSe1YcEU3KGzIudgUzHp2f2lNbD7jtf3oeD2eaMF7qcHX5mdg7OhJ7wmD7U X-Received: by 2002:a17:90b:1e0d:b0:213:ae0:fcf8 with SMTP id pg13-20020a17090b1e0d00b002130ae0fcf8mr5267044pjb.189.1667058416871; Sat, 29 Oct 2022 08:46:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667058416; cv=none; d=google.com; s=arc-20160816; b=Rr+zH0YJ7575lMD357O5gwHOHnSr3Gn1AAAxaiX+hkpdpPbvFBFpJaW3B0PD1qLoop AJO534EJgUjVMZt/ZldjsTNDh0smxQE9u7HRkeco8J3hpYcp9wgufHdDS4aferoj3e1r ot4YgA5W6kjXxYjIV5VI/Q08bpFZQfnwqfclfY5+BV+U3RhIUnypB0cAvImMwfYGIKnR Aj1gziixB7UAw7unvm1nNk4nU4Qt7ubIUUCROlT2e69jJiRR3Id4gntDBXWfjfkm/xbr +jSHZoc6cW1v5QeYqKuLUGBpUTG6EKA+djWym+FnQoz0e/3hbHX5lZLQtWC/W2JDj38q DDUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=8dYAr+qr1R6Xo9zoSFNEOc560F/LbrOVb8a+d7kwqp4=; b=Lm4YDe7Uuo0nnsvMu1yhFQb8hjplqIUE8iaQImHeVzNpgg4KW0sGYAEbA1XPduWV/j O6IIevzD7XhAWV690MgD83uY/yRVvkbM2WlShCG5jelQ4HBH2cNkssZOXa4o0E0jolIh 6TUKmpnJt/RuPaeN/ARx4RNfpsyCu57mG2FHYqiMKuOuWTNkUcQXbBxi6SS7hR1ZFmNS xCveAW6EaEtSjmPky5v33soNmB0GW3f2k8XWnpWdgd9NST94LlcTmXomC8bWVzNTykAi 2RJstSxtkJnLRsEyhg97E3AHn1NVayyURXiAqNeEkFOynU6RgeA2SFiPL+Sq8nmDBGfG UVyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SFBCqSFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l20-20020a170902e2d400b0018273316ce0si1963634plc.511.2022.10.29.08.46.40; Sat, 29 Oct 2022 08:46:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=SFBCqSFc; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229476AbiJ2Pa0 (ORCPT + 99 others); Sat, 29 Oct 2022 11:30:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229629AbiJ2PaZ (ORCPT ); Sat, 29 Oct 2022 11:30:25 -0400 Received: from mail-yb1-xb29.google.com (mail-yb1-xb29.google.com [IPv6:2607:f8b0:4864:20::b29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9217357DCD for ; Sat, 29 Oct 2022 08:30:23 -0700 (PDT) Received: by mail-yb1-xb29.google.com with SMTP id 185so9236455ybc.3 for ; Sat, 29 Oct 2022 08:30:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=8dYAr+qr1R6Xo9zoSFNEOc560F/LbrOVb8a+d7kwqp4=; b=SFBCqSFcPyEKhaC6bkuFqJYnUd9DED1eyM0qEKYKOdozhtCgd966FWyCAL95L0D80h 50sNgHFjWZZw0Yq12HL9aG2X8zwmhWvBIZJdN7jY9P8/4PHIFaSwZ3dT3pLwa2TYYTb0 Sae9dgnu11OQwrC3KqFpHDK5AFeZk0ilcz8TIhucXVVf75orNE4l0S4SfiIZK93wnh82 vuUA8W5fJT1WZuWsWujX8kjO2m5ksrQ2hpxUeEeYTBmWdM6TJXz8KrLxwnbIsFcObwcN ehnw/G0cLjpCe8k/EeeNAZ7Nh4YfHUn9JB3dVrZF4pZHkbQQIKm5tVYh90J6Dpa1kbDn TKow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=8dYAr+qr1R6Xo9zoSFNEOc560F/LbrOVb8a+d7kwqp4=; b=5AyND/wOSDG+svSKLVoI3WgOqJtUdDffKPQVwI4SlMBBb9Y/yhW2bVGfw9nwVYqd5f oQXz7sbrAdSJGTQwiqNQxUpK+twftlBEkQnn/1Q/RQ/Gq+J0X5QcN6Spt7ndjvH8LOds wm/mfeTGIe+WNeVzh8MJOJdOqhZMIuj2a+4vIuujro9Efw9qR3jG0shZOxKH1Zi9rl1L EkzDCmKAy76nMEOmb3LZ41tEtTstZ2F7NsNbfnQXFhcQS8QJOreM87fj7Uytnz8i9SSd 9C+tmM+p9xTzQa+NTWZ/SxdFPvQYqS9BkWKf4qu9pFHJrjpxR6d+Y2dP3vPRSG2wJBNW 83Zg== X-Gm-Message-State: ACrzQf00/KJ68L98Z81RYJNmIdOok5ZFXQFWmhXEGxixX0zM7qqGh0pV bG2FTd6Tyhy6sqHqGfqo+KfgdEhMV8JqNXaWKkDytg== X-Received: by 2002:a25:aa2c:0:b0:6cc:16c2:5385 with SMTP id s41-20020a25aa2c000000b006cc16c25385mr4201849ybi.55.1667057422552; Sat, 29 Oct 2022 08:30:22 -0700 (PDT) MIME-Version: 1.0 References: <20221029130957.1292060-1-imagedong@tencent.com> <20221029130957.1292060-2-imagedong@tencent.com> In-Reply-To: <20221029130957.1292060-2-imagedong@tencent.com> From: Eric Dumazet Date: Sat, 29 Oct 2022 08:30:11 -0700 Message-ID: Subject: Re: [PATCH net-next 1/9] net: skb: introduce try_kfree_skb() To: menglong8.dong@gmail.com Cc: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, yoshfuji@linux-ipv6.org, dsahern@kernel.org, imagedong@tencent.com, kafai@fb.com, asml.silence@gmail.com, keescook@chromium.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL 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 On Sat, Oct 29, 2022 at 6:11 AM wrote: > > From: Menglong Dong > > In order to simply the code, introduce try_kfree_skb(), which allow > SKB_NOT_DROPPED_YET to be passed. When the reason is SKB_NOT_DROPPED_YET, > consume_skb() will be called to free the skb normally. Otherwise, > kfree_skb_reason() will be called. > > Signed-off-by: Menglong Dong > --- > include/linux/skbuff.h | 9 +++++++++ > 1 file changed, 9 insertions(+) > > diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h > index 59c9fd55699d..f722accc054e 100644 > --- a/include/linux/skbuff.h > +++ b/include/linux/skbuff.h > @@ -1236,6 +1236,15 @@ static inline void consume_skb(struct sk_buff *skb) > } > #endif > > +static inline void try_kfree_skb(struct sk_buff *skb, > + enum skb_drop_reason reason) > +{ > + if (reason != SKB_NOT_DROPPED_YET) > + kfree_skb_reason(skb, reason); > + else > + consume_skb(skb); > +} > + My proposal looks better IMO https://patchwork.kernel.org/project/netdevbpf/patch/20221028133043.2312984-2-edumazet@google.com/