From: David Ahern <dsahern@gmail.com>
To: menglong8.dong@gmail.com, kuba@kernel.org, rostedt@goodmis.org
Cc: davem@davemloft.net, mingo@redhat.com, yoshfuji@linux-ipv6.org,
dsahern@kernel.org, imagedong@tencent.com, ycheng@google.com,
kuniyu@amazon.co.jp, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: Re: [PATCH v2 net-next 0/2] net: snmp: tracepoint support for snmp
Date: Thu, 18 Nov 2021 08:36:55 -0700 [thread overview]
Message-ID: <67b36bd8-2477-88ac-83a0-35a1eeaf40c9@gmail.com> (raw)
In-Reply-To: <20211118124812.106538-1-imagedong@tencent.com>
On 11/18/21 5:48 AM, menglong8.dong@gmail.com wrote:
> From: Menglong Dong <imagedong@tencent.com>
>
> snmp is the network package statistics module in kernel, and it is
> useful in network issue diagnosis, such as packet drop.
>
> However, it is hard to get the detail information about the packet.
> For example, we can know that there is something wrong with the
> checksum of udp packet though 'InCsumErrors' of UDP protocol in
> /proc/net/snmp, but we can't figure out the ip and port of the packet
> that this error is happening on.
>
> Add tracepoint for snmp. Therefor, users can use some tools (such as
> eBPF) to get the information of the exceptional packet.
>
> In the first patch, the frame of snmp-tracepoint is created. And in
> the second patch, tracepoint for udp-snmp is introduced.
>
there is already good infrastructure around kfree_skb - e.g., drop watch
monitor. Why not extend that in a way that other drop points can benefit
over time?
e.g., something like this (uncompiled and not tested; and to which
Steven is going to suggest strings for the reason):
diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
index 0bd6520329f6..e66e634acad0 100644
--- a/include/linux/skbuff.h
+++ b/include/linux/skbuff.h
@@ -1075,8 +1075,13 @@ static inline bool skb_unref(struct sk_buff *skb)
return true;
}
+enum skb_drop_reason {
+ SKB_DROP_REASON_NOT_SPECIFIED,
+ SKB_DROP_REASON_CSUM,
+}
void skb_release_head_state(struct sk_buff *skb);
void kfree_skb(struct sk_buff *skb);
+void kfree_skb_with_reason(struct sk_buff *skb, enum skb_drop_reason);
void kfree_skb_list(struct sk_buff *segs);
void skb_dump(const char *level, const struct sk_buff *skb, bool full_pkt);
void skb_tx_error(struct sk_buff *skb);
diff --git a/include/trace/events/skb.h b/include/trace/events/skb.h
index 9e92f22eb086..2a2d263f9d46 100644
--- a/include/trace/events/skb.h
+++ b/include/trace/events/skb.h
@@ -14,7 +14,7 @@
*/
TRACE_EVENT(kfree_skb,
- TP_PROTO(struct sk_buff *skb, void *location),
+ TP_PROTO(struct sk_buff *skb, void *location, enum
skb_drop_reason reason),
TP_ARGS(skb, location),
@@ -22,16 +22,18 @@ TRACE_EVENT(kfree_skb,
__field( void *, skbaddr )
__field( void *, location )
__field( unsigned short, protocol )
+ __field( unsigned int, reason )
),
TP_fast_assign(
__entry->skbaddr = skb;
__entry->location = location;
__entry->protocol = ntohs(skb->protocol);
+ __entry->reason = reason;
),
- TP_printk("skbaddr=%p protocol=%u location=%p",
- __entry->skbaddr, __entry->protocol, __entry->location)
+ TP_printk("skbaddr=%p protocol=%u location=%p reason %u",
+ __entry->skbaddr, __entry->protocol, __entry->location,
__entry->reason)
);
TRACE_EVENT(consume_skb,
diff --git a/net/core/skbuff.c b/net/core/skbuff.c
index 67a9188d8a49..388059bda3d1 100644
--- a/net/core/skbuff.c
+++ b/net/core/skbuff.c
@@ -770,11 +770,29 @@ void kfree_skb(struct sk_buff *skb)
if (!skb_unref(skb))
return;
- trace_kfree_skb(skb, __builtin_return_address(0));
+ trace_kfree_skb(skb, __builtin_return_address(0),
SKB_DROP_REASON_NOT_SPECIFIED);
__kfree_skb(skb);
}
EXPORT_SYMBOL(kfree_skb);
+/**
+ * kfree_skb_with_reason - free an sk_buff
+ * @skb: buffer to free
+ * @reason: enum describing why the skb is dropped
+ *
+ * Drop a reference to the buffer and free it if the usage count has
+ * hit zero.
+ */
+void kfree_skb_with_reason(struct sk_buff *skb, enum skb_drop_reason
reason);
+{
+ if (!skb_unref(skb))
+ return;
+
+ trace_kfree_skb(skb, __builtin_return_address(0), reason);
+ __kfree_skb(skb);
+}
+EXPORT_SYMBOL(kfree_skb_with_reason);
+
void kfree_skb_list(struct sk_buff *segs)
{
while (segs) {
next prev parent reply other threads:[~2021-11-18 15:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-18 12:48 menglong8.dong
2021-11-18 12:48 ` [PATCH v2 net-next 1/2] net: snmp: add " menglong8.dong
2021-11-18 15:57 ` Steven Rostedt
2021-11-18 12:48 ` [PATCH v2 net-next 2/2] net: snmp: add snmp tracepoint support for udp menglong8.dong
2021-11-18 14:46 ` [PATCH v2 net-next 0/2] net: snmp: tracepoint support for snmp Steven Rostedt
2021-11-18 15:36 ` David Ahern [this message]
2021-11-19 3:45 ` Menglong Dong
2021-11-19 3:54 ` David Ahern
2021-11-21 10:47 ` Menglong Dong
2021-11-21 14:02 ` Steven Rostedt
2021-11-22 16:42 ` David Ahern
2021-11-24 2:56 ` Menglong Dong
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=67b36bd8-2477-88ac-83a0-35a1eeaf40c9@gmail.com \
--to=dsahern@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=imagedong@tencent.com \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.co.jp \
--cc=linux-kernel@vger.kernel.org \
--cc=menglong8.dong@gmail.com \
--cc=mingo@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=rostedt@goodmis.org \
--cc=ycheng@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
all inboxes | Powered by JetHome®