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, edumazet@google.com,
alobakin@pm.me, ast@kernel.org, imagedong@tencent.com,
pabeni@redhat.com, keescook@chromium.org, talalahmad@google.com,
haokexin@gmail.com, ilias.apalodimas@linaro.org,
memxor@gmail.com, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org, netfilter-devel@vger.kernel.org,
coreteam@netfilter.org, paulb@nvidia.com,
cong.wang@bytedance.com, mengensun@tencent.com
Subject: [PATCH v4 net-next 5/7] net: ipv4: use kfree_skb_reason() in ip_protocol_deliver_rcu()
Date: Sat, 5 Feb 2022 15:47:37 +0800 [thread overview]
Message-ID: <20220205074739.543606-6-imagedong@tencent.com> (raw)
In-Reply-To: <20220205074739.543606-1-imagedong@tencent.com>
From: Menglong Dong <imagedong@tencent.com>
Replace kfree_skb() with kfree_skb_reason() in ip_protocol_deliver_rcu().
Following new drop reasons are introduced:
SKB_DROP_REASON_XFRM_POLICY
SKB_DROP_REASON_IP_NOPROTO
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: David Ahern <dsahern@kernel.org>
---
v2:
- add document for the introduced drop reasons
---
include/linux/skbuff.h | 2 ++
include/trace/events/skb.h | 2 ++
net/ipv4/ip_input.c | 5 +++--
3 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 4baba45f223d..2a64afa97910 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -339,6 +339,8 @@ enum skb_drop_reason {
* is multicast, but L3 is
* unicast.
*/
+ SKB_DROP_REASON_XFRM_POLICY, /* xfrm policy check failed */
+ SKB_DROP_REASON_IP_NOPROTO, /* no support for IP protocol */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 485a1d3034a4..985e481c092d 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -23,6 +23,8 @@
EM(SKB_DROP_REASON_IP_RPFILTER, IP_RPFILTER) \
EM(SKB_DROP_REASON_UNICAST_IN_L2_MULTICAST, \
UNICAST_IN_L2_MULTICAST) \
+ EM(SKB_DROP_REASON_XFRM_POLICY, XFRM_POLICY) \
+ EM(SKB_DROP_REASON_IP_NOPROTO, IP_NOPROTO) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index d5222c0fa87c..d94f9f7e60c3 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -196,7 +196,8 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
if (ipprot) {
if (!ipprot->no_policy) {
if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
- kfree_skb(skb);
+ kfree_skb_reason(skb,
+ SKB_DROP_REASON_XFRM_POLICY);
return;
}
nf_reset_ct(skb);
@@ -215,7 +216,7 @@ void ip_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int protocol)
icmp_send(skb, ICMP_DEST_UNREACH,
ICMP_PROT_UNREACH, 0);
}
- kfree_skb(skb);
+ kfree_skb_reason(skb, SKB_DROP_REASON_IP_NOPROTO);
} else {
__IP_INC_STATS(net, IPSTATS_MIB_INDELIVERS);
consume_skb(skb);
--
2.34.1
next prev parent reply other threads:[~2022-02-05 7:48 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-05 7:47 [PATCH v4 net-next 0/7] net: use kfree_skb_reason() for ip/udp packet receive menglong8.dong
2022-02-05 7:47 ` [PATCH v4 net-next 1/7] net: skb_drop_reason: add document for drop reasons menglong8.dong
2022-02-05 7:47 ` [PATCH v4 net-next 2/7] net: netfilter: use kfree_drop_reason() for NF_DROP menglong8.dong
2022-02-05 7:47 ` [PATCH v4 net-next 3/7] net: ipv4: use kfree_skb_reason() in ip_rcv_core() menglong8.dong
2022-02-06 19:49 ` David Ahern
2022-02-05 7:47 ` [PATCH v4 net-next 4/7] net: ipv4: use kfree_skb_reason() in ip_rcv_finish_core() menglong8.dong
2022-02-05 7:47 ` menglong8.dong [this message]
2022-02-05 7:47 ` [PATCH v4 net-next 6/7] net: udp: use kfree_skb_reason() in udp_queue_rcv_one_skb() menglong8.dong
2022-02-05 7:47 ` [PATCH v4 net-next 7/7] net: udp: use kfree_skb_reason() in __udp_queue_rcv_skb() menglong8.dong
2022-02-07 11:40 ` [PATCH v4 net-next 0/7] net: use kfree_skb_reason() for ip/udp packet receive patchwork-bot+netdevbpf
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=20220205074739.543606-6-imagedong@tencent.com \
--to=menglong8.dong@gmail.com \
--cc=alobakin@pm.me \
--cc=ast@kernel.org \
--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=ilias.apalodimas@linaro.org \
--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=pabeni@redhat.com \
--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).