Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 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 | |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 15 | TP_PROTO(const struct net *net, const struct fib6_info *f6i, |
Paolo Abeni | b65f164 | 2017-10-19 09:31:43 +0200 | [diff] [blame] | 16 | struct fib6_table *table, const struct flowi6 *flp), |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 17 | |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 18 | TP_ARGS(net, f6i, table, flp), |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 19 | |
| 20 | TP_STRUCT__entry( |
| 21 | __field( u32, tb_id ) |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 22 | __field( int, err ) |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 23 | __field( int, oif ) |
| 24 | __field( int, iif ) |
| 25 | __field( __u8, tos ) |
| 26 | __field( __u8, scope ) |
| 27 | __field( __u8, flags ) |
| 28 | __array( __u8, src, 16 ) |
| 29 | __array( __u8, dst, 16 ) |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 30 | __field( u16, sport ) |
| 31 | __field( u16, dport ) |
| 32 | __field( u8, proto ) |
| 33 | __field( u8, rt_type ) |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 34 | __dynamic_array( char, name, IFNAMSIZ ) |
| 35 | __array( __u8, gw, 16 ) |
| 36 | ), |
| 37 | |
| 38 | TP_fast_assign( |
| 39 | struct in6_addr *in6; |
| 40 | |
Paolo Abeni | b65f164 | 2017-10-19 09:31:43 +0200 | [diff] [blame] | 41 | __entry->tb_id = table->tb6_id; |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 42 | __entry->err = ip6_rt_type_to_error(f6i->fib6_type); |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 43 | __entry->oif = flp->flowi6_oif; |
| 44 | __entry->iif = flp->flowi6_iif; |
Daniel Borkmann | 69716a2 | 2016-03-18 18:37:59 +0100 | [diff] [blame] | 45 | __entry->tos = ip6_tclass(flp->flowlabel); |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 46 | __entry->scope = flp->flowi6_scope; |
| 47 | __entry->flags = flp->flowi6_flags; |
| 48 | |
| 49 | in6 = (struct in6_addr *)__entry->src; |
| 50 | *in6 = flp->saddr; |
| 51 | |
| 52 | in6 = (struct in6_addr *)__entry->dst; |
| 53 | *in6 = flp->daddr; |
| 54 | |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 55 | __entry->proto = flp->flowi6_proto; |
| 56 | if (__entry->proto == IPPROTO_TCP || |
| 57 | __entry->proto == IPPROTO_UDP) { |
| 58 | __entry->sport = ntohs(flp->fl6_sport); |
| 59 | __entry->dport = ntohs(flp->fl6_dport); |
| 60 | } else { |
| 61 | __entry->sport = 0; |
| 62 | __entry->dport = 0; |
| 63 | } |
| 64 | |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 65 | if (f6i->fib6_nh.nh_dev) { |
| 66 | __assign_str(name, f6i->fib6_nh.nh_dev); |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 67 | } else { |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 68 | __assign_str(name, "-"); |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 69 | } |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 70 | if (f6i == net->ipv6.fib6_null_entry) { |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 71 | struct in6_addr in6_zero = {}; |
| 72 | |
| 73 | in6 = (struct in6_addr *)__entry->gw; |
| 74 | *in6 = in6_zero; |
| 75 | |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 76 | } else if (f6i) { |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 77 | in6 = (struct in6_addr *)__entry->gw; |
David Ahern | d4bea42 | 2018-05-09 20:34:24 -0700 | [diff] [blame] | 78 | *in6 = f6i->fib6_nh.nh_gw; |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 79 | } |
| 80 | ), |
| 81 | |
David Ahern | 30d444d | 2018-05-23 17:08:48 -0700 | [diff] [blame^] | 82 | TP_printk("table %3u oif %d iif %d proto %u %pI6c/%u -> %pI6c/%u tos %d scope %d flags %x ==> dev %s gw %pI6c err %d", |
| 83 | __entry->tb_id, __entry->oif, __entry->iif, __entry->proto, |
| 84 | __entry->src, __entry->sport, __entry->dst, __entry->dport, |
| 85 | __entry->tos, __entry->scope, __entry->flags, |
| 86 | __get_str(name), __entry->gw, __entry->err) |
David Ahern | b811580 | 2015-11-19 12:24:22 -0800 | [diff] [blame] | 87 | ); |
| 88 | |
| 89 | #endif /* _TRACE_FIB6_H */ |
| 90 | |
| 91 | /* This part must be outside protection */ |
| 92 | #include <trace/define_trace.h> |