xref: /openbmc/linux/include/trace/events/fib.h (revision 569820be)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 #undef TRACE_SYSTEM
3 #define TRACE_SYSTEM fib
4 
5 #if !defined(_TRACE_FIB_H) || defined(TRACE_HEADER_MULTI_READ)
6 #define _TRACE_FIB_H
7 
8 #include <linux/skbuff.h>
9 #include <linux/netdevice.h>
10 #include <net/ip_fib.h>
11 #include <linux/tracepoint.h>
12 
13 TRACE_EVENT(fib_table_lookup,
14 
15 	TP_PROTO(u32 tb_id, const struct flowi4 *flp,
16 		 const struct fib_nh_common *nhc, int err),
17 
18 	TP_ARGS(tb_id, flp, nhc, err),
19 
20 	TP_STRUCT__entry(
21 		__field(	u32,	tb_id		)
22 		__field(	int,	err		)
23 		__field(	int,	oif		)
24 		__field(	int,	iif		)
25 		__field(	u8,	proto		)
26 		__field(	__u8,	tos		)
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	)
33 		__field(	u16,	sport		)
34 		__field(	u16,	dport		)
35 		__array(char,  name,   IFNAMSIZ )
36 	),
37 
38 	TP_fast_assign(
39 		struct net_device *dev;
40 		struct in6_addr *in6;
41 		__be32 *p32;
42 
43 		__entry->tb_id = tb_id;
44 		__entry->err = err;
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;
50 
51 		p32 = (__be32 *) __entry->src;
52 		*p32 = flp->saddr;
53 
54 		p32 = (__be32 *) __entry->dst;
55 		*p32 = flp->daddr;
56 
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);
62 		} else {
63 			__entry->sport = 0;
64 			__entry->dport = 0;
65 		}
66 
67 		dev = nhc ? nhc->nhc_dev : NULL;
68 		strscpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ);
69 
70 		if (nhc) {
71 			if (nhc->nhc_gw_family == AF_INET) {
72 				p32 = (__be32 *) __entry->gw4;
73 				*p32 = nhc->nhc_gw.ipv4;
74 
75 				in6 = (struct in6_addr *)__entry->gw6;
76 				*in6 = in6addr_any;
77 			} else if (nhc->nhc_gw_family == AF_INET6) {
78 				p32 = (__be32 *) __entry->gw4;
79 				*p32 = 0;
80 
81 				in6 = (struct in6_addr *)__entry->gw6;
82 				*in6 = nhc->nhc_gw.ipv6;
83 			}
84 		} else {
85 			p32 = (__be32 *) __entry->gw4;
86 			*p32 = 0;
87 
88 			in6 = (struct in6_addr *)__entry->gw6;
89 			*in6 = in6addr_any;
90 		}
91 	),
92 
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)
98 );
99 #endif /* _TRACE_FIB_H */
100 
101 /* This part must be outside protection */
102 #include <trace/define_trace.h>
103