From: menglong8.dong@gmail.com
To: dsahern@kernel.org
Cc: rostedt@goodmis.org, mingo@redhat.com, davem@davemloft.net,
yoshfuji@linux-ipv6.org, kuba@kernel.org, pabeni@redhat.com,
benbjiang@tencent.com, flyingpeng@tencent.com,
imagedong@tencent.com, edumazet@google.com, kafai@fb.com,
talalahmad@google.com, keescook@chromium.org,
mengensun@tencent.com, dongli.zhang@oracle.com,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: [PATCH net-next 9/9] net: ipv6: add skb drop reasons to ip6_protocol_deliver_rcu()
Date: Wed, 13 Apr 2022 16:16:00 +0800 [thread overview]
Message-ID: <20220413081600.187339-10-imagedong@tencent.com> (raw)
In-Reply-To: <20220413081600.187339-1-imagedong@tencent.com>
From: Menglong Dong <imagedong@tencent.com>
Replace kfree_skb() used in ip6_protocol_deliver_rcu() with
kfree_skb_reason().
No new reasons are added.
Some paths are ignored, as they are not common, such as encapsulation
on non-final protocol.
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
---
net/ipv6/ip6_input.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/net/ipv6/ip6_input.c b/net/ipv6/ip6_input.c
index 1b925ecb26e9..126ae3aa67e1 100644
--- a/net/ipv6/ip6_input.c
+++ b/net/ipv6/ip6_input.c
@@ -362,6 +362,7 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
const struct inet6_protocol *ipprot;
struct inet6_dev *idev;
unsigned int nhoff;
+ SKB_DR(reason);
bool raw;
/*
@@ -421,12 +422,16 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
if (ipv6_addr_is_multicast(&hdr->daddr) &&
!ipv6_chk_mcast_addr(dev, &hdr->daddr,
&hdr->saddr) &&
- !ipv6_is_mld(skb, nexthdr, skb_network_header_len(skb)))
+ !ipv6_is_mld(skb, nexthdr, skb_network_header_len(skb))) {
+ SKB_DR_SET(reason, IP_INADDRERRORS);
goto discard;
+ }
}
if (!(ipprot->flags & INET6_PROTO_NOPOLICY) &&
- !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb))
+ !xfrm6_policy_check(NULL, XFRM_POLICY_IN, skb)) {
+ SKB_DR_SET(reason, XFRM_POLICY);
goto discard;
+ }
ret = INDIRECT_CALL_2(ipprot->handler, tcp_v6_rcv, udpv6_rcv,
skb);
@@ -452,8 +457,11 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
IPSTATS_MIB_INUNKNOWNPROTOS);
icmpv6_send(skb, ICMPV6_PARAMPROB,
ICMPV6_UNK_NEXTHDR, nhoff);
+ SKB_DR_SET(reason, IP_NOPROTO);
+ } else {
+ SKB_DR_SET(reason, XFRM_POLICY);
}
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
} else {
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDELIVERS);
consume_skb(skb);
@@ -463,7 +471,7 @@ void ip6_protocol_deliver_rcu(struct net *net, struct sk_buff *skb, int nexthdr,
discard:
__IP6_INC_STATS(net, idev, IPSTATS_MIB_INDISCARDS);
- kfree_skb(skb);
+ kfree_skb_reason(skb, reason);
}
static int ip6_input_finish(struct net *net, struct sock *sk, struct sk_buff *skb)
--
2.35.1
next prev parent reply other threads:[~2022-04-13 8:44 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-13 8:15 [PATCH net-next 0/9] net: ip: add skb drop reasons to ip ingress menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 1/9] skb: add some helpers for skb drop reasons menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 2/9] net: ipv4: add skb drop reasons to ip_error() menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 3/9] net: ipv6: add skb drop reasons to ip6_pkt_drop() menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 4/9] net: ip: add skb drop reasons to ip forwarding menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 5/9] net: icmp: introduce function icmpv6_param_prob_reason() menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 6/9] net: ipv6: remove redundant statistics in ipv6_hop_jumbo() menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 7/9] net: ipv6: add skb drop reasons to TLV parse menglong8.dong
2022-04-13 8:15 ` [PATCH net-next 8/9] net: ipv6: add skb drop reasons to ip6_rcv_core() menglong8.dong
2022-04-13 20:40 ` Eric Dumazet
2022-04-14 1:20 ` Menglong Dong
2022-04-13 8:16 ` menglong8.dong [this message]
2022-04-13 13:30 ` [PATCH net-next 0/9] net: ip: add skb drop reasons to ip ingress 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=20220413081600.187339-10-imagedong@tencent.com \
--to=menglong8.dong@gmail.com \
--cc=benbjiang@tencent.com \
--cc=davem@davemloft.net \
--cc=dongli.zhang@oracle.com \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=flyingpeng@tencent.com \
--cc=imagedong@tencent.com \
--cc=kafai@fb.com \
--cc=keescook@chromium.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mengensun@tencent.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.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).