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 __array(char, name, IFNAMSIZ )
39 struct net_device *dev;
43 __entry->tb_id = tb_id;
45 __entry->oif = flp->flowi4_oif;
46 __entry->iif = flp->flowi4_iif;
47 __entry->tos = flp->flowi4_tos;
48 __entry->scope = flp->flowi4_scope;
49 __entry->flags = flp->flowi4_flags;
51 p32 = (__be32 *) __entry->src;
54 p32 = (__be32 *) __entry->dst;
57 __entry->proto = flp->flowi4_proto;
58 if (__entry->proto == IPPROTO_TCP ||
59 __entry->proto == IPPROTO_UDP) {
60 __entry->sport = ntohs(flp->fl4_sport);
61 __entry->dport = ntohs(flp->fl4_dport);
67 dev = nhc ? nhc->nhc_dev : NULL;
68 strscpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ);
71 if (nhc->nhc_gw_family == AF_INET) {
72 p32 = (__be32 *) __entry->gw4;
73 *p32 = nhc->nhc_gw.ipv4;
75 in6 = (struct in6_addr *)__entry->gw6;
77 } else if (nhc->nhc_gw_family == AF_INET6) {
78 p32 = (__be32 *) __entry->gw4;
81 in6 = (struct in6_addr *)__entry->gw6;
82 *in6 = nhc->nhc_gw.ipv6;
85 p32 = (__be32 *) __entry->gw4;
88 in6 = (struct in6_addr *)__entry->gw6;
93 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",
94 __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
95 __entry->src, __entry->sport, __entry->dst, __entry->dport,
96 __entry->tos, __entry->scope, __entry->flags,
97 __entry->name, __entry->gw4, __entry->gw6, __entry->err)
99 #endif /* _TRACE_FIB_H */
101 /* This part must be outside protection */
102 #include <trace/define_trace.h>