blob: 6f2a4dc35e37eae4d302055d195ac2fc2b67089b [file] [log] [blame]
Andrew Scullb4b6d4a2019-01-02 15:54:55 +00001/* 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
13TRACE_EVENT(fib_table_lookup,
14
15 TP_PROTO(u32 tb_id, const struct flowi4 *flp,
David Brazdil0f672f62019-12-10 10:32:29 +000016 const struct fib_nh_common *nhc, int err),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000017
David Brazdil0f672f62019-12-10 10:32:29 +000018 TP_ARGS(tb_id, flp, nhc, err),
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000019
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 )
David Brazdil0f672f62019-12-10 10:32:29 +000031 __array( __u8, gw4, 4 )
32 __array( __u8, gw6, 16 )
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000033 __field( u16, sport )
34 __field( u16, dport )
35 __dynamic_array(char, name, IFNAMSIZ )
36 ),
37
38 TP_fast_assign(
David Brazdil0f672f62019-12-10 10:32:29 +000039 struct in6_addr in6_zero = {};
40 struct net_device *dev;
41 struct in6_addr *in6;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000042 __be32 *p32;
43
44 __entry->tb_id = tb_id;
45 __entry->err = err;
46 __entry->oif = flp->flowi4_oif;
47 __entry->iif = flp->flowi4_iif;
48 __entry->tos = flp->flowi4_tos;
49 __entry->scope = flp->flowi4_scope;
50 __entry->flags = flp->flowi4_flags;
51
52 p32 = (__be32 *) __entry->src;
53 *p32 = flp->saddr;
54
55 p32 = (__be32 *) __entry->dst;
56 *p32 = flp->daddr;
57
58 __entry->proto = flp->flowi4_proto;
59 if (__entry->proto == IPPROTO_TCP ||
60 __entry->proto == IPPROTO_UDP) {
61 __entry->sport = ntohs(flp->fl4_sport);
62 __entry->dport = ntohs(flp->fl4_dport);
63 } else {
64 __entry->sport = 0;
65 __entry->dport = 0;
66 }
67
David Brazdil0f672f62019-12-10 10:32:29 +000068 dev = nhc ? nhc->nhc_dev : NULL;
69 __assign_str(name, dev ? dev->name : "-");
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000070
David Brazdil0f672f62019-12-10 10:32:29 +000071 if (nhc) {
72 if (nhc->nhc_gw_family == AF_INET) {
73 p32 = (__be32 *) __entry->gw4;
74 *p32 = nhc->nhc_gw.ipv4;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000075
David Brazdil0f672f62019-12-10 10:32:29 +000076 in6 = (struct in6_addr *)__entry->gw6;
77 *in6 = in6_zero;
78 } else if (nhc->nhc_gw_family == AF_INET6) {
79 p32 = (__be32 *) __entry->gw4;
80 *p32 = 0;
81
82 in6 = (struct in6_addr *)__entry->gw6;
83 *in6 = nhc->nhc_gw.ipv6;
84 }
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000085 } else {
David Brazdil0f672f62019-12-10 10:32:29 +000086 p32 = (__be32 *) __entry->gw4;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000087 *p32 = 0;
88
David Brazdil0f672f62019-12-10 10:32:29 +000089 in6 = (struct in6_addr *)__entry->gw6;
90 *in6 = in6_zero;
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000091 }
92 ),
93
David Brazdil0f672f62019-12-10 10:32:29 +000094 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",
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000095 __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
96 __entry->src, __entry->sport, __entry->dst, __entry->dport,
97 __entry->tos, __entry->scope, __entry->flags,
David Brazdil0f672f62019-12-10 10:32:29 +000098 __get_str(name), __entry->gw4, __entry->gw6, __entry->err)
Andrew Scullb4b6d4a2019-01-02 15:54:55 +000099);
100#endif /* _TRACE_FIB_H */
101
102/* This part must be outside protection */
103#include <trace/define_trace.h>