fib.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM fib
  4. #if !defined(_TRACE_FIB_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_FIB_H
  6. #include <linux/skbuff.h>
  7. #include <linux/netdevice.h>
  8. #include <net/ip_fib.h>
  9. #include <linux/tracepoint.h>
  10. TRACE_EVENT(fib_table_lookup,
  11. TP_PROTO(u32 tb_id, const struct flowi4 *flp,
  12. const struct fib_nh *nh, int err),
  13. TP_ARGS(tb_id, flp, nh, err),
  14. TP_STRUCT__entry(
  15. __field( u32, tb_id )
  16. __field( int, err )
  17. __field( int, oif )
  18. __field( int, iif )
  19. __field( u8, proto )
  20. __field( __u8, tos )
  21. __field( __u8, scope )
  22. __field( __u8, flags )
  23. __array( __u8, src, 4 )
  24. __array( __u8, dst, 4 )
  25. __array( __u8, gw, 4 )
  26. __array( __u8, saddr, 4 )
  27. __field( u16, sport )
  28. __field( u16, dport )
  29. __dynamic_array(char, name, IFNAMSIZ )
  30. ),
  31. TP_fast_assign(
  32. __be32 *p32;
  33. __entry->tb_id = tb_id;
  34. __entry->err = err;
  35. __entry->oif = flp->flowi4_oif;
  36. __entry->iif = flp->flowi4_iif;
  37. __entry->tos = flp->flowi4_tos;
  38. __entry->scope = flp->flowi4_scope;
  39. __entry->flags = flp->flowi4_flags;
  40. p32 = (__be32 *) __entry->src;
  41. *p32 = flp->saddr;
  42. p32 = (__be32 *) __entry->dst;
  43. *p32 = flp->daddr;
  44. __entry->proto = flp->flowi4_proto;
  45. if (__entry->proto == IPPROTO_TCP ||
  46. __entry->proto == IPPROTO_UDP) {
  47. __entry->sport = ntohs(flp->fl4_sport);
  48. __entry->dport = ntohs(flp->fl4_dport);
  49. } else {
  50. __entry->sport = 0;
  51. __entry->dport = 0;
  52. }
  53. if (nh) {
  54. p32 = (__be32 *) __entry->saddr;
  55. *p32 = nh->nh_saddr;
  56. p32 = (__be32 *) __entry->gw;
  57. *p32 = nh->nh_gw;
  58. __assign_str(name, nh->nh_dev ? nh->nh_dev->name : "-");
  59. } else {
  60. p32 = (__be32 *) __entry->saddr;
  61. *p32 = 0;
  62. p32 = (__be32 *) __entry->gw;
  63. *p32 = 0;
  64. __assign_str(name, "-");
  65. }
  66. ),
  67. TP_printk("table %u oif %d iif %d proto %u %pI4/%u -> %pI4/%u tos %d scope %d flags %x ==> dev %s gw %pI4 src %pI4 err %d",
  68. __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
  69. __entry->src, __entry->sport, __entry->dst, __entry->dport,
  70. __entry->tos, __entry->scope, __entry->flags,
  71. __get_str(name), __entry->gw, __entry->saddr, __entry->err)
  72. );
  73. #endif /* _TRACE_FIB_H */
  74. /* This part must be outside protection */
  75. #include <trace/define_trace.h>