68 lines · c
1/* SPDX-License-Identifier: GPL-2.0 */2#undef TRACE_SYSTEM3#define TRACE_SYSTEM icmp4 5#if !defined(_TRACE_ICMP_H) || defined(TRACE_HEADER_MULTI_READ)6#define _TRACE_ICMP_H7 8#include <linux/icmp.h>9#include <linux/tracepoint.h>10 11TRACE_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 = udp_hdr(skb);31 int proto_4 = iph->protocol;32 __be32 *p32;33 34 __entry->skbaddr = skb;35 __entry->type = type;36 __entry->code = code;37 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);48 }49 50 p32 = (__be32 *) __entry->saddr;51 *p32 = iph->saddr;52 53 p32 = (__be32 *) __entry->daddr;54 *p32 = iph->daddr;55 ),56 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)61);62 63#endif /* _TRACE_ICMP_H */64 65/* This part must be outside protection */66#include <trace/define_trace.h>67 68