[ltt-dev] [PATCH 2/4] Trace incoming TCP traffic

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


Add a tracepoint to determine if a received packet contains a TCP segment.

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

diff --git a/include/trace/net.h b/include/trace/net.h
index c33b136..43b5779 100644
--- a/include/trace/net.h
+++ b/include/trace/net.h
@@ -10,6 +10,9 @@ DECLARE_TRACE(net_dev_xmit,
 DECLARE_TRACE(net_dev_receive,
 	TP_PROTO(struct sk_buff *skb),
 	TP_ARGS(skb));
+DECLARE_TRACE(net_tcpv4_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 c267355..7b5f124 100644
--- a/ltt/probes/net-trace.c
+++ b/ltt/probes/net-trace.c
@@ -244,6 +244,20 @@ void probe_socket_call(int call, unsigned long a0)
 		"call %d a0 %lu", call, a0);
 }
 
+void probe_tcpv4_rcv(struct sk_buff *skb);
+
+DEFINE_MARKER_TP(net, tcpv4_rcv, net_tcpv4_rcv, probe_tcpv4_rcv,
+	"skb %p");
+
+notrace void probe_tcpv4_rcv(struct sk_buff *skb)
+{
+	struct marker *marker;
+
+	marker = &GET_MARKER(net, tcpv4_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/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 6d88219..8d60b15 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -81,6 +81,10 @@
 #include <linux/crypto.h>
 #include <linux/scatterlist.h>
 
+#include <trace/net.h>
+
+DEFINE_TRACE(net_tcpv4_rcv);
+
 int sysctl_tcp_tw_reuse __read_mostly;
 int sysctl_tcp_low_latency __read_mostly;
 
@@ -1457,6 +1461,9 @@ static __sum16 tcp_v4_checksum_init(struct sk_buff *skb)
 int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
 {
 	struct sock *rsk;
+
+	trace_net_tcpv4_rcv(skb);
+
 #ifdef CONFIG_TCP_MD5SIG
 	/*
 	 * We really want to reject the packet as early as possible
-- 
1.6.3.3





More information about the lttng-dev mailing list