1 /* SPDX-License-Identifier: GPL-2.0 */
3 #define TRACE_SYSTEM fib
5 #if !defined(_TRACE_FIB_H) || defined(TRACE_HEADER_MULTI_READ)
8 #include <linux/skbuff.h>
9 #include <linux/netdevice.h>
10 #include <net/ip_fib.h>
11 #include <linux/tracepoint.h>
13 TRACE_EVENT(fib_table_lookup
,
15 TP_PROTO(u32 tb_id
, const struct flowi4
*flp
,
16 const struct fib_nh_common
*nhc
, int err
),
18 TP_ARGS(tb_id
, flp
, nhc
, err
),
27 __field( __u8
, scope
)
28 __field( __u8
, flags
)
29 __array( __u8
, src
, 4 )
30 __array( __u8
, dst
, 4 )
31 __array( __u8
, gw4
, 4 )
32 __array( __u8
, gw6
, 16 )
35 __dynamic_array(char, name
, IFNAMSIZ
)
39 struct in6_addr in6_zero
= {};
40 struct net_device
*dev
;
44 __entry
->tb_id
= tb_id
;
46 __entry
->oif
= flp
->flowi4_oif
;
47 __entry
->iif
= flp
->flowi4_iif
;
48 __entry
->tos
= flp
->flowi4_tos
;
49 __entry
->scope
= flp
->flowi4_scope
;
50 __entry
->flags
= flp
->flowi4_flags
;
52 p32
= (__be32
*) __entry
->src
;
55 p32
= (__be32
*) __entry
->dst
;
58 __entry
->proto
= flp
->flowi4_proto
;
59 if (__entry
->proto
== IPPROTO_TCP
||
60 __entry
->proto
== IPPROTO_UDP
) {
61 __entry
->sport
= ntohs(flp
->fl4_sport
);
62 __entry
->dport
= ntohs(flp
->fl4_dport
);
68 dev
= nhc
? nhc
->nhc_dev
: NULL
;
69 __assign_str(name
, dev
? dev
->name
: "-");
72 if (nhc
->nhc_gw_family
== AF_INET
) {
73 p32
= (__be32
*) __entry
->gw4
;
74 *p32
= nhc
->nhc_gw
.ipv4
;
76 in6
= (struct in6_addr
*)__entry
->gw6
;
78 } else if (nhc
->nhc_gw_family
== AF_INET6
) {
79 p32
= (__be32
*) __entry
->gw4
;
82 in6
= (struct in6_addr
*)__entry
->gw6
;
83 *in6
= nhc
->nhc_gw
.ipv6
;
86 p32
= (__be32
*) __entry
->gw4
;
89 in6
= (struct in6_addr
*)__entry
->gw6
;
94 TP_printk("table %u oif %d iif %d proto %u %pI4/%u -> %pI4/%u tos %d scope %d flags %x ==> dev %s gw %pI4/%pI6c err %d",
95 __entry
->tb_id
, __entry
->oif
, __entry
->iif
, __entry
->proto
,
96 __entry
->src
, __entry
->sport
, __entry
->dst
, __entry
->dport
,
97 __entry
->tos
, __entry
->scope
, __entry
->flags
,
98 __get_str(name
), __entry
->gw4
, __entry
->gw6
, __entry
->err
)
100 #endif /* _TRACE_FIB_H */
102 /* This part must be outside protection */
103 #include <trace/define_trace.h>