diff mbox series

[net-next,10/13] ipv6: introduce tracepoint trace_udpv6_rcv()

Message ID 20210805185750.4522-11-xiyou.wangcong@gmail.com
State New
Headers show
Series net: add more tracepoints to TCP/IP stack | expand

Commit Message

Cong Wang Aug. 5, 2021, 6:57 p.m. UTC
From: Qitao Xu <qitao.xu@bytedance.com>

Tracepoint trace_udpv6_rcv() is introduced to trace skb at
the entrance of UDPv6 layer on RX side.

Reviewed-by: Cong Wang <cong.wang@bytedance.com>
Signed-off-by: Qitao Xu <qitao.xu@bytedance.com>
---
 include/trace/events/udp.h | 17 +++++++++++++++++
 net/core/net-traces.c      |  1 +
 net/ipv6/udp.c             |  7 ++++++-
 3 files changed, 24 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/include/trace/events/udp.h b/include/trace/events/udp.h
index 5008bdd546e8..01e026a3f542 100644
--- a/include/trace/events/udp.h
+++ b/include/trace/events/udp.h
@@ -82,6 +82,23 @@  TRACE_EVENT(udp_v6_send_skb,
 
 	TP_printk("skaddr=%px, skbaddr=%px", __entry->skaddr, __entry->skbaddr)
 );
+
+TRACE_EVENT(udpv6_rcv,
+
+	TP_PROTO(const struct sk_buff *skb),
+
+	TP_ARGS(skb),
+
+	TP_STRUCT__entry(
+		__field(const void *, skbaddr)
+	),
+
+	TP_fast_assign(
+		__entry->skbaddr = skb;
+	),
+
+	TP_printk("skbaddr=%px", __entry->skbaddr)
+);
 #endif
 
 #endif /* _TRACE_UDP_H */
diff --git a/net/core/net-traces.c b/net/core/net-traces.c
index de5a13ae933c..83df315708ba 100644
--- a/net/core/net-traces.c
+++ b/net/core/net-traces.c
@@ -65,4 +65,5 @@  EXPORT_TRACEPOINT_SYMBOL_GPL(tcp_bad_csum);
 #if IS_ENABLED(CONFIG_IPV6)
 EXPORT_TRACEPOINT_SYMBOL_GPL(udp_v6_send_skb);
 EXPORT_TRACEPOINT_SYMBOL_GPL(ipv6_rcv);
+EXPORT_TRACEPOINT_SYMBOL_GPL(udpv6_rcv);
 #endif
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 84895ca40e5c..1c8b36fe7218 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -1085,7 +1085,12 @@  INDIRECT_CALLABLE_SCOPE void udp_v6_early_demux(struct sk_buff *skb)
 
 INDIRECT_CALLABLE_SCOPE int udpv6_rcv(struct sk_buff *skb)
 {
-	return __udp6_lib_rcv(skb, &udp_table, IPPROTO_UDP);
+	int ret;
+
+	ret = __udp6_lib_rcv(skb, &udp_table, IPPROTO_UDP);
+	if (!ret)
+		trace_udpv6_rcv(skb);
+	return ret;
 }
 
 /*