Update ring buffer and pretty print
[lttng-modules.git] / deprecated / probes / net-trace.c
CommitLineData
1c8284eb
MD
1/*
2 * ltt/probes/net-trace.c
3 *
4 * Net tracepoint probes.
5 *
6 * (C) Copyright 2009 - Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
7 * Dual LGPL v2.1/GPL v2 license.
8 */
9
10#include <linux/module.h>
11#include <linux/netdevice.h>
12#include <linux/string.h>
13#include <trace/net.h>
14#include <trace/ipv4.h>
15#include <trace/ipv6.h>
16#include <trace/socket.h>
17
18#include "../ltt-type-serializer.h"
19
20void probe_net_dev_xmit(void *_data, struct sk_buff *skb);
21
22DEFINE_MARKER_TP(net, dev_xmit, net_dev_xmit, probe_net_dev_xmit,
23 "skb %p protocol #n2u%hu");
24
25notrace void probe_net_dev_xmit(void *_data, struct sk_buff *skb)
26{
27 struct marker *marker;
28 struct serialize_long_short data;
29
30 data.f1 = (unsigned long)skb;
31 data.f2 = skb->protocol;
32
33 marker = &GET_MARKER(net, dev_xmit);
34 ltt_specialized_trace(marker, marker->single.probe_private,
35 &data, serialize_sizeof(data), sizeof(long));
36}
37
38void probe_net_dev_receive(void *_data, struct sk_buff *skb);
39
40DEFINE_MARKER_TP(net, dev_receive, net_dev_receive, probe_net_dev_receive,
41 "skb %p protocol #n2u%hu");
42
43notrace void probe_net_dev_receive(void *_data, struct sk_buff *skb)
44{
45 struct marker *marker;
46 struct serialize_long_short data;
47
48 data.f1 = (unsigned long)skb;
49 data.f2 = skb->protocol;
50
51 marker = &GET_MARKER(net, dev_receive);
52 ltt_specialized_trace(marker, marker->single.probe_private,
53 &data, serialize_sizeof(data), sizeof(long));
54}
55
56void probe_ipv4_addr_add(void *_data, struct in_ifaddr *ifa)
57{
58 trace_mark_tp(netif_state, insert_ifa_ipv4, ipv4_addr_add,
59 probe_ipv4_addr_add, "label %s address #4u%u",
60 ifa->ifa_label, (unsigned int)ifa->ifa_address);
61}
62
63void probe_ipv4_addr_del(void *_data, struct in_ifaddr *ifa)
64{
65 trace_mark_tp(netif_state, del_ifa_ipv4, ipv4_addr_del,
66 probe_ipv4_addr_del, "label %s address #4u%u",
67 ifa->ifa_label, (unsigned int)ifa->ifa_address);
68}
69
70void probe_ipv6_addr_add(void *_data, struct inet6_ifaddr *ifa)
71{
72 __u8 *addr = ifa->addr.s6_addr;
73
74 trace_mark_tp(netif_state, insert_ifa_ipv6, ipv6_addr_add,
75 probe_ipv6_addr_add,
76 "label %s "
77 "a15 #1x%c a14 #1x%c a13 #1x%c a12 #1x%c "
78 "a11 #1x%c a10 #1x%c a9 #1x%c a8 #1x%c "
79 "a7 #1x%c a6 #1x%c a5 #1x%c a4 #1x%c "
80 "a3 #1x%c a2 #1x%c a1 #1x%c a0 #1x%c",
81 ifa->idev->dev->name,
82 addr[15], addr[14], addr[13], addr[12],
83 addr[11], addr[10], addr[9], addr[8],
84 addr[7], addr[6], addr[5], addr[4],
85 addr[3], addr[2], addr[1], addr[0]);
86}
87
88void probe_ipv6_addr_del(void *_data, struct inet6_ifaddr *ifa)
89{
90 __u8 *addr = ifa->addr.s6_addr;
91
92 trace_mark_tp(netif_state, insert_ifa_ipv6, ipv6_addr_del,
93 probe_ipv6_addr_del,
94 "label %s "
95 "a15 #1x%c a14 #1x%c a13 #1x%c a12 #1x%c "
96 "a11 #1x%c a10 #1x%c a9 #1x%c a8 #1x%c "
97 "a7 #1x%c a6 #1x%c a5 #1x%c a4 #1x%c "
98 "a3 #1x%c a2 #1x%c a1 #1x%c a0 #1x%c",
99 ifa->idev->dev->name,
100 addr[15], addr[14], addr[13], addr[12],
101 addr[11], addr[10], addr[9], addr[8],
102 addr[7], addr[6], addr[5], addr[4],
103 addr[3], addr[2], addr[1], addr[0]);
104}
105
106void probe_socket_create(void *_data, int family, int type, int protocol,
107 struct socket *sock, int ret)
108{
109 trace_mark_tp(net, socket_create, socket_create, probe_socket_create,
110 "family %d type %d protocol %d sock %p ret %d",
111 family, type, protocol, sock, ret);
112}
113
114void probe_socket_bind(void *_data, int fd, struct sockaddr __user *umyaddr, int addrlen,
115 int ret)
116{
117 trace_mark_tp(net, socket_bind, socket_bind, probe_socket_bind,
118 "fd %d umyaddr %p addrlen %d ret %d",
119 fd, umyaddr, addrlen, ret);
120}
121
122void probe_socket_connect(void *_data, int fd, struct sockaddr __user *uservaddr,
123 int addrlen, int ret)
124{
125 trace_mark_tp(net, socket_connect, socket_connect, probe_socket_connect,
126 "fd %d uservaddr %p addrlen %d ret %d",
127 fd, uservaddr, addrlen, ret);
128}
129
130void probe_socket_listen(void *_data, int fd, int backlog, int ret)
131{
132 trace_mark_tp(net, socket_listen, socket_listen, probe_socket_listen,
133 "fd %d backlog %d ret %d",
134 fd, backlog, ret);
135}
136
137void probe_socket_accept(void *_data, int fd, struct sockaddr __user *upeer_sockaddr,
138 int __user *upeer_addrlen, int flags, int ret)
139{
140 trace_mark_tp(net, socket_accept, socket_accept, probe_socket_accept,
141 "fd %d upeer_sockaddr %p upeer_addrlen %p flags %d ret %d",
142 fd, upeer_sockaddr, upeer_addrlen, flags, ret);
143}
144
145void probe_socket_getsockname(void *_data, int fd, struct sockaddr __user *usockaddr,
146 int __user *usockaddr_len, int ret)
147{
148 trace_mark_tp(net, socket_getsockname, socket_getsockname,
149 probe_socket_getsockname,
150 "fd %d usockaddr %p usockaddr_len %p ret %d",
151 fd, usockaddr, usockaddr_len, ret);
152}
153
154void probe_socket_getpeername(void *_data, int fd, struct sockaddr __user *usockaddr,
155 int __user *usockaddr_len, int ret)
156{
157 trace_mark_tp(net, socket_getpeername, socket_getpeername,
158 probe_socket_getpeername,
159 "fd %d usockaddr %p usockaddr_len %p ret %d",
160 fd, usockaddr, usockaddr_len, ret);
161}
162
163void probe_socket_socketpair(void *_data, int family, int type, int protocol,
164 int __user *usockvec, int ret)
165{
166 trace_mark_tp(net, socket_socketpair, socket_socketpair,
167 probe_socket_socketpair,
168 "family %d type %d protocol %d usockvec %p ret %d",
169 family, type, protocol, usockvec, ret);
170}
171
172void probe_socket_sendmsg(void *_data, struct socket *sock, struct msghdr *msg, size_t size,
173 int ret);
174
175DEFINE_MARKER_TP(net, socket_sendmsg, net_socket_sendmsg,
176 probe_socket_sendmsg,
177 "sock %p msg %p size %zu ret %d");
178
179notrace void probe_socket_sendmsg(void *_data, struct socket *sock, struct msghdr *msg,
180 size_t size, int ret)
181{
182 struct marker *marker;
183 struct serialize_long_long_sizet_int data;
184
185 data.f1 = (unsigned long)sock;
186 data.f2 = (unsigned long)msg;
187 data.f3 = size;
188 data.f4 = ret;
189
190 marker = &GET_MARKER(net, socket_sendmsg);
191 ltt_specialized_trace(marker, marker->single.probe_private,
192 &data, serialize_sizeof(data), sizeof(size_t));
193}
194
195void probe_socket_recvmsg(void *_data, struct socket *sock, struct msghdr *msg, size_t size,
196 int flags, int ret);
197
198DEFINE_MARKER_TP(net, socket_recvmsg, net_socket_recvmsg,
199 probe_socket_recvmsg,
200 "sock %p msg %p size %zu flags %d ret %d");
201
202notrace void probe_socket_recvmsg(void *_data, struct socket *sock, struct msghdr *msg,
203 size_t size, int flags, int ret)
204{
205 struct marker *marker;
206 struct serialize_long_long_sizet_int_int data;
207
208 data.f1 = (unsigned long)sock;
209 data.f2 = (unsigned long)msg;
210 data.f3 = size;
211 data.f4 = flags;
212 data.f5 = ret;
213
214 marker = &GET_MARKER(net, socket_recvmsg);
215 ltt_specialized_trace(marker, marker->single.probe_private,
216 &data, serialize_sizeof(data), sizeof(size_t));
217}
218
219void probe_socket_setsockopt(void *_data, int fd, int level, int optname,
220 char __user *optval, int optlen, int ret)
221{
222 trace_mark_tp(net, socket_setsockopt, socket_setsockopt,
223 probe_socket_setsockopt,
224 "fd %d level %d optname %d optval %p optlen %d ret %d",
225 fd, level, optname, optval, optlen, ret);
226}
227
228void probe_socket_getsockopt(void *_data, int fd, int level, int optname,
229 char __user *optval, int __user *optlen, int ret)
230{
231 trace_mark_tp(net, socket_getsockopt, socket_getsockopt,
232 probe_socket_getsockopt,
233 "fd %d level %d optname %d optval %p optlen %p ret %d",
234 fd, level, optname, optval, optlen, ret);
235}
236
237void probe_socket_shutdown(void *_data, int fd, int how, int ret)
238{
239 trace_mark_tp(net, socket_shutdown, socket_shutdown,
240 probe_socket_shutdown,
241 "fd %d how %d ret %d",
242 fd, how, ret);
243}
244
245void probe_socket_call(void *_data, int call, unsigned long a0)
246{
247 trace_mark_tp(net, socket_call, socket_call, probe_socket_call,
248 "call %d a0 %lu", call, a0);
249}
250
251void probe_tcpv4_rcv(void *_data, struct sk_buff *skb);
252
253DEFINE_MARKER_TP(net, tcpv4_rcv, net_tcpv4_rcv, probe_tcpv4_rcv,
254 "skb %p");
255
256notrace void probe_tcpv4_rcv(void *_data, struct sk_buff *skb)
257{
258 struct marker *marker;
259
260 marker = &GET_MARKER(net, tcpv4_rcv);
261 ltt_specialized_trace(marker, marker->single.probe_private,
262 &skb, sizeof(skb), sizeof(skb));
263}
264
265void probe_udpv4_rcv(void *_data, struct sk_buff *skb);
266
267DEFINE_MARKER_TP(net, udpv4_rcv, net_udpv4_rcv, probe_udpv4_rcv,
268 "skb %p");
269
270notrace void probe_udpv4_rcv(void *_data, struct sk_buff *skb)
271{
272 struct marker *marker;
273
274 marker = &GET_MARKER(net, udpv4_rcv);
275 ltt_specialized_trace(marker, marker->single.probe_private,
276 &skb, sizeof(skb), sizeof(skb));
277}
278
279#ifdef CONFIG_NETPOLL
280void probe_net_napi_schedule(void *_data, struct napi_struct *n);
281
282DEFINE_MARKER_TP(net, napi_schedule, net_napi_schedule,
283 probe_net_napi_schedule,
284 "napi_struct %p name %s");
285
286notrace void probe_net_napi_schedule(void *_data, struct napi_struct *n)
287{
288 struct marker *marker;
289 struct serialize_long_ifname data;
290 size_t data_len = 0;
291
292 data.f1 = (unsigned long)n;
293 data_len += sizeof(data.f1);
294 /* No need to align for strings */
295 strcpy(data.f2, n->dev ? n->dev->name : "<unk>");
296 data_len += strlen(data.f2) + 1;
297
298 marker = &GET_MARKER(net, napi_schedule);
299 ltt_specialized_trace(marker, marker->single.probe_private,
300 &data, data_len, sizeof(long));
301}
302
303void probe_net_napi_poll(void *_data, struct napi_struct *n);
304
305DEFINE_MARKER_TP(net, napi_poll, net_napi_poll,
306 probe_net_napi_poll,
307 "napi_struct %p name %s");
308
309notrace void probe_net_napi_poll(void *_data, struct napi_struct *n)
310{
311 struct marker *marker;
312 struct serialize_long_ifname data;
313 size_t data_len = 0;
314
315 data.f1 = (unsigned long)n;
316 data_len += sizeof(data.f1);
317 /* No need to align for strings */
318 strcpy(data.f2, n->dev ? n->dev->name : "<unk>");
319 data_len += strlen(data.f2) + 1;
320
321 marker = &GET_MARKER(net, napi_poll);
322 ltt_specialized_trace(marker, marker->single.probe_private,
323 &data, data_len, sizeof(long));
324}
325
326void probe_net_napi_complete(void *_data, struct napi_struct *n);
327
328DEFINE_MARKER_TP(net, napi_complete, net_napi_complete,
329 probe_net_napi_complete,
330 "napi_struct %p name %s");
331
332notrace void probe_net_napi_complete(void *_data, struct napi_struct *n)
333{
334 struct marker *marker;
335 struct serialize_long_ifname data;
336 size_t data_len = 0;
337
338 data.f1 = (unsigned long)n;
339 data_len += sizeof(data.f1);
340 /* No need to align for strings */
341 strcpy(data.f2, n->dev ? n->dev->name : "<unk>");
342 data_len += strlen(data.f2) + 1;
343
344 marker = &GET_MARKER(net, napi_complete);
345 ltt_specialized_trace(marker, marker->single.probe_private,
346 &data, data_len, sizeof(long));
347}
348#else /* !CONFIG_NETPOLL */
349void probe_net_napi_schedule(void *_data, struct napi_struct *n);
350
351DEFINE_MARKER_TP(net, napi_schedule, net_napi_schedule,
352 probe_net_napi_schedule,
353 "napi_struct %p");
354
355notrace void probe_net_napi_schedule(void *_data, struct napi_struct *n)
356{
357 struct marker *marker;
358 unsigned long data;
359
360 data = (unsigned long)n;
361
362 marker = &GET_MARKER(net, napi_schedule);
363 ltt_specialized_trace(marker, marker->single.probe_private,
364 &data, sizeof(data), sizeof(data));
365}
366
367void probe_net_napi_poll(void *_data, struct napi_struct *n);
368
369DEFINE_MARKER_TP(net, napi_poll, net_napi_poll,
370 probe_net_napi_poll,
371 "napi_struct %p");
372
373notrace void probe_net_napi_poll(void *_data, struct napi_struct *n)
374{
375 struct marker *marker;
376 unsigned long data;
377
378 data = (unsigned long)n;
379
380 marker = &GET_MARKER(net, napi_poll);
381 ltt_specialized_trace(marker, marker->single.probe_private,
382 &data, sizeof(data), sizeof(data));
383}
384
385void probe_net_napi_complete(void *_data, struct napi_struct *n);
386
387DEFINE_MARKER_TP(net, napi_complete, net_napi_complete,
388 probe_net_napi_complete,
389 "napi_struct %p");
390
391notrace void probe_net_napi_complete(void *_data, struct napi_struct *n)
392{
393 struct marker *marker;
394 unsigned long data;
395
396 data = (unsigned long)n;
397
398 marker = &GET_MARKER(net, napi_complete);
399 ltt_specialized_trace(marker, marker->single.probe_private,
400 &data, sizeof(data), sizeof(data));
401}
402#endif
403
404MODULE_LICENSE("GPL and additional rights");
405MODULE_AUTHOR("Mathieu Desnoyers");
406MODULE_DESCRIPTION("Net Tracepoint Probes");
This page took 0.069658 seconds and 4 git commands to generate.