diff mbox series

[net-next,2/3] net/ipv6: Udate fib6_table_lookup tracepoint

Message ID 20180521212443.23612-3-dsahern@kernel.org
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series net: Update fib_table_lookup tracepoints | expand

Commit Message

David Ahern May 21, 2018, 9:24 p.m. UTC
From: David Ahern <dsahern@gmail.com>

Commit bb0ad1987e96 ("ipv6: fib6_rules: support for match on sport, dport
and ip proto") added support for protocol and ports to FIB rules.
Update the FIB lookup tracepoint to dump the parameters.

Signed-off-by: David Ahern <dsahern@gmail.com>
---
 include/net/ip6_fib.h       |  2 ++
 include/trace/events/fib6.h | 29 ++++++++++++++++++++++-------
 net/ipv6/route.c            |  2 +-
 3 files changed, 25 insertions(+), 8 deletions(-)

Comments

kernel test robot May 23, 2018, 6:46 a.m. UTC | #1
Hi David,

I love your patch! Yet something to improve:

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/dsahern-kernel-org/net-ipv4-Udate-fib_table_lookup-tracepoint/20180523-083238
config: x86_64-randconfig-s4-05231222 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-16) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

   net/core/net-traces.o: In function `perf_trace_fib6_table_lookup':
>> include/trace/events/fib6.h:13: undefined reference to `ip6_rt_type_to_error'
   net/core/net-traces.o: In function `trace_event_raw_event_fib6_table_lookup':
>> include/trace/events/fib6.h:13: undefined reference to `ip6_rt_type_to_error'

vim +13 include/trace/events/fib6.h

b811580d David Ahern     2015-11-19  12  
b811580d David Ahern     2015-11-19 @13  TRACE_EVENT(fib6_table_lookup,
b811580d David Ahern     2015-11-19  14  
d4bea421 David Ahern     2018-05-09  15  	TP_PROTO(const struct net *net, const struct fib6_info *f6i,
b65f164d Paolo Abeni     2017-10-19  16  		 struct fib6_table *table, const struct flowi6 *flp),
b811580d David Ahern     2015-11-19  17  
d4bea421 David Ahern     2018-05-09  18  	TP_ARGS(net, f6i, table, flp),
b811580d David Ahern     2015-11-19  19  
b811580d David Ahern     2015-11-19  20  	TP_STRUCT__entry(
b811580d David Ahern     2015-11-19  21  		__field(	u32,	tb_id		)
6d233bf4 David Ahern     2018-05-21  22  		__field(	int,	err		)
b811580d David Ahern     2015-11-19  23  		__field(	int,	oif		)
b811580d David Ahern     2015-11-19  24  		__field(	int,	iif		)
b811580d David Ahern     2015-11-19  25  		__field(	__u8,	tos		)
b811580d David Ahern     2015-11-19  26  		__field(	__u8,	scope		)
b811580d David Ahern     2015-11-19  27  		__field(	__u8,	flags		)
b811580d David Ahern     2015-11-19  28  		__array(	__u8,	src,	16	)
b811580d David Ahern     2015-11-19  29  		__array(	__u8,	dst,	16	)
6d233bf4 David Ahern     2018-05-21  30  		__field(        u16,	sport		)
6d233bf4 David Ahern     2018-05-21  31  		__field(        u16,	dport		)
6d233bf4 David Ahern     2018-05-21  32  		__field(        u8,	proto		)
6d233bf4 David Ahern     2018-05-21  33  		__field(        u8,	rt_type		)
b811580d David Ahern     2015-11-19  34  		__dynamic_array(	char,	name,	IFNAMSIZ )
b811580d David Ahern     2015-11-19  35  		__array(		__u8,	gw,	16	 )
b811580d David Ahern     2015-11-19  36  	),
b811580d David Ahern     2015-11-19  37  
b811580d David Ahern     2015-11-19  38  	TP_fast_assign(
b811580d David Ahern     2015-11-19  39  		struct in6_addr *in6;
b811580d David Ahern     2015-11-19  40  
b65f164d Paolo Abeni     2017-10-19  41  		__entry->tb_id = table->tb6_id;
6d233bf4 David Ahern     2018-05-21  42  		__entry->err = ip6_rt_type_to_error(f6i->fib6_type);
b811580d David Ahern     2015-11-19  43  		__entry->oif = flp->flowi6_oif;
b811580d David Ahern     2015-11-19  44  		__entry->iif = flp->flowi6_iif;
69716a2b Daniel Borkmann 2016-03-18  45  		__entry->tos = ip6_tclass(flp->flowlabel);
b811580d David Ahern     2015-11-19  46  		__entry->scope = flp->flowi6_scope;
b811580d David Ahern     2015-11-19  47  		__entry->flags = flp->flowi6_flags;
b811580d David Ahern     2015-11-19  48  
b811580d David Ahern     2015-11-19  49  		in6 = (struct in6_addr *)__entry->src;
b811580d David Ahern     2015-11-19  50  		*in6 = flp->saddr;
b811580d David Ahern     2015-11-19  51  
b811580d David Ahern     2015-11-19  52  		in6 = (struct in6_addr *)__entry->dst;
b811580d David Ahern     2015-11-19  53  		*in6 = flp->daddr;
b811580d David Ahern     2015-11-19  54  
6d233bf4 David Ahern     2018-05-21  55  		__entry->proto = flp->flowi6_proto;
6d233bf4 David Ahern     2018-05-21  56  		if (__entry->proto == IPPROTO_TCP ||
6d233bf4 David Ahern     2018-05-21  57  		    __entry->proto == IPPROTO_UDP) {
6d233bf4 David Ahern     2018-05-21  58  			__entry->sport = ntohs(flp->fl6_sport);
6d233bf4 David Ahern     2018-05-21  59  			__entry->dport = ntohs(flp->fl6_dport);
6d233bf4 David Ahern     2018-05-21  60  		} else {
6d233bf4 David Ahern     2018-05-21  61  			__entry->sport = 0;
6d233bf4 David Ahern     2018-05-21  62  			__entry->dport = 0;
6d233bf4 David Ahern     2018-05-21  63  		}
6d233bf4 David Ahern     2018-05-21  64  
d4bea421 David Ahern     2018-05-09  65  		if (f6i->fib6_nh.nh_dev) {
d4bea421 David Ahern     2018-05-09  66  			__assign_str(name, f6i->fib6_nh.nh_dev);
b811580d David Ahern     2015-11-19  67  		} else {
6d233bf4 David Ahern     2018-05-21  68  			__assign_str(name, "-");
b811580d David Ahern     2015-11-19  69  		}
d4bea421 David Ahern     2018-05-09  70  		if (f6i == net->ipv6.fib6_null_entry) {
b811580d David Ahern     2015-11-19  71  			struct in6_addr in6_zero = {};
b811580d David Ahern     2015-11-19  72  
b811580d David Ahern     2015-11-19  73  			in6 = (struct in6_addr *)__entry->gw;
b811580d David Ahern     2015-11-19  74  			*in6 = in6_zero;
b811580d David Ahern     2015-11-19  75  
d4bea421 David Ahern     2018-05-09  76  		} else if (f6i) {
b811580d David Ahern     2015-11-19  77  			in6 = (struct in6_addr *)__entry->gw;
d4bea421 David Ahern     2018-05-09  78  			*in6 = f6i->fib6_nh.nh_gw;
b811580d David Ahern     2015-11-19  79  		}
b811580d David Ahern     2015-11-19  80  	),
b811580d David Ahern     2015-11-19  81  
6d233bf4 David Ahern     2018-05-21  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",
6d233bf4 David Ahern     2018-05-21  83  		  __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
6d233bf4 David Ahern     2018-05-21  84  		  __entry->src, __entry->sport, __entry->dst, __entry->dport,
6d233bf4 David Ahern     2018-05-21  85  		  __entry->tos, __entry->scope, __entry->flags,
6d233bf4 David Ahern     2018-05-21  86  		  __get_str(name), __entry->gw, __entry->err)
b811580d David Ahern     2015-11-19  87  );
b811580d David Ahern     2015-11-19  88  

:::::: The code at line 13 was first introduced by commit
:::::: b811580d91e9c0945b0a923dcec3e10cce04ac30 net: IPv6 fib lookup tracepoint

:::::: TO: David Ahern <dsa@cumulusnetworks.com>
:::::: CC: David S. Miller <davem@davemloft.net>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
David Miller May 23, 2018, 5:09 p.m. UTC | #2
From: dsahern@kernel.org
Date: Mon, 21 May 2018 14:24:42 -0700

> +		__entry->err = ip6_rt_type_to_error(f6i->fib6_type);

As the kbuild bot discovered, this doesn't work when IPV6=m.
David Ahern May 23, 2018, 5:13 p.m. UTC | #3
On 5/23/18 11:09 AM, David Miller wrote:
> From: dsahern@kernel.org
> Date: Mon, 21 May 2018 14:24:42 -0700
> 
>> +		__entry->err = ip6_rt_type_to_error(f6i->fib6_type);
> 
> As the kbuild bot discovered, this doesn't work when IPV6=m.
> 

yep. I'll take a look later today. Thinking about moving the tracepoint
create from net/core/net-traces.c to net/ipv6/route.c.
diff mbox series

Patch

diff --git a/include/net/ip6_fib.h b/include/net/ip6_fib.h
index cc70f6da8462..63fd9888f006 100644
--- a/include/net/ip6_fib.h
+++ b/include/net/ip6_fib.h
@@ -286,6 +286,8 @@  static inline void fib6_info_release(struct fib6_info *f6i)
 		fib6_info_destroy(f6i);
 }
 
+int ip6_rt_type_to_error(u8 fib6_type);
+
 enum fib6_walk_state {
 #ifdef CONFIG_IPV6_SUBTREES
 	FWS_S,
diff --git a/include/trace/events/fib6.h b/include/trace/events/fib6.h
index 1b8d951e3c12..b088b54d699c 100644
--- a/include/trace/events/fib6.h
+++ b/include/trace/events/fib6.h
@@ -19,7 +19,7 @@  TRACE_EVENT(fib6_table_lookup,
 
 	TP_STRUCT__entry(
 		__field(	u32,	tb_id		)
-
+		__field(	int,	err		)
 		__field(	int,	oif		)
 		__field(	int,	iif		)
 		__field(	__u8,	tos		)
@@ -27,7 +27,10 @@  TRACE_EVENT(fib6_table_lookup,
 		__field(	__u8,	flags		)
 		__array(	__u8,	src,	16	)
 		__array(	__u8,	dst,	16	)
-
+		__field(        u16,	sport		)
+		__field(        u16,	dport		)
+		__field(        u8,	proto		)
+		__field(        u8,	rt_type		)
 		__dynamic_array(	char,	name,	IFNAMSIZ )
 		__array(		__u8,	gw,	16	 )
 	),
@@ -36,6 +39,7 @@  TRACE_EVENT(fib6_table_lookup,
 		struct in6_addr *in6;
 
 		__entry->tb_id = table->tb6_id;
+		__entry->err = ip6_rt_type_to_error(f6i->fib6_type);
 		__entry->oif = flp->flowi6_oif;
 		__entry->iif = flp->flowi6_iif;
 		__entry->tos = ip6_tclass(flp->flowlabel);
@@ -48,10 +52,20 @@  TRACE_EVENT(fib6_table_lookup,
 		in6 = (struct in6_addr *)__entry->dst;
 		*in6 = flp->daddr;
 
+		__entry->proto = flp->flowi6_proto;
+		if (__entry->proto == IPPROTO_TCP ||
+		    __entry->proto == IPPROTO_UDP) {
+			__entry->sport = ntohs(flp->fl6_sport);
+			__entry->dport = ntohs(flp->fl6_dport);
+		} else {
+			__entry->sport = 0;
+			__entry->dport = 0;
+		}
+
 		if (f6i->fib6_nh.nh_dev) {
 			__assign_str(name, f6i->fib6_nh.nh_dev);
 		} else {
-			__assign_str(name, "");
+			__assign_str(name, "-");
 		}
 		if (f6i == net->ipv6.fib6_null_entry) {
 			struct in6_addr in6_zero = {};
@@ -65,10 +79,11 @@  TRACE_EVENT(fib6_table_lookup,
 		}
 	),
 
-	TP_printk("table %3u oif %d iif %d src %pI6c dst %pI6c tos %d scope %d flags %x ==> dev %s gw %pI6c",
-		  __entry->tb_id, __entry->oif, __entry->iif,
-		  __entry->src, __entry->dst, __entry->tos, __entry->scope,
-		  __entry->flags, __get_str(name), __entry->gw)
+	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",
+		  __entry->tb_id, __entry->oif, __entry->iif, __entry->proto,
+		  __entry->src, __entry->sport, __entry->dst, __entry->dport,
+		  __entry->tos, __entry->scope, __entry->flags,
+		  __get_str(name), __entry->gw, __entry->err)
 );
 
 #endif /* _TRACE_FIB6_H */
diff --git a/net/ipv6/route.c b/net/ipv6/route.c
index cc24ed3bc334..ae27e57c5997 100644
--- a/net/ipv6/route.c
+++ b/net/ipv6/route.c
@@ -897,7 +897,7 @@  static const int fib6_prop[RTN_MAX + 1] = {
 	[RTN_XRESOLVE]	= -EINVAL,
 };
 
-static int ip6_rt_type_to_error(u8 fib6_type)
+int ip6_rt_type_to_error(u8 fib6_type)
 {
 	return fib6_prop[fib6_type];
 }