From: menglong8.dong@gmail.com
To: dsahern@kernel.org, kuba@kernel.org
Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net,
yoshfuji@linux-ipv6.org, pablo@netfilter.org,
kadlec@netfilter.org, fw@strlen.de, imagedong@tencent.com,
edumazet@google.com, alobakin@pm.me, paulb@nvidia.com,
keescook@chromium.org, talalahmad@google.com, haokexin@gmail.com,
memxor@gmail.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, cong.wang@bytedance.com,
mengensun@tencent.com
Subject: [PATCH v3 net-next 2/7] net: netfilter: use kfree_drop_reason() for NF_DROP
Date: Fri, 28 Jan 2022 15:33:14 +0800 [thread overview]
Message-ID: <20220128073319.1017084-3-imagedong@tencent.com> (raw)
In-Reply-To: <20220128073319.1017084-1-imagedong@tencent.com>
From: Menglong Dong <imagedong@tencent.com>
Replace kfree_skb() with kfree_skb_reason() in nf_hook_slow() when
skb is dropped by reason of NF_DROP. Following new drop reasons
are introduced:
SKB_DROP_REASON_NETFILTER_DROP
Signed-off-by: Menglong Dong <imagedong@tencent.com>
---
v2:
- add document for SKB_DROP_REASON_NETFILTER_DROP
---
include/linux/skbuff.h | 1 +
include/trace/events/skb.h | 1 +
net/netfilter/core.c | 3 ++-
3 files changed, 4 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 5c5615a487e7..786ea2c2334e 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -320,6 +320,7 @@ enum skb_drop_reason {
SKB_DROP_REASON_TCP_CSUM, /* TCP checksum error */
SKB_DROP_REASON_SOCKET_FILTER, /* dropped by socket filter */
SKB_DROP_REASON_UDP_CSUM, /* UDP checksum error */
+ SKB_DROP_REASON_NETFILTER_DROP, /* dropped by netfilter */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index a8a64b97504d..3d89f7b09a43 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -16,6 +16,7 @@
EM(SKB_DROP_REASON_TCP_CSUM, TCP_CSUM) \
EM(SKB_DROP_REASON_SOCKET_FILTER, SOCKET_FILTER) \
EM(SKB_DROP_REASON_UDP_CSUM, UDP_CSUM) \
+ EM(SKB_DROP_REASON_NETFILTER_DROP, NETFILTER_DROP) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/netfilter/core.c b/net/netfilter/core.c
index 354cb472f386..d1c9dfbb11fa 100644
--- a/net/netfilter/core.c
+++ b/net/netfilter/core.c
@@ -621,7 +621,8 @@ int nf_hook_slow(struct sk_buff *skb, struct nf_hook_state *state,
case NF_ACCEPT:
break;
case NF_DROP:
- kfree_skb(skb);
+ kfree_skb_reason(skb,
+ SKB_DROP_REASON_NETFILTER_DROP);
ret = NF_DROP_GETERR(verdict);
if (ret == 0)
ret = -EPERM;
--
2.34.1
next prev parent reply other threads:[~2022-01-28 7:33 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-28 7:33 [PATCH v3 net-next 0/7] net: use kfree_skb_reason() for ip/udp packet receive menglong8.dong
2022-01-28 7:33 ` [PATCH v3 net-next 1/7] net: skb_drop_reason: add document for drop reasons menglong8.dong
2022-01-31 17:14 ` David Ahern
2022-02-10 3:19 ` Menglong Dong
2022-02-10 5:12 ` Jakub Kicinski
2022-02-10 13:42 ` Menglong Dong
2022-02-10 16:13 ` Jakub Kicinski
2022-02-10 16:29 ` Eric Dumazet
2022-02-11 8:53 ` Menglong Dong
2022-02-11 8:49 ` Menglong Dong
2022-01-28 7:33 ` menglong8.dong [this message]
2022-01-28 7:33 ` [PATCH v3 net-next 3/7] net: ipv4: use kfree_skb_reason() in ip_rcv_core() menglong8.dong
2022-01-31 18:05 ` David Ahern
2022-02-04 14:42 ` Menglong Dong
2022-01-28 7:33 ` [PATCH v3 net-next 4/7] net: ipv4: use kfree_skb_reason() in ip_rcv_finish_core() menglong8.dong
2022-01-31 17:45 ` David Ahern
2022-01-28 7:33 ` [PATCH v3 net-next 5/7] net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu() menglong8.dong
2022-01-31 17:49 ` David Ahern
2022-01-28 7:33 ` [PATCH v3 net-next 6/7] net: udp: use kfree_skb_reason() in udp_queue_rcv_one_skb() menglong8.dong
2022-01-31 17:50 ` David Ahern
2022-01-28 7:33 ` [PATCH v3 net-next 7/7] net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb() menglong8.dong
2022-01-31 17:53 ` David Ahern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220128073319.1017084-3-imagedong@tencent.com \
--to=menglong8.dong@gmail.com \
--cc=alobakin@pm.me \
--cc=cong.wang@bytedance.com \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=haokexin@gmail.com \
--cc=imagedong@tencent.com \
--cc=kadlec@netfilter.org \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=memxor@gmail.com \
--cc=mengensun@tencent.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=paulb@nvidia.com \
--cc=rostedt@goodmis.org \
--cc=talalahmad@google.com \
--cc=yoshfuji@linux-ipv6.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).