1 /* SPDX-License-Identifier: GPL-2.0 */ 2 #undef TRACE_SYSTEM 3 #define TRACE_SYSTEM icmp 4 5 #if !defined(_TRACE_ICMP_H) || defined(TRACE_HEADER_MULTI_READ) 6 #define _TRACE_ICMP_H 7 8 #include <linux/icmp.h> 9 #include <linux/tracepoint.h> 10 11 TRACE_EVENT(icmp_send, 12 13 TP_PROTO(const struct sk_buff *skb, int type, int code), 14 15 TP_ARGS(skb, type, code), 16 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) 26 ), 27 28 TP_fast_assign( 29 struct iphdr *iph = ip_hdr(skb); 30 struct udphdr _uh, *uh = NULL; 31 __be32 *p32; 32 33 __entry->skbaddr = skb; 34 __entry->type = type; 35 __entry->code = code; 36 37 if (iph->protocol == IPPROTO_UDP) 38 uh = skb_header_pointer(skb, 39 skb_network_offset(skb) + 40 (iph->ihl << 2), 41 sizeof(_uh), &_uh); 42 43 if (!uh) { 44 __entry->sport = 0; 45 __entry->dport = 0; 46 __entry->ulen = 0; 47 } else { 48 __entry->sport = ntohs(uh->source); 49 __entry->dport = ntohs(uh->dest); 50 __entry->ulen = udp_get_len_short(uh); 51 } 52 53 p32 = (__be32 *) __entry->saddr; 54 *p32 = iph->saddr; 55 56 p32 = (__be32 *) __entry->daddr; 57 *p32 = iph->daddr; 58 ), 59 60 TP_printk("icmp_send: type=%d, code=%d. From %pI4:%u to %pI4:%u ulen=%d skbaddr=%p", 61 __entry->type, __entry->code, 62 __entry->saddr, __entry->sport, __entry->daddr, 63 __entry->dport, __entry->ulen, __entry->skbaddr) 64 ); 65 66 #endif /* _TRACE_ICMP_H */ 67 68 /* This part must be outside protection */ 69 #include <trace/define_trace.h> 70 71