[ltt-dev] [PATCH 3/4] Trace incomming UDP traffic

Benjamin Poirier benjamin.poirier at polymtl.ca
Wed Oct 21 16:51:39 EDT 2009


Add a tracepoint to determine if a received packet contains a UDP datagram.

Signed-off-by: Benjamin Poirier <benjamin.poirier at polymtl.ca>
---
 include/trace/net.h    |    3 +++
 ltt/probes/net-trace.c |   14 ++++++++++++++
 net/ipv4/udp.c         |    5 +++++
 3 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/include/trace/net.h b/include/trace/net.h
index 43b5779..5e774eb 100644
--- a/include/trace/net.h
+++ b/include/trace/net.h
@@ -13,6 +13,9 @@ DECLARE_TRACE(net_dev_receive,
 DECLARE_TRACE(net_tcpv4_rcv,
 	TP_PROTO(struct sk_buff *skb),
 	TP_ARGS(skb));
+DECLARE_TRACE(net_udpv4_rcv,
+	TP_PROTO(struct sk_buff *skb),
+	TP_ARGS(skb));
 
 /*
  * Note these first 2 traces are actually in __napi_schedule and net_rx_action
diff --git a/ltt/probes/net-trace.c b/ltt/probes/net-trace.c
index 7b5f124..8fa5111 100644
--- a/ltt/probes/net-trace.c
+++ b/ltt/probes/net-trace.c
@@ -258,6 +258,20 @@ notrace void probe_tcpv4_rcv(struct sk_buff *skb)
 		&skb, sizeof(skb), sizeof(skb));
 }
 
+void probe_udpv4_rcv(struct sk_buff *skb);
+
+DEFINE_MARKER_TP(net, udpv4_rcv, net_udpv4_rcv, probe_udpv4_rcv,
+	"skb %p");
+
+notrace void probe_udpv4_rcv(struct sk_buff *skb)
+{
+	struct marker *marker;
+
+	marker = &GET_MARKER(net, udpv4_rcv);
+	ltt_specialized_trace(marker, marker->single.probe_private,
+		&skb, sizeof(skb), sizeof(skb));
+}
+
 #ifdef CONFIG_NETPOLL
 void probe_net_napi_schedule(struct napi_struct *n);
 
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 80e3812..87c842f 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -104,6 +104,7 @@
 #include <net/route.h>
 #include <net/checksum.h>
 #include <net/xfrm.h>
+#include <trace/net.h>
 #include "udp_impl.h"
 
 struct udp_table udp_table;
@@ -122,6 +123,8 @@ EXPORT_SYMBOL(udp_memory_allocated);
 
 #define PORTS_PER_CHAIN (65536 / UDP_HTABLE_SIZE)
 
+DEFINE_TRACE(net_udpv4_rcv);
+
 static int udp_lib_lport_inuse(struct net *net, __u16 num,
 			       const struct udp_hslot *hslot,
 			       unsigned long *bitmap,
@@ -1263,6 +1266,8 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
 	if (udp4_csum_init(skb, uh, proto))
 		goto csum_error;
 
+	trace_net_udpv4_rcv(skb);
+
 	saddr = ip_hdr(skb)->saddr;
 	daddr = ip_hdr(skb)->daddr;
 
-- 
1.6.3.3





More information about the lttng-dev mailing list