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 2/9] net: ipv4: add skb drop reasons to ip_error()
Date: Wed, 13 Apr 2022 16:15:53 +0800 [thread overview]
Message-ID: <20220413081600.187339-3-imagedong@tencent.com> (raw)
In-Reply-To: <20220413081600.187339-1-imagedong@tencent.com>
From: Menglong Dong <imagedong@tencent.com>
Eventually, I find out the handler function for inputting route lookup
fail: ip_error().
The drop reasons we used in ip_error() are almost corresponding to
IPSTATS_MIB_*, and following new reasons are introduced:
SKB_DROP_REASON_IP_INADDRERRORS
SKB_DROP_REASON_IP_INNOROUTES
Isn't the name SKB_DROP_REASON_IP_HOSTUNREACH and
SKB_DROP_REASON_IP_NETUNREACH more accurate? To make them corresponding
to IPSTATS_MIB_*, we keep their name still.
Signed-off-by: Menglong Dong <imagedong@tencent.com>
Reviewed-by: Jiang Biao <benbjiang@tencent.com>
Reviewed-by: Hao Peng <flyingpeng@tencent.com>
---
include/linux/skbuff.h | 6 ++++++
include/trace/events/skb.h | 2 ++
net/ipv4/route.c | 6 +++++-
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0cbd6ada957c..886e83ac4b70 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -447,6 +447,12 @@ enum skb_drop_reason {
* 2211, such as a broadcasts
* ICMP_TIMESTAMP
*/
+ SKB_DROP_REASON_IP_INADDRERRORS, /* host unreachable, corresponding
+ * to IPSTATS_MIB_INADDRERRORS
+ */
+ SKB_DROP_REASON_IP_INNOROUTES, /* network unreachable, corresponding
+ * to IPSTATS_MIB_INADDRERRORS
+ */
SKB_DROP_REASON_MAX,
};
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 42647114fffe..0acac7e5a019 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -63,6 +63,8 @@
EM(SKB_DROP_REASON_TAP_TXFILTER, TAP_TXFILTER) \
EM(SKB_DROP_REASON_ICMP_CSUM, ICMP_CSUM) \
EM(SKB_DROP_REASON_INVALID_PROTO, INVALID_PROTO) \
+ EM(SKB_DROP_REASON_IP_INADDRERRORS, IP_INADDRERRORS) \
+ EM(SKB_DROP_REASON_IP_INNOROUTES, IP_INNOROUTES) \
EMe(SKB_DROP_REASON_MAX, MAX)
#undef EM
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 98c6f3429593..0b581ee5c000 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -945,6 +945,7 @@ static int ip_error(struct sk_buff *skb)
struct inet_peer *peer;
unsigned long now;
struct net *net;
+ SKB_DR(reason);
bool send;
int code;
@@ -964,10 +965,12 @@ static int ip_error(struct sk_buff *skb)
if (!IN_DEV_FORWARD(in_dev)) {
switch (rt->dst.error) {
case EHOSTUNREACH:
+ SKB_DR_SET(reason, IP_INADDRERRORS);
__IP_INC_STATS(net, IPSTATS_MIB_INADDRERRORS);
break;
case ENETUNREACH:
+ SKB_DR_SET(reason, IP_INNOROUTES);
__IP_INC_STATS(net, IPSTATS_MIB_INNOROUTES);
break;
}
@@ -983,6 +986,7 @@ static int ip_error(struct sk_buff *skb)
break;
case ENETUNREACH:
code = ICMP_NET_UNREACH;
+ SKB_DR_SET(reason, IP_INNOROUTES);
__IP_INC_STATS(net, IPSTATS_MIB_INNOROUTES);
break;
case EACCES:
@@ -1009,7 +1013,7 @@ static int ip_error(struct sk_buff *skb)
if (send)
icmp_send(skb, ICMP_DEST_UNREACH, code, 0);
-out: kfree_skb(skb);
+out: kfree_skb_reason(skb, reason);
return 0;
}
--
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 ` menglong8.dong [this message]
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 ` [PATCH net-next 9/9] net: ipv6: add skb drop reasons to ip6_protocol_deliver_rcu() menglong8.dong
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-3-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).