icmp.h 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM icmp
  4. #if !defined(_TRACE_ICMP_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_ICMP_H
  6. #include <linux/icmp.h>
  7. #include <linux/tracepoint.h>
  8. TRACE_EVENT(icmp_send,
  9. TP_PROTO(const struct sk_buff *skb, int type, int code),
  10. TP_ARGS(skb, type, code),
  11. TP_STRUCT__entry(
  12. __field(const void *, skbaddr)
  13. __field(int, type)
  14. __field(int, code)
  15. __array(__u8, saddr, 4)
  16. __array(__u8, daddr, 4)
  17. __field(__u16, sport)
  18. __field(__u16, dport)
  19. __field(unsigned short, ulen)
  20. ),
  21. TP_fast_assign(
  22. struct iphdr *iph = ip_hdr(skb);
  23. struct udphdr *uh = udp_hdr(skb);
  24. int proto_4 = iph->protocol;
  25. __be32 *p32;
  26. __entry->skbaddr = skb;
  27. __entry->type = type;
  28. __entry->code = code;
  29. if (proto_4 != IPPROTO_UDP || (u8 *)uh < skb->head ||
  30. (u8 *)uh + sizeof(struct udphdr)
  31. > skb_tail_pointer(skb)) {
  32. __entry->sport = 0;
  33. __entry->dport = 0;
  34. __entry->ulen = 0;
  35. } else {
  36. __entry->sport = ntohs(uh->source);
  37. __entry->dport = ntohs(uh->dest);
  38. __entry->ulen = ntohs(uh->len);
  39. }
  40. p32 = (__be32 *) __entry->saddr;
  41. *p32 = iph->saddr;
  42. p32 = (__be32 *) __entry->daddr;
  43. *p32 = iph->daddr;
  44. ),
  45. TP_printk("icmp_send: type=%d, code=%d. From %pI4:%u to %pI4:%u ulen=%d skbaddr=%p",
  46. __entry->type, __entry->code,
  47. __entry->saddr, __entry->sport, __entry->daddr,
  48. __entry->dport, __entry->ulen, __entry->skbaddr)
  49. );
  50. #endif /* _TRACE_ICMP_H */
  51. /* This part must be outside protection */
  52. #include <trace/define_trace.h>