| 1 | /* SPDX-License-Identifier: GPL-2.0 */ | 
|---|
| 2 | #undef TRACE_SYSTEM | 
|---|
| 3 | #define TRACE_SYSTEM fib6 | 
|---|
| 4 |  | 
|---|
| 5 | #if !defined(_TRACE_FIB6_H) || defined(TRACE_HEADER_MULTI_READ) | 
|---|
| 6 | #define _TRACE_FIB6_H | 
|---|
| 7 |  | 
|---|
| 8 | #include <linux/in6.h> | 
|---|
| 9 | #include <net/flow.h> | 
|---|
| 10 | #include <net/ip6_fib.h> | 
|---|
| 11 | #include <linux/tracepoint.h> | 
|---|
| 12 |  | 
|---|
| 13 | TRACE_EVENT(fib6_table_lookup, | 
|---|
| 14 |  | 
|---|
| 15 | TP_PROTO(const struct net *net, const struct fib6_result *res, | 
|---|
| 16 | struct fib6_table *table, const struct flowi6 *flp), | 
|---|
| 17 |  | 
|---|
| 18 | TP_ARGS(net, res, table, flp), | 
|---|
| 19 |  | 
|---|
| 20 | TP_STRUCT__entry( | 
|---|
| 21 | __field(	u32,	tb_id		) | 
|---|
| 22 | __field(	int,	err		) | 
|---|
| 23 | __field(	int,	oif		) | 
|---|
| 24 | __field(	int,	iif		) | 
|---|
| 25 | __field(	u32,	flowlabel	) | 
|---|
| 26 | __field(	__u8,	tos		) | 
|---|
| 27 | __field(	__u8,	scope		) | 
|---|
| 28 | __field(	__u8,	flags		) | 
|---|
| 29 | __array(	__u8,	src,	16	) | 
|---|
| 30 | __array(	__u8,	dst,	16	) | 
|---|
| 31 | __field(        u16,	sport		) | 
|---|
| 32 | __field(        u16,	dport		) | 
|---|
| 33 | __field(        u8,	proto		) | 
|---|
| 34 | __field(        u8,	rt_type		) | 
|---|
| 35 | __array(		char,	name,	IFNAMSIZ ) | 
|---|
| 36 | __array(		__u8,	gw,	16	 ) | 
|---|
| 37 | ), | 
|---|
| 38 |  | 
|---|
| 39 | TP_fast_assign( | 
|---|
| 40 | struct in6_addr *in6; | 
|---|
| 41 |  | 
|---|
| 42 | __entry->tb_id = table->tb6_id; | 
|---|
| 43 | __entry->err = ip6_rt_type_to_error(res->fib6_type); | 
|---|
| 44 | __entry->oif = flp->flowi6_oif; | 
|---|
| 45 | __entry->iif = flp->flowi6_iif; | 
|---|
| 46 | __entry->flowlabel = ntohl(flowi6_get_flowlabel(flp)); | 
|---|
| 47 | __entry->tos = ip6_tclass(flp->flowlabel); | 
|---|
| 48 | __entry->scope = flp->flowi6_scope; | 
|---|
| 49 | __entry->flags = flp->flowi6_flags; | 
|---|
| 50 |  | 
|---|
| 51 | in6 = (struct in6_addr *)__entry->src; | 
|---|
| 52 | *in6 = flp->saddr; | 
|---|
| 53 |  | 
|---|
| 54 | in6 = (struct in6_addr *)__entry->dst; | 
|---|
| 55 | *in6 = flp->daddr; | 
|---|
| 56 |  | 
|---|
| 57 | __entry->proto = flp->flowi6_proto; | 
|---|
| 58 | if (__entry->proto == IPPROTO_TCP || | 
|---|
| 59 | __entry->proto == IPPROTO_UDP) { | 
|---|
| 60 | __entry->sport = ntohs(flp->fl6_sport); | 
|---|
| 61 | __entry->dport = ntohs(flp->fl6_dport); | 
|---|
| 62 | } else { | 
|---|
| 63 | __entry->sport = 0; | 
|---|
| 64 | __entry->dport = 0; | 
|---|
| 65 | } | 
|---|
| 66 |  | 
|---|
| 67 | if (res->nh && res->nh->fib_nh_dev) { | 
|---|
| 68 | strscpy(__entry->name, res->nh->fib_nh_dev->name, IFNAMSIZ); | 
|---|
| 69 | } else { | 
|---|
| 70 | strcpy(__entry->name, "-"); | 
|---|
| 71 | } | 
|---|
| 72 | if (res->f6i == net->ipv6.fib6_null_entry) { | 
|---|
| 73 | in6 = (struct in6_addr *)__entry->gw; | 
|---|
| 74 | *in6 = in6addr_any; | 
|---|
| 75 | } else if (res->nh) { | 
|---|
| 76 | in6 = (struct in6_addr *)__entry->gw; | 
|---|
| 77 | *in6 = res->nh->fib_nh_gw6; | 
|---|
| 78 | } | 
|---|
| 79 | ), | 
|---|
| 80 |  | 
|---|
| 81 | TP_printk( "table %3u oif %d iif %d proto %u %pI6c/%u -> %pI6c/%u flowlabel %#x tos %d scope %d flags %x ==> dev %s gw %pI6c err %d", | 
|---|
| 82 | __entry->tb_id, __entry->oif, __entry->iif, __entry->proto, | 
|---|
| 83 | __entry->src, __entry->sport, __entry->dst, __entry->dport, | 
|---|
| 84 | __entry->flowlabel, __entry->tos, __entry->scope, | 
|---|
| 85 | __entry->flags, __entry->name, __entry->gw, __entry->err) | 
|---|
| 86 | ); | 
|---|
| 87 |  | 
|---|
| 88 | #endif /* _TRACE_FIB6_H */ | 
|---|
| 89 |  | 
|---|
| 90 | /* This part must be outside protection */ | 
|---|
| 91 | #include <trace/define_trace.h> | 
|---|
| 92 |  | 
|---|