Update licensing info
[lttng-modules.git] / deprecated / probes / net-extended-trace.c
CommitLineData
1c8284eb
MD
1/*
2 * ltt/probes/net-extended-trace.c
3 *
4 * Net tracepoint extended probes.
5 *
6 * These probes record many header fields from TCP and UDP messages. Here are
7 * the consequences of this:
8 * 1) it allows analyzing network traffic to provide some pcap-like
9 * functionality within LTTng
10 * 2) it allows offline synchronization of a group of concurrent traces
11 * recorded on different nodes
12 * 3) it increases tracing overhead
13 *
14 * You can leave out these probes or not activate them if you are not
15 * especially interested in the details of network traffic and do not wish to
16 * synchronize distributed traces.
17 *
17baffe2
MD
18 * (C) Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
19 *
1c8284eb
MD
20 * Dual LGPL v2.1/GPL v2 license.
21 */
22
23#include <linux/in_route.h>
24#include <linux/ip.h>
25#include <linux/module.h>
26#include <linux/tcp.h>
27#include <linux/udp.h>
28#include <net/route.h>
29#include <trace/net.h>
30
31#include "../ltt-type-serializer.h"
32
33void probe_net_dev_xmit_extended(void *_data, struct sk_buff *skb);
34
35DEFINE_MARKER_TP(net, dev_xmit_extended, net_dev_xmit,
36 probe_net_dev_xmit_extended, "skb 0x%lX network_protocol #n2u%hu "
37 "transport_protocol #1u%u saddr #n4u%lu daddr #n4u%lu "
38 "tot_len #n2u%hu ihl #1u%u source #n2u%hu dest #n2u%hu seq #n4u%lu "
39 "ack_seq #n4u%lu doff #1u%u ack #1u%u rst #1u%u syn #1u%u fin #1u%u");
40
41notrace void probe_net_dev_xmit_extended(void *_data, struct sk_buff *skb)
42{
43 struct marker *marker;
44 struct serialize_l214421224411111 data;
45 struct iphdr *iph = ip_hdr(skb);
46 struct tcphdr *th = tcp_hdr(skb);
47
48 data.f1 = (unsigned long)skb;
49 data.f2 = skb->protocol;
50
51 if (ntohs(skb->protocol) == ETH_P_IP) {
52 data.f3 = ip_hdr(skb)->protocol;
53 data.f4 = iph->saddr;
54 data.f5 = iph->daddr;
55 data.f6 = iph->tot_len;
56 data.f7 = iph->ihl;
57
58 if (data.f3 == IPPROTO_TCP) {
59 data.f8 = th->source;
60 data.f9 = th->dest;
61 data.f10 = th->seq;
62 data.f11 = th->ack_seq;
63 data.f12 = th->doff;
64 data.f13 = th->ack;
65 data.f14 = th->rst;
66 data.f15 = th->syn;
67 data.f16 = th->fin;
68 }
69 }
70
71 marker = &GET_MARKER(net, dev_xmit_extended);
72 ltt_specialized_trace(marker, marker->single.probe_private,
73 &data, serialize_sizeof(data), sizeof(long));
74}
75
76void probe_tcpv4_rcv_extended(void *_data, struct sk_buff *skb);
77
78DEFINE_MARKER_TP(net, tcpv4_rcv_extended, net_tcpv4_rcv,
79 probe_tcpv4_rcv_extended, "skb 0x%lX saddr #n4u%lu daddr #n4u%lu "
80 "tot_len #n2u%hu ihl #1u%u source #n2u%hu dest #n2u%hu seq #n4u%lu "
81 "ack_seq #n4u%lu doff #1u%u ack #1u%u rst #1u%u syn #1u%u fin #1u%u");
82
83notrace void probe_tcpv4_rcv_extended(void *_data, struct sk_buff *skb)
84{
85 struct marker *marker;
86 struct serialize_l4421224411111 data;
87 struct iphdr *iph = ip_hdr(skb);
88 struct tcphdr *th = tcp_hdr(skb);
89
90 data.f1 = (unsigned long)skb;
91 data.f2 = iph->saddr;
92 data.f3 = iph->daddr;
93 data.f4 = iph->tot_len;
94 data.f5 = iph->ihl;
95 data.f6 = th->source;
96 data.f7 = th->dest;
97 data.f8 = th->seq;
98 data.f9 = th->ack_seq;
99 data.f10 = th->doff;
100 data.f11 = th->ack;
101 data.f12 = th->rst;
102 data.f13 = th->syn;
103 data.f14 = th->fin;
104
105 marker = &GET_MARKER(net, tcpv4_rcv_extended);
106 ltt_specialized_trace(marker, marker->single.probe_private,
107 &data, serialize_sizeof(data), sizeof(long));
108}
109
110void probe_udpv4_rcv_extended(void *_data, struct sk_buff *skb);
111
112DEFINE_MARKER_TP(net, udpv4_rcv_extended, net_udpv4_rcv,
113 probe_udpv4_rcv_extended, "skb 0x%lX saddr #n4u%lu daddr #n4u%lu "
114 "unicast #1u%u ulen #n2u%hu source #n2u%hu dest #n2u%hu "
115 "data_start #8u%lx");
116
117notrace void probe_udpv4_rcv_extended(void *_data, struct sk_buff *skb)
118{
119 struct marker *marker;
120 struct serialize_l4412228 data;
121 struct iphdr *iph = ip_hdr(skb);
122 struct rtable *rt = skb_rtable(skb);
123 struct udphdr *uh = udp_hdr(skb);
124
125 data.f1 = (unsigned long)skb;
126 data.f2 = iph->saddr;
127 data.f3 = iph->daddr;
128 data.f4 = rt->rt_flags & (RTCF_BROADCAST | RTCF_MULTICAST) ? 0 : 1;
129 data.f5 = uh->len;
130 data.f6 = uh->source;
131 data.f7 = uh->dest;
132 /* UDP header has not been pulled from skb->data, read the first 8
133 * bytes of UDP data if they are not in a fragment*/
134 data.f8 = 0;
135 if (skb_headlen(skb) >= sizeof(struct udphdr) + 8)
136 data.f8 = *(unsigned long long *)(skb->data + sizeof(*uh));
137 else if (skb_headlen(skb) >= sizeof(struct udphdr))
138 memcpy(&data.f8, skb->data + sizeof(struct udphdr),
139 skb_headlen(skb) - sizeof(struct udphdr));
140
141 marker = &GET_MARKER(net, udpv4_rcv_extended);
142 ltt_specialized_trace(marker, marker->single.probe_private,
143 &data, serialize_sizeof(data), sizeof(unsigned long long));
144}
145
146MODULE_LICENSE("GPL and additional rights");
147MODULE_AUTHOR("Benjamin Poirier");
148MODULE_DESCRIPTION("Net Tracepoint Extended Probes");
This page took 0.027804 seconds and 4 git commands to generate.