| 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/flow.h> |
| 11 |
#include <net/inet_dscp.h> |
| 12 |
#include <net/ip_fib.h> |
| 13 |
#include <linux/tracepoint.h> |
| 14 |
|
| 15 |
TRACE_EVENT(fib_table_lookup, |
| 16 |
|
| 17 |
TP_PROTO(u32 tb_id, const struct flowi4 *flp, |
| 18 |
const struct fib_nh_common *nhc, int err), |
| 19 |
|
| 20 |
TP_ARGS(tb_id, flp, nhc, err), |
| 21 |
|
| 22 |
TP_STRUCT__entry( |
| 23 |
__field( u32, tb_id ) |
| 24 |
__field( int, err ) |
| 25 |
__field( int, oif ) |
| 26 |
__field( int, iif ) |
| 27 |
__field( u8, proto ) |
| 28 |
__field( __u8, tos ) |
| 29 |
__field( __u8, scope ) |
| 30 |
__field( __u8, flags ) |
| 31 |
__array( __u8, src, 4 ) |
| 32 |
__array( __u8, dst, 4 ) |
| 33 |
__array( __u8, gw4, 4 ) |
| 34 |
__array( __u8, gw6, 16 ) |
| 35 |
__field( u16, sport ) |
| 36 |
__field( u16, dport ) |
| 37 |
__array(char, name, IFNAMSIZ ) |
| 38 |
), |
| 39 |
|
| 40 |
TP_fast_assign( |
| 41 |
struct net_device *dev; |
| 42 |
struct in6_addr *in6; |
| 43 |
__be32 *p32; |
| 44 |
|
| 45 |
__entry->tb_id = tb_id; |
| 46 |
__entry->err = err; |
| 47 |
__entry->oif = flp->flowi4_oif; |
| 48 |
__entry->iif = flp->flowi4_iif; |
| 49 |
__entry->tos = inet_dscp_to_dsfield(flp->flowi4_dscp); |
| 50 |
__entry->scope = flp->flowi4_scope; |
| 51 |
__entry->flags = flp->flowi4_flags; |
| 52 |
|
| 53 |
p32 = (__be32 *) __entry->src; |
| 54 |
*p32 = flp->saddr; |
| 55 |
|
| 56 |
p32 = (__be32 *) __entry->dst; |
| 57 |
*p32 = flp->daddr; |
| 58 |
|
| 59 |
__entry->proto = flp->flowi4_proto; |
| 60 |
if (__entry->proto == IPPROTO_TCP || |
| 61 |
__entry->proto == IPPROTO_UDP) { |
| 62 |
__entry->sport = ntohs(flp->fl4_sport); |
| 63 |
__entry->dport = ntohs(flp->fl4_dport); |
| 64 |
} else { |
| 65 |
__entry->sport = 0; |
| 66 |
__entry->dport = 0; |
| 67 |
} |
| 68 |
|
| 69 |
dev = nhc ? nhc->nhc_dev : NULL; |
| 70 |
strscpy(__entry->name, dev ? dev->name : "-", IFNAMSIZ); |
| 71 |
|
| 72 |
if (nhc) { |
| 73 |
if (nhc->nhc_gw_family == AF_INET) { |
| 74 |
p32 = (__be32 *) __entry->gw4; |
| 75 |
*p32 = nhc->nhc_gw.ipv4; |
| 76 |
|
| 77 |
in6 = (struct in6_addr *)__entry->gw6; |
| 78 |
*in6 = in6addr_any; |
| 79 |
} else if (nhc->nhc_gw_family == AF_INET6) { |
| 80 |
p32 = (__be32 *) __entry->gw4; |
| 81 |
*p32 = 0; |
| 82 |
|
| 83 |
in6 = (struct in6_addr *)__entry->gw6; |
| 84 |
*in6 = nhc->nhc_gw.ipv6; |
| 85 |
} |
| 86 |
} else { |
| 87 |
p32 = (__be32 *) __entry->gw4; |
| 88 |
*p32 = 0; |
| 89 |
|
| 90 |
in6 = (struct in6_addr *)__entry->gw6; |
| 91 |
*in6 = in6addr_any; |
| 92 |
} |
| 93 |
), |
| 94 |
|
| 95 |
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", |
| 96 |
__entry->tb_id, __entry->oif, __entry->iif, __entry->proto, |
| 97 |
__entry->src, __entry->sport, __entry->dst, __entry->dport, |
| 98 |
__entry->tos, __entry->scope, __entry->flags, |
| 99 |
__entry->name, __entry->gw4, __entry->gw6, __entry->err) |
| 100 |
); |
| 101 |
#endif /* _TRACE_FIB_H */ |
| 102 |
|
| 103 |
/* This part must be outside protection */ |
| 104 |
#include <trace/define_trace.h> |