This introduces a new tracepoint trace_udp_queue_rcv, it will trace UDP
packets that are going to be queued on the socket receive queue.

Signed-off-by: Tony Lu <ton...@linux.alibaba.com>
---
 include/trace/events/udp.h | 7 +++++++
 net/ipv4/udp.c             | 1 +
 net/ipv6/udp.c             | 1 +
 3 files changed, 9 insertions(+)

diff --git a/include/trace/events/udp.h b/include/trace/events/udp.h
index f2c26780e2a9..37daea5f7cb1 100644
--- a/include/trace/events/udp.h
+++ b/include/trace/events/udp.h
@@ -108,6 +108,13 @@ DEFINE_EVENT(udp_event_sk_skb, udp_send,
        TP_ARGS(sk, skb)
 );
 
+DEFINE_EVENT(udp_event_sk_skb, udp_queue_rcv,
+
+       TP_PROTO(const struct sock *sk, const struct sk_buff *skb),
+
+       TP_ARGS(sk, skb)
+);
+
 #endif /* _TRACE_UDP_H */
 
 /* This part must be outside protection */
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 3ff6fea9debe..262d76559bd5 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -2238,6 +2238,7 @@ static int udp_unicast_rcv_skb(struct sock *sk, struct 
sk_buff *skb,
                skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check,
                                         inet_compute_pseudo);
 
+       trace_udp_queue_rcv(sk, skb);
        ret = udp_queue_rcv_skb(sk, skb);
 
        /* a return value > 0 means to resubmit the input, but
diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
index 3a26990d5dc8..49473c5d3c4b 100644
--- a/net/ipv6/udp.c
+++ b/net/ipv6/udp.c
@@ -842,6 +842,7 @@ static int udp6_unicast_rcv_skb(struct sock *sk, struct 
sk_buff *skb,
                skb_checksum_try_convert(skb, IPPROTO_UDP, uh->check,
                                         ip6_compute_pseudo);
 
+       trace_udp_queue_rcv(sk, skb);
        ret = udpv6_queue_rcv_skb(sk, skb);
 
        /* a return value > 0 means to resubmit the input */
-- 
2.21.0

Reply via email to