Received: by 2002:a05:6358:795:b0:dc:4c66:fc3e with SMTP id n21csp495203rwj; Sat, 29 Oct 2022 06:29:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DkcTAgZ80lPy1gBRWWD0Gt7BSWDddZn5JCjwTqWoYXGQi/jbHdbfD3ZR4t9Bi8tkT3Q8e X-Received: by 2002:a05:6402:27d2:b0:462:8e41:569c with SMTP id c18-20020a05640227d200b004628e41569cmr4393838ede.191.1667050160915; Sat, 29 Oct 2022 06:29:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667050160; cv=none; d=google.com; s=arc-20160816; b=eR/YJ7Pxn87GviKVdHsT/ZAiMNDzfoBi4l9MUkPsktmpN6WTVdFOwzQH2Fiai4il1z v2uzx3lmL9S1TdDV+RbV7kNK2GRIRE+3QBtnFKGcy7Ijoyptrzp+Bifn0dLW0Ncfn/X+ x/YGouPgNqQtcKtXnJXn68gllSt1q4Uu9ME4umL3gf+1kURxbPb8MX/3VnYlgSv+uHGw BqclMgv4DOj5umdqg3kQ2geIEGtupUqbuVPBzvS6C1yRmhDoIqsvTsu0YCNFQvFBZY7T tTgb/Q5E+hHy8rInnpKci7IvO4teeRZ8ngZjnMbf2MNnanABiGWwNxtw34HnXjM8KEcQ Zehg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/X4FUMErTbSXHi7NztKKgHeZBiz/PANDAO+0/r0jpSo=; b=ygGjsz9Rlnui6zi01jmeZELgF2poubHf3HfJQ6SbTRCe1hDL6B07kbUqn4CUtJmm0z nWZHS7cr8GC8tetw/7JeXCK23MsvbexyE2AoM6PwWtoc3B0IB61Vkiv3lPbbWi7suCcw 77crSDTMi5XQdUZCOPhqbdqVZe04/M5WQDMGaibUyul8LDVcY31PEFI87YwnCxbzio/r CbGX5m5Ud+4ejnIyYa9epIRUPW0Iwk191+oNbduzMiXhEPZ+ALwgBXR0HbZzByqq5ziI xdCGy8a/PoCx4/TJcoCQRxXDq8aWwuxTgWdSq2t3qqjlTbF066FincKlkkKM/GUxnz9p OSFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=FwtcjpMM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ht8-20020a170907608800b0073d8e4e8c77si1482010ejc.1005.2022.10.29.06.28.52; Sat, 29 Oct 2022 06:29:20 -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=@gmail.com header.s=20210112 header.b=FwtcjpMM; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbiJ2NLT (ORCPT + 99 others); Sat, 29 Oct 2022 09:11:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39206 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229726AbiJ2NLJ (ORCPT ); Sat, 29 Oct 2022 09:11:09 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DF2C68CE7; Sat, 29 Oct 2022 06:11:06 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id r61-20020a17090a43c300b00212f4e9cccdso12202759pjg.5; Sat, 29 Oct 2022 06:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; 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=/X4FUMErTbSXHi7NztKKgHeZBiz/PANDAO+0/r0jpSo=; b=FwtcjpMMhXktv2Q5T+BzKd+LQYO2JAIc77TSXa7VNqsJyPNQ9vUMasTrM2hj/vM8/3 x/1LAtjeS7rcyhPhBFP4z3fmNE6Es2lGxSAJnGZq2P+EPb3UFsTkyTHXUrZbxImwcK6A 4pBl5A8Z0+mBeN3smBxLaOC4ZrKoyEeg98pjsQz0pEl/6RrLlqcfjl2vaH3X1quacz22 uxF3EbA5GPE9L9b2MVGJrK4u41ukNP/9cH0yz/RxozSW6x2qJO9SgikuYp48sb8fxiPt 4TQwYOqi44QjtIszjY9cZdggfeM0HDNb3308fQBbnqgRb+kQuba0nbumU3ildGccdl9N +xZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=/X4FUMErTbSXHi7NztKKgHeZBiz/PANDAO+0/r0jpSo=; b=jN5QkKEGl9rrAn3TPhu1qbJZX312Wo5GeGyqjns+fqkQdNv2X9juALWVsbJ0xDcUFP BJ9seZJZc3VUvspqU4HqlaSUhM6e0srj1PDNoDT7meqah0jTJQg61znYzeRNHnjs51Pe ZRdzKhF4O9wekKZOy6ZL1rt4f8Vxn1tKWRYXhmKYUYeNXbEgWnoe6Cyd+TG+6v/kJuSX NlNvbICjjEeuM7Z+h6JB23sA21BfTtNTXLfhsNv9J2ONxw2xxHy9uyuAbXJ6Dl6MWIDm OA24KGwl44J6tOOvkMw9SClJU+DAfoJ9PuGBAOp1CXSETk6oxraWeEfF0OAWDxL9DuTs 3zIA== X-Gm-Message-State: ACrzQf2sgasB/yBS7c7qikvwFy8Nw46fEyFoKCWnVREiGmcNavMhmc+V yCxe+d4aa8FdSooUXmHz2FU= X-Received: by 2002:a17:903:50e:b0:182:631b:df6f with SMTP id jn14-20020a170903050e00b00182631bdf6fmr4297256plb.66.1667049066487; Sat, 29 Oct 2022 06:11:06 -0700 (PDT) Received: from localhost.localdomain ([203.205.141.21]) by smtp.gmail.com with ESMTPSA id s7-20020a170902988700b001811a197797sm1244069plp.194.2022.10.29.06.11.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Oct 2022 06:11:05 -0700 (PDT) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: edumazet@google.com, kuba@kernel.org Cc: 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 Subject: [PATCH net-next 1/9] net: skb: introduce try_kfree_skb() Date: Sat, 29 Oct 2022 21:09:49 +0800 Message-Id: <20221029130957.1292060-2-imagedong@tencent.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20221029130957.1292060-1-imagedong@tencent.com> References: <20221029130957.1292060-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: 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); +} + void __consume_stateless_skb(struct sk_buff *skb); void __kfree_skb(struct sk_buff *skb); extern struct kmem_cache *skbuff_head_cache; -- 2.37.2