Skip to content

Commit b811580

Browse files
David Aherndavem330
authored andcommitted
net: IPv6 fib lookup tracepoint
Add tracepoint to show fib6 table lookups and result. Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent e2f9dc3 commit b811580

File tree

3 files changed

+90
-0
lines changed

3 files changed

+90
-0
lines changed

include/trace/events/fib6.h

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#undef TRACE_SYSTEM
2+
#define TRACE_SYSTEM fib6
3+
4+
#if !defined(_TRACE_FIB6_H) || defined(TRACE_HEADER_MULTI_READ)
5+
#define _TRACE_FIB6_H
6+
7+
#include <linux/in6.h>
8+
#include <net/flow.h>
9+
#include <net/ip6_fib.h>
10+
#include <linux/tracepoint.h>
11+
12+
TRACE_EVENT(fib6_table_lookup,
13+
14+
TP_PROTO(const struct net *net, const struct rt6_info *rt,
15+
u32 tb_id, const struct flowi6 *flp),
16+
17+
TP_ARGS(net, rt, tb_id, flp),
18+
19+
TP_STRUCT__entry(
20+
__field( u32, tb_id )
21+
22+
__field( int, oif )
23+
__field( int, iif )
24+
__field( __u8, tos )
25+
__field( __u8, scope )
26+
__field( __u8, flags )
27+
__array( __u8, src, 16 )
28+
__array( __u8, dst, 16 )
29+
30+
__dynamic_array( char, name, IFNAMSIZ )
31+
__array( __u8, gw, 16 )
32+
),
33+
34+
TP_fast_assign(
35+
struct in6_addr *in6;
36+
37+
__entry->tb_id = tb_id;
38+
__entry->oif = flp->flowi6_oif;
39+
__entry->iif = flp->flowi6_iif;
40+
__entry->tos = flp->flowi6_tos;
41+
__entry->scope = flp->flowi6_scope;
42+
__entry->flags = flp->flowi6_flags;
43+
44+
in6 = (struct in6_addr *)__entry->src;
45+
*in6 = flp->saddr;
46+
47+
in6 = (struct in6_addr *)__entry->dst;
48+
*in6 = flp->daddr;
49+
50+
if (rt->rt6i_idev) {
51+
__assign_str(name, rt->rt6i_idev->dev->name);
52+
} else {
53+
__assign_str(name, "");
54+
}
55+
if (rt == net->ipv6.ip6_null_entry) {
56+
struct in6_addr in6_zero = {};
57+
58+
in6 = (struct in6_addr *)__entry->gw;
59+
*in6 = in6_zero;
60+
61+
} else if (rt) {
62+
in6 = (struct in6_addr *)__entry->gw;
63+
*in6 = rt->rt6i_gateway;
64+
}
65+
),
66+
67+
TP_printk("table %3u oif %d iif %d src %pI6c dst %pI6c tos %d scope %d flags %x ==> dev %s gw %pI6c",
68+
__entry->tb_id, __entry->oif, __entry->iif,
69+
__entry->src, __entry->dst, __entry->tos, __entry->scope,
70+
__entry->flags, __get_str(name), __entry->gw)
71+
);
72+
73+
#endif /* _TRACE_FIB6_H */
74+
75+
/* This part must be outside protection */
76+
#include <trace/define_trace.h>

net/core/net-traces.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@
3232
#include <trace/events/sock.h>
3333
#include <trace/events/udp.h>
3434
#include <trace/events/fib.h>
35+
#if IS_ENABLED(CONFIG_IPV6)
36+
#include <trace/events/fib6.h>
37+
EXPORT_TRACEPOINT_SYMBOL_GPL(fib6_table_lookup);
38+
#endif
3539

3640
EXPORT_TRACEPOINT_SYMBOL_GPL(kfree_skb);
3741

net/ipv6/route.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
#include <net/lwtunnel.h>
6363
#include <net/ip_tunnels.h>
6464
#include <net/l3mdev.h>
65+
#include <trace/events/fib6.h>
6566

6667
#include <asm/uaccess.h>
6768

@@ -865,6 +866,9 @@ static struct rt6_info *ip6_pol_route_lookup(struct net *net,
865866
}
866867
dst_use(&rt->dst, jiffies);
867868
read_unlock_bh(&table->tb6_lock);
869+
870+
trace_fib6_table_lookup(net, rt, table->tb6_id, fl6);
871+
868872
return rt;
869873

870874
}
@@ -1078,6 +1082,8 @@ static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
10781082
read_unlock_bh(&table->tb6_lock);
10791083

10801084
rt6_dst_from_metrics_check(rt);
1085+
1086+
trace_fib6_table_lookup(net, rt, table->tb6_id, fl6);
10811087
return rt;
10821088
} else if (unlikely((fl6->flowi6_flags & FLOWI_FLAG_KNOWN_NH) &&
10831089
!(rt->rt6i_flags & RTF_GATEWAY))) {
@@ -1101,6 +1107,8 @@ static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
11011107
uncached_rt = net->ipv6.ip6_null_entry;
11021108

11031109
dst_hold(&uncached_rt->dst);
1110+
1111+
trace_fib6_table_lookup(net, uncached_rt, table->tb6_id, fl6);
11041112
return uncached_rt;
11051113

11061114
} else {
@@ -1125,6 +1133,7 @@ static struct rt6_info *ip6_pol_route(struct net *net, struct fib6_table *table,
11251133
dst_release(&rt->dst);
11261134
}
11271135

1136+
trace_fib6_table_lookup(net, pcpu_rt, table->tb6_id, fl6);
11281137
return pcpu_rt;
11291138

11301139
}
@@ -1474,6 +1483,7 @@ static struct rt6_info *__ip6_route_redirect(struct net *net,
14741483

14751484
read_unlock_bh(&table->tb6_lock);
14761485

1486+
trace_fib6_table_lookup(net, rt, table->tb6_id, fl6);
14771487
return rt;
14781488
};
14791489

0 commit comments

Comments
 (0)