Message ID | 20221029130957.1292060-2-imagedong@tencent.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp1341837wru; Sat, 29 Oct 2022 06:12:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7qaIF63lrm7/cCDTsT40JJm5taIEZvsjJcGuKMJpJaqAgTwtld4PKItZDCqMePeSur5nLF X-Received: by 2002:a17:902:8bc9:b0:186:e151:6b29 with SMTP id r9-20020a1709028bc900b00186e1516b29mr4428667plo.8.1667049162317; Sat, 29 Oct 2022 06:12:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667049162; cv=none; d=google.com; s=arc-20160816; b=WrfXAypboP5RHrI1aakXzN/kGOBEfum/2VKndNdUaDFlRp6tu82nh7lepEaY8x9FeD wqfmZJNrFMcjIPGlBDET3D9baFP40fCahAMftkP3WWA0NHg5ZZmEQ4haskeqQVJYwPWC PnkSTve5vrsmpP8P6t0GAYu/D+IW7HJ27wyBvZCCBbIgmOFS3FKyMI9MIcXietjIxIx8 dawRyRDMn3liOPDxMrnYHcinlxHL4rOTRWbh0vVjUEQk3BWft5fH6HvRF76YjUtebE7z R+1X3nFpgXZTkyEhY4t+TfIuD/xIOHfTfhaZuKdS07Tp7EkI+xqw3uXK+0ZDTtP3i6Tp CeJg== 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 Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y38-20020a056a00182600b0053652e1c0b6si2178936pfa.12.2022.10.29.06.12.29; Sat, 29 Oct 2022 06:12:42 -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 <rfc822;pusanteemu@gmail.com> + 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 <rfc822;linux-kernel@vger.kernel.org>); 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748027742732250902?= X-GMAIL-MSGID: =?utf-8?q?1748027742732250902?= |
Series |
net: tcp: add skb drop reasons to tcp state process
|
|
Commit Message
Menglong Dong
Oct. 29, 2022, 1:09 p.m. UTC
From: Menglong Dong <imagedong@tencent.com> 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 <imagedong@tencent.com> --- include/linux/skbuff.h | 9 +++++++++ 1 file changed, 9 insertions(+)
Comments
On Sat, Oct 29, 2022 at 6:11 AM <menglong8.dong@gmail.com> wrote: > > From: Menglong Dong <imagedong@tencent.com> > > 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 <imagedong@tencent.com> > --- > 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/
On Sat, Oct 29, 2022 at 11:30 PM Eric Dumazet <edumazet@google.com> wrote: > > On Sat, Oct 29, 2022 at 6:11 AM <menglong8.dong@gmail.com> wrote: > > > > From: Menglong Dong <imagedong@tencent.com> > > > > 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 <imagedong@tencent.com> > > --- > > 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/ Hnn...yeah, your idea seems fine, which wont affect the existing code.
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;