fib6.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #undef TRACE_SYSTEM
  3. #define TRACE_SYSTEM fib6
  4. #if !defined(_TRACE_FIB6_H) || defined(TRACE_HEADER_MULTI_READ)
  5. #define _TRACE_FIB6_H
  6. #include <linux/in6.h>
  7. #include <net/flow.h>
  8. #include <net/ip6_fib.h>
  9. #include <linux/tracepoint.h>
  10. TRACE_EVENT(fib6_table_lookup,
  11. TP_PROTO(const struct net *net, const struct fib6_result *res,
  12. struct fib6_table *table, const struct flowi6 *flp),
  13. TP_ARGS(net, res, table, flp),
  14. TP_STRUCT__entry(
  15. __field( u32, tb_id )
  16. __field( int, err )
  17. __field( int, oif )
  18. __field( int, iif )
  19. __field( u32, flowlabel )
  20. __field( __u8, tos )
  21. __field( __u8, scope )
  22. __field( __u8, flags )
  23. __array( __u8, src, 16 )
  24. __array( __u8, dst, 16 )
  25. __field( u16, sport )
  26. __field( u16, dport )
  27. __field( u8, proto )
  28. __field( u8, rt_type )
  29. __array( char, name, IFNAMSIZ )
  30. __array( __u8, gw, 16 )
  31. ),
  32. TP_fast_assign(
  33. struct in6_addr *in6;
  34. __entry->tb_id = table->tb6_id;
  35. __entry->err = ip6_rt_type_to_error(res->fib6_type);
  36. __entry->oif = flp->flowi6_oif;
  37. __entry->iif = flp->flowi6_iif;
  38. __entry->flowlabel = ntohl(flowi6_get_flowlabel(flp));
  39. __entry->tos = ip6_tclass(flp->flowlabel);
  40. __entry->scope = flp->flowi6_scope;
  41. __entry->flags = flp->flowi6_flags;
  42. in6 = (struct in6_addr *)__entry->src;
  43. *in6 = flp->saddr;
  44. in6 = (struct in6_addr *)__entry->dst;
  45. *in6 = flp->daddr;
  46. __entry->proto = flp->flowi6_proto;
  47. if (__entry->proto == IPPROTO_TCP ||
  48. __entry->proto == IPPROTO_UDP) {
  49. __entry->sport = ntohs(flp->fl6_sport);
  50. __entry->dport = ntohs(flp->fl6_dport);
  51. } else {
  52. __entry->sport = 0;
  53. __entry->dport = 0;
  54. }
  55. if (res->nh && res->nh->fib_nh_dev) {
  56. strscpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ);
  57. } else {
  58. strcpy(__entry->name, "-");
  59. }
  60. if (res->f6i == net->ipv6.fib6_null_entry) {
  61. in6 = (struct in6_addr *)__entry->gw;
  62. *in6 = in6addr_any;
  63. } else if (res->nh) {
  64. in6 = (struct in6_addr *)__entry->gw;
  65. *in6 = res->nh->fib_nh_gw6;
  66. }
  67. ),
  68. TP_printk("table %3u oif %d iif %d proto %u %pI6c/%u -> %pI6c/%u flowlabel %#x tos %d scope %d flags %x ==> dev %s gw %pI6c err %d",
  69. __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
  70. __entry->src, __entry->sport, __entry->dst, __entry->dport,
  71. __entry->flowlabel, __entry->tos, __entry->scope,
  72. __entry->flags, __entry->name, __entry->gw, __entry->err)
  73. );
  74. #endif /* _TRACE_FIB6_H */
  75. /* This part must be outside protection */
  76. #include <trace/define_trace.h>