Merge tag 'trace-printf-v6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/trace...
[drm/drm-misc.git] / include / trace / events / icmp.h
blob31559796949a783f24c07c737cf971a598e255a3
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM icmp
5 #if !defined(_TRACE_ICMP_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_ICMP_H
8 #include <linux/icmp.h>
9 #include <linux/tracepoint.h>
11 TRACE_EVENT(icmp_send,
13 TP_PROTO(const struct sk_buff *skb, int type, int code),
15 TP_ARGS(skb, type, code),
17 TP_STRUCT__entry(
18 __field(const void *, skbaddr)
19 __field(int, type)
20 __field(int, code)
21 __array(__u8, saddr, 4)
22 __array(__u8, daddr, 4)
23 __field(__u16, sport)
24 __field(__u16, dport)
25 __field(unsigned short, ulen)
28 TP_fast_assign(
29 struct iphdr *iph = ip_hdr(skb);
30 struct udphdr *uh = udp_hdr(skb);
31 int proto_4 = iph->protocol;
32 __be32 *p32;
34 __entry->skbaddr = skb;
35 __entry->type = type;
36 __entry->code = code;
38 if (proto_4 != IPPROTO_UDP || (u8 *)uh < skb->head ||
39 (u8 *)uh + sizeof(struct udphdr)
40 > skb_tail_pointer(skb)) {
41 __entry->sport = 0;
42 __entry->dport = 0;
43 __entry->ulen = 0;
44 } else {
45 __entry->sport = ntohs(uh->source);
46 __entry->dport = ntohs(uh->dest);
47 __entry->ulen = ntohs(uh->len);
50 p32 = (__be32 *) __entry->saddr;
51 *p32 = iph->saddr;
53 p32 = (__be32 *) __entry->daddr;
54 *p32 = iph->daddr;
57 TP_printk("icmp_send: type=%d, code=%d. From %pI4:%u to %pI4:%u ulen=%d skbaddr=%p",
58 __entry->type, __entry->code,
59 __entry->saddr, __entry->sport, __entry->daddr,
60 __entry->dport, __entry->ulen, __entry->skbaddr)
63 #endif /* _TRACE_ICMP_H */
65 /* This part must be outside protection */
66 #include <trace/define_trace.h>