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 *nh, int err), 17 18 TP_ARGS(tb_id, flp, nh, 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, tos ) 26 __field( __u8, scope ) 27 __field( __u8, flags ) 28 __array( __u8, src, 4 ) 29 __array( __u8, dst, 4 ) 30 __array( __u8, gw, 4 ) 31 __array( __u8, saddr, 4 ) 32 __field( u16, sport ) 33 __field( u16, dport ) 34 __field( u8, proto ) 35 __dynamic_array(char, name, IFNAMSIZ ) 36 ), 37 38 TP_fast_assign( 39 __be32 *p32; 40 41 __entry->tb_id = tb_id; 42 __entry->err = err; 43 __entry->oif = flp->flowi4_oif; 44 __entry->iif = flp->flowi4_iif; 45 __entry->tos = flp->flowi4_tos; 46 __entry->scope = flp->flowi4_scope; 47 __entry->flags = flp->flowi4_flags; 48 49 p32 = (__be32 *) __entry->src; 50 *p32 = flp->saddr; 51 52 p32 = (__be32 *) __entry->dst; 53 *p32 = flp->daddr; 54 55 __entry->proto = flp->flowi4_proto; 56 if (__entry->proto == IPPROTO_TCP || 57 __entry->proto == IPPROTO_UDP) { 58 __entry->sport = ntohs(flp->fl4_sport); 59 __entry->dport = ntohs(flp->fl4_dport); 60 } else { 61 __entry->sport = 0; 62 __entry->dport = 0; 63 } 64 65 if (nh) { 66 p32 = (__be32 *) __entry->saddr; 67 *p32 = nh->nh_saddr; 68 69 p32 = (__be32 *) __entry->gw; 70 *p32 = nh->nh_gw; 71 72 __assign_str(name, nh->nh_dev ? nh->nh_dev->name : "-"); 73 } else { 74 p32 = (__be32 *) __entry->saddr; 75 *p32 = 0; 76 77 p32 = (__be32 *) __entry->gw; 78 *p32 = 0; 79 80 __assign_str(name, "-"); 81 } 82 ), 83 84 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", 85 __entry->tb_id, __entry->oif, __entry->iif, __entry->proto, 86 __entry->src, __entry->sport, __entry->dst, __entry->dport, 87 __entry->tos, __entry->scope, __entry->flags, 88 __get_str(name), __entry->gw, __entry->saddr, __entry->err) 89 ); 90 #endif /* _TRACE_FIB_H */ 91 92 /* This part must be outside protection */ 93 #include <trace/define_trace.h> 94