linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state
@ 2017-11-09 14:26 Yafang Shao
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Yafang Shao @ 2017-11-09 14:26 UTC (permalink / raw)
  To: davem; +Cc: kuznet, yoshfuji, rostedt, mingo, netdev, linux-kernel, Yafang Shao

The TCP/IP transition from TCP_LISTEN to TCP_SYN_RECV isn't traced in
the tcp_set_state tracepoint.

In order to trace the whole tcp lifespans, two helpers are introduced,
static inline void __tcp_set_state(struct sock *sk, int state)
static inline void __sk_state_store(struct sock *sk, int newstate)

When do TCP/IP state transition, we should use these two helpers or use
tcp_set_state() other than assigning a value to sk_state directly.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/net/tcp.h               | 16 ++++++++++++++++
 net/ipv4/inet_connection_sock.c |  6 +++---
 net/ipv4/inet_hashtables.c      |  2 +-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/include/net/tcp.h b/include/net/tcp.h
index babfd4d..c1d57d0 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -46,6 +46,7 @@
 #include <linux/seq_file.h>
 #include <linux/memcontrol.h>
 #include <linux/bpf-cgroup.h>
+#include <trace/events/tcp.h>
 
 extern struct inet_hashinfo tcp_hashinfo;
 
@@ -1263,6 +1264,21 @@ static inline bool tcp_checksum_complete(struct sk_buff *skb)
 #endif
 void tcp_set_state(struct sock *sk, int state);
 
+/*
+ * To trace TCP/IP state transition.
+ */
+static inline void __tcp_set_state(struct sock *sk, int state)
+{
+	trace_tcp_set_state(sk, sk->sk_state, state);
+	sk->sk_state = state;
+}
+
+static inline void __sk_state_store(struct sock *sk, int newstate)
+{
+	trace_tcp_set_state(sk, sk->sk_state, newstate);
+	sk_state_store(sk, newstate);
+}
+
 void tcp_done(struct sock *sk);
 
 int tcp_abort(struct sock *sk, int err);
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 4ca46dc..f3967f1 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -783,7 +783,7 @@ struct sock *inet_csk_clone_lock(const struct sock *sk,
 	if (newsk) {
 		struct inet_connection_sock *newicsk = inet_csk(newsk);
 
-		newsk->sk_state = TCP_SYN_RECV;
+		__tcp_set_state(newsk, TCP_SYN_RECV);
 		newicsk->icsk_bind_hash = NULL;
 
 		inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port;
@@ -877,7 +877,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 	 * It is OK, because this socket enters to hash table only
 	 * after validation is complete.
 	 */
-	sk_state_store(sk, TCP_LISTEN);
+	__sk_state_store(sk, TCP_LISTEN);
 	if (!sk->sk_prot->get_port(sk, inet->inet_num)) {
 		inet->inet_sport = htons(inet->inet_num);
 
@@ -888,7 +888,7 @@ int inet_csk_listen_start(struct sock *sk, int backlog)
 			return 0;
 	}
 
-	sk->sk_state = TCP_CLOSE;
+	__tcp_set_state(sk, TCP_CLOSE);
 	return err;
 }
 EXPORT_SYMBOL_GPL(inet_csk_listen_start);
diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
index e7d15fb..72c15b6 100644
--- a/net/ipv4/inet_hashtables.c
+++ b/net/ipv4/inet_hashtables.c
@@ -430,7 +430,7 @@ bool inet_ehash_nolisten(struct sock *sk, struct sock *osk)
 		sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1);
 	} else {
 		percpu_counter_inc(sk->sk_prot->orphan_count);
-		sk->sk_state = TCP_CLOSE;
+		__tcp_set_state(sk, TCP_CLOSE);
 		sock_set_flag(sk, SOCK_DEAD);
 		inet_csk_destroy_sock(sk);
 	}
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:26 [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state Yafang Shao
@ 2017-11-09 14:26 ` Yafang Shao
  2017-11-09 14:52   ` Eric Dumazet
                     ` (2 more replies)
  2017-11-12 13:46 ` [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state kbuild test robot
                   ` (2 subsequent siblings)
  3 siblings, 3 replies; 11+ messages in thread
From: Yafang Shao @ 2017-11-09 14:26 UTC (permalink / raw)
  To: davem; +Cc: kuznet, yoshfuji, rostedt, mingo, netdev, linux-kernel, Yafang Shao

When TCP connetion in TCP_TIME_WAIT or TCP_NEW_SYN_RECV state, it can't
get the sport/dport/saddr/daddr from inet_sock.

trace_tcp_set_state may be called when the oldstate in these two states.

Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
---
 include/trace/events/tcp.h | 33 ++++++++++++++++++++++++++-------
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
index 07cccca..1982a71 100644
--- a/include/trace/events/tcp.h
+++ b/include/trace/events/tcp.h
@@ -196,7 +196,6 @@
 	),
 
 	TP_fast_assign(
-		struct inet_sock *inet = inet_sk(sk);
 		struct in6_addr *pin6;
 		__be32 *p32;
 
@@ -204,14 +203,34 @@
 		__entry->oldstate = oldstate;
 		__entry->newstate = newstate;
 
-		__entry->sport = ntohs(inet->inet_sport);
-		__entry->dport = ntohs(inet->inet_dport);
+		if (oldstate == TCP_TIME_WAIT) {
+			__entry->sport = ntohs(inet_twsk(sk)->tw_sport);
+			__entry->dport = ntohs(inet_twsk(sk)->tw_dport);
 
-		p32 = (__be32 *) __entry->saddr;
-		*p32 = inet->inet_saddr;
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_twsk(sk)->tw_rcv_saddr;
 
-		p32 = (__be32 *) __entry->daddr;
-		*p32 =  inet->inet_daddr;
+			p32 = (__be32 *) __entry->daddr;
+			*p32 = inet_twsk(sk)->tw_daddr;
+		} else if (oldstate == TCP_NEW_SYN_RECV) {
+			__entry->sport = inet_rsk(inet_reqsk(sk))->ir_num;
+			__entry->dport = ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port);
+
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_rsk(inet_reqsk(sk))->ir_loc_addr;
+
+			p32 = (__be32 *) __entry->daddr;
+			*p32 = inet_rsk(inet_reqsk(sk))->ir_rmt_addr;
+		} else {
+			__entry->sport = ntohs(inet_sk(sk)->inet_sport);
+			__entry->dport = ntohs(inet_sk(sk)->inet_dport);
+
+			p32 = (__be32 *) __entry->saddr;
+			*p32 = inet_sk(sk)->inet_saddr;
+
+			p32 = (__be32 *) __entry->daddr;
+			*p32 =  inet_sk(sk)->inet_daddr;
+		}
 
 #if IS_ENABLED(CONFIG_IPV6)
 		if (sk->sk_family == AF_INET6) {
-- 
1.8.3.1

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
@ 2017-11-09 14:52   ` Eric Dumazet
  2017-11-09 14:58     ` Eric Dumazet
  2017-11-12 14:15   ` kbuild test robot
  2017-11-12 15:40   ` kbuild test robot
  2 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2017-11-09 14:52 UTC (permalink / raw)
  To: Yafang Shao; +Cc: davem, kuznet, yoshfuji, rostedt, mingo, netdev, linux-kernel

On Thu, 2017-11-09 at 14:26 +0000, Yafang Shao wrote:
> When TCP connetion in TCP_TIME_WAIT or TCP_NEW_SYN_RECV state, it can't
> get the sport/dport/saddr/daddr from inet_sock.
> 
> trace_tcp_set_state may be called when the oldstate in these two states.
> 
> Signed-off-by: Yafang Shao <laoar.shao@gmail.com>
> ---
>  include/trace/events/tcp.h | 33 ++++++++++++++++++++++++++-------
>  1 file changed, 26 insertions(+), 7 deletions(-)
> 
> diff --git a/include/trace/events/tcp.h b/include/trace/events/tcp.h
> index 07cccca..1982a71 100644
> --- a/include/trace/events/tcp.h
> +++ b/include/trace/events/tcp.h
> @@ -196,7 +196,6 @@
>  	),
>  
>  	TP_fast_assign(
> -		struct inet_sock *inet = inet_sk(sk);
>  		struct in6_addr *pin6;
>  		__be32 *p32;
>  
> @@ -204,14 +203,34 @@
>  		__entry->oldstate = oldstate;
>  		__entry->newstate = newstate;
>  
> -		__entry->sport = ntohs(inet->inet_sport);
> -		__entry->dport = ntohs(inet->inet_dport);
> +		if (oldstate == TCP_TIME_WAIT) {
> +			__entry->sport = ntohs(inet_twsk(sk)->tw_sport);
> +			__entry->dport = ntohs(inet_twsk(sk)->tw_dport);
>  
> -		p32 = (__be32 *) __entry->saddr;
> -		*p32 = inet->inet_saddr;
> +			p32 = (__be32 *) __entry->saddr;
> +			*p32 = inet_twsk(sk)->tw_rcv_saddr;
>  
> -		p32 = (__be32 *) __entry->daddr;
> -		*p32 =  inet->inet_daddr;
> +			p32 = (__be32 *) __entry->daddr;
> +			*p32 = inet_twsk(sk)->tw_daddr;
> +		} else if (oldstate == TCP_NEW_SYN_RECV) {
> +			__entry->sport = inet_rsk(inet_reqsk(sk))->ir_num;
> +			__entry->dport = ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port);
> +
> +			p32 = (__be32 *) __entry->saddr;
> +			*p32 = inet_rsk(inet_reqsk(sk))->ir_loc_addr;
> +
> +			p32 = (__be32 *) __entry->daddr;
> +			*p32 = inet_rsk(inet_reqsk(sk))->ir_rmt_addr;
> +		} else {
> +			__entry->sport = ntohs(inet_sk(sk)->inet_sport);
> +			__entry->dport = ntohs(inet_sk(sk)->inet_dport);
> +
> +			p32 = (__be32 *) __entry->saddr;
> +			*p32 = inet_sk(sk)->inet_saddr;
> +
> +			p32 = (__be32 *) __entry->daddr;
> +			*p32 =  inet_sk(sk)->inet_daddr;
> +		}


Wow.


Since all three variants of sockets (full sockets, request sockets,
timewait sockets) are all hashed into ehash table these days, they all
have the fields at the same offset

For IPv4, that would be :

__sk_common.skc_daddr    (or inet_daddr)
__sk_common.skc_rcv_saddr (or inet_rcv_saddr )
__sk_common.skc_dport     (or inet_dport)
__sk_common.skc_num       (or inet_num)

Look at __inet_lookup_established() and INET_MATCH() : They deal with
the three variants, without having to look at sk_state.

If you were using the fields that are common to all sockets, no need to
add all this unnecessary complexity.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:52   ` Eric Dumazet
@ 2017-11-09 14:58     ` Eric Dumazet
  2017-11-09 15:11       ` Yafang Shao
  0 siblings, 1 reply; 11+ messages in thread
From: Eric Dumazet @ 2017-11-09 14:58 UTC (permalink / raw)
  To: Yafang Shao; +Cc: davem, kuznet, yoshfuji, rostedt, mingo, netdev, linux-kernel

On Thu, 2017-11-09 at 06:52 -0800, Eric Dumazet wrote:

> Wow.
> 
> 
> Since all three variants of sockets (full sockets, request sockets,
> timewait sockets) are all hashed into ehash table these days, they all
> have the fields at the same offset
> 
> For IPv4, that would be :
> 
> __sk_common.skc_daddr    (or inet_daddr)
> __sk_common.skc_rcv_saddr (or inet_rcv_saddr )
> __sk_common.skc_dport     (or inet_dport)
> __sk_common.skc_num       (or inet_num)
> 
> Look at __inet_lookup_established() and INET_MATCH() : They deal with
> the three variants, without having to look at sk_state.
> 
> If you were using the fields that are common to all sockets, no need to
> add all this unnecessary complexity.
> 

Not to mention that your patch took care of IPv4 only.

I can not say how sad I am that in 2017 IPv6 seems to be second class
citizen.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:58     ` Eric Dumazet
@ 2017-11-09 15:11       ` Yafang Shao
  2017-11-09 15:18         ` Eric Dumazet
  0 siblings, 1 reply; 11+ messages in thread
From: Yafang Shao @ 2017-11-09 15:11 UTC (permalink / raw)
  To: Eric Dumazet
  Cc: David Miller, Alexey Kuznetsov, yoshfuji, rostedt, mingo, netdev,
	linux-kernel

2017-11-09 22:58 GMT+08:00 Eric Dumazet <eric.dumazet@gmail.com>:
> On Thu, 2017-11-09 at 06:52 -0800, Eric Dumazet wrote:
>
>> Wow.
>>
>>
>> Since all three variants of sockets (full sockets, request sockets,
>> timewait sockets) are all hashed into ehash table these days, they all
>> have the fields at the same offset
>>
>> For IPv4, that would be :
>>
>> __sk_common.skc_daddr    (or inet_daddr)
>> __sk_common.skc_rcv_saddr (or inet_rcv_saddr )
>> __sk_common.skc_dport     (or inet_dport)
>> __sk_common.skc_num       (or inet_num)
>>
>> Look at __inet_lookup_established() and INET_MATCH() : They deal with
>> the three variants, without having to look at sk_state.
>>
>> If you were using the fields that are common to all sockets, no need to
>> add all this unnecessary complexity.
>>
>
> Not to mention that your patch took care of IPv4 only.
>
> I can not say how sad I am that in 2017 IPv6 seems to be second class
> citizen.
>

I'm also very sad that I'm still using IPv4 in 2017 : (

Okay then another issue,
shoule we reduce the complexity in  the function tcp4_seq_show() ?

Thanks
Yafang

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 15:11       ` Yafang Shao
@ 2017-11-09 15:18         ` Eric Dumazet
  0 siblings, 0 replies; 11+ messages in thread
From: Eric Dumazet @ 2017-11-09 15:18 UTC (permalink / raw)
  To: Yafang Shao
  Cc: David Miller, Alexey Kuznetsov, yoshfuji, rostedt, mingo, netdev,
	linux-kernel

On Thu, 2017-11-09 at 23:11 +0800, Yafang Shao wrote:

> I'm also very sad that I'm still using IPv4 in 2017 : (
> 
> Okay then another issue,
> shoule we reduce the complexity in  the function tcp4_seq_show() ?

This is irrelevant really.

I do not see how tcp4_seq_show() could avoid testing sk_state.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state
  2017-11-09 14:26 [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state Yafang Shao
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
@ 2017-11-12 13:46 ` kbuild test robot
  2017-11-12 15:10 ` kbuild test robot
  2017-11-12 17:15 ` kbuild test robot
  3 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2017-11-12 13:46 UTC (permalink / raw)
  To: Yafang Shao
  Cc: kbuild-all, davem, kuznet, yoshfuji, rostedt, mingo, netdev,
	linux-kernel, Yafang Shao

[-- Attachment #1: Type: text/plain, Size: 5240 bytes --]

Hi Yafang,

Thank you for the patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Yafang-Shao/net-tcp-track-all-TCP-IP-state-transition-in-tcp_set_state/20171112-203643
config: blackfin-allmodconfig (attached as .config)
compiler: bfin-uclinux-gcc (GCC) 6.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=blackfin 

All error/warnings (new ones prefixed by >>):

   In file included from include/net/tcp.h:49:0,
                    from net/netfilter/ipvs/ip_vs_proto_tcp.c:27:
>> include/trace/events/tcp.h:12:31: error: expected identifier or '(' before '{' token
    #define tcp_state_name(state) { state, #state }
                                  ^
>> net/netfilter/ipvs/ip_vs_proto_tcp.c:424:21: note: in expansion of macro 'tcp_state_name'
    static const char * tcp_state_name(int state)
                        ^~~~~~~~~~~~~~
>> net/netfilter/ipvs/ip_vs_proto_tcp.c:425:1: error: expected identifier or '(' before '{' token
    {
    ^
   In file included from include/net/tcp.h:49:0,
                    from net/netfilter/ipvs/ip_vs_proto_tcp.c:27:
   net/netfilter/ipvs/ip_vs_proto_tcp.c: In function 'set_tcp_state':
>> include/trace/events/tcp.h:12:31: error: expected expression before '{' token
    #define tcp_state_name(state) { state, #state }
                                  ^
>> include/net/ip_vs.h:228:37: note: in expansion of macro 'tcp_state_name'
       printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
                                        ^~~~~~~~~~~
>> net/netfilter/ipvs/ip_vs_proto_tcp.c:541:3: note: in expansion of macro 'IP_VS_DBG_BUF'
      IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->"
      ^~~~~~~~~~~~~
   net/netfilter/ipvs/ip_vs_proto_tcp.c: At top level:
>> net/netfilter/ipvs/ip_vs_proto_tcp.c:737:17: error: 'tcp_state_name' undeclared here (not in a function)
     .state_name =  tcp_state_name,
                    ^~~~~~~~~~~~~~
--
   In file included from include/net/tcp.h:49:0,
                    from net/netfilter//ipvs/ip_vs_proto_tcp.c:27:
>> include/trace/events/tcp.h:12:31: error: expected identifier or '(' before '{' token
    #define tcp_state_name(state) { state, #state }
                                  ^
   net/netfilter//ipvs/ip_vs_proto_tcp.c:424:21: note: in expansion of macro 'tcp_state_name'
    static const char * tcp_state_name(int state)
                        ^~~~~~~~~~~~~~
   net/netfilter//ipvs/ip_vs_proto_tcp.c:425:1: error: expected identifier or '(' before '{' token
    {
    ^
   In file included from include/net/tcp.h:49:0,
                    from net/netfilter//ipvs/ip_vs_proto_tcp.c:27:
   net/netfilter//ipvs/ip_vs_proto_tcp.c: In function 'set_tcp_state':
>> include/trace/events/tcp.h:12:31: error: expected expression before '{' token
    #define tcp_state_name(state) { state, #state }
                                  ^
>> include/net/ip_vs.h:228:37: note: in expansion of macro 'tcp_state_name'
       printk(KERN_DEBUG pr_fmt(msg), ##__VA_ARGS__); \
                                        ^~~~~~~~~~~
   net/netfilter//ipvs/ip_vs_proto_tcp.c:541:3: note: in expansion of macro 'IP_VS_DBG_BUF'
      IP_VS_DBG_BUF(8, "%s %s [%c%c%c%c] %s:%d->"
      ^~~~~~~~~~~~~
   net/netfilter//ipvs/ip_vs_proto_tcp.c: At top level:
   net/netfilter//ipvs/ip_vs_proto_tcp.c:737:17: error: 'tcp_state_name' undeclared here (not in a function)
     .state_name =  tcp_state_name,
                    ^~~~~~~~~~~~~~

vim +12 include/trace/events/tcp.h

e086101b Cong Wang 2017-10-13  11  
e8fce239 Song Liu  2017-10-23 @12  #define tcp_state_name(state)	{ state, #state }
e8fce239 Song Liu  2017-10-23  13  #define show_tcp_state_name(val)			\
e8fce239 Song Liu  2017-10-23  14  	__print_symbolic(val,				\
e8fce239 Song Liu  2017-10-23  15  		tcp_state_name(TCP_ESTABLISHED),	\
e8fce239 Song Liu  2017-10-23  16  		tcp_state_name(TCP_SYN_SENT),		\
e8fce239 Song Liu  2017-10-23  17  		tcp_state_name(TCP_SYN_RECV),		\
e8fce239 Song Liu  2017-10-23  18  		tcp_state_name(TCP_FIN_WAIT1),		\
e8fce239 Song Liu  2017-10-23  19  		tcp_state_name(TCP_FIN_WAIT2),		\
e8fce239 Song Liu  2017-10-23  20  		tcp_state_name(TCP_TIME_WAIT),		\
e8fce239 Song Liu  2017-10-23  21  		tcp_state_name(TCP_CLOSE),		\
e8fce239 Song Liu  2017-10-23  22  		tcp_state_name(TCP_CLOSE_WAIT),		\
e8fce239 Song Liu  2017-10-23  23  		tcp_state_name(TCP_LAST_ACK),		\
e8fce239 Song Liu  2017-10-23  24  		tcp_state_name(TCP_LISTEN),		\
e8fce239 Song Liu  2017-10-23  25  		tcp_state_name(TCP_CLOSING),		\
e8fce239 Song Liu  2017-10-23  26  		tcp_state_name(TCP_NEW_SYN_RECV))
e8fce239 Song Liu  2017-10-23  27  

:::::: The code at line 12 was first introduced by commit
:::::: e8fce23946b7e7eadf25ad78d8207c22903dfe27 tcp: add tracepoint trace_tcp_set_state()

:::::: TO: Song Liu <songliubraving@fb.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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 45915 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
  2017-11-09 14:52   ` Eric Dumazet
@ 2017-11-12 14:15   ` kbuild test robot
  2017-11-12 15:40   ` kbuild test robot
  2 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2017-11-12 14:15 UTC (permalink / raw)
  To: Yafang Shao
  Cc: kbuild-all, davem, kuznet, yoshfuji, rostedt, mingo, netdev,
	linux-kernel, Yafang Shao

[-- Attachment #1: Type: text/plain, Size: 12414 bytes --]

Hi Yafang,

Thank you for the patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Yafang-Shao/net-tcp-track-all-TCP-IP-state-transition-in-tcp_set_state/20171112-203643
config: i386-randconfig-i1-201746 (attached as .config)
compiler: gcc-6 (Debian 6.4.0-9) 6.4.0 20171026
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/tcp.h:318,
                    from net/core/net-traces.c:35:
   include/trace/events/tcp.h: In function 'trace_event_raw_event_tcp_set_state':
>> include/trace/events/tcp.h:245:27: error: 'inet' undeclared (first use in this function)
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   include/trace/events/tcp.h:245:27: note: each undeclared identifier is reported only once for each function it appears in
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:97:0,
                    from include/trace/events/tcp.h:318,
                    from net/core/net-traces.c:35:
   include/trace/events/tcp.h: In function 'perf_trace_tcp_set_state':
>> include/trace/events/tcp.h:245:27: error: 'inet' undeclared (first use in this function)
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/perf.h:66:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~

vim +/inet +245 include/trace/events/tcp.h

e8fce239 Song Liu    2017-10-23  181  
e8fce239 Song Liu    2017-10-23  182  	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
e8fce239 Song Liu    2017-10-23  183  
e8fce239 Song Liu    2017-10-23  184  	TP_ARGS(sk, oldstate, newstate),
e8fce239 Song Liu    2017-10-23  185  
e8fce239 Song Liu    2017-10-23  186  	TP_STRUCT__entry(
e8fce239 Song Liu    2017-10-23  187  		__field(const void *, skaddr)
e8fce239 Song Liu    2017-10-23  188  		__field(int, oldstate)
e8fce239 Song Liu    2017-10-23  189  		__field(int, newstate)
e8fce239 Song Liu    2017-10-23  190  		__field(__u16, sport)
e8fce239 Song Liu    2017-10-23  191  		__field(__u16, dport)
e8fce239 Song Liu    2017-10-23  192  		__array(__u8, saddr, 4)
e8fce239 Song Liu    2017-10-23  193  		__array(__u8, daddr, 4)
e8fce239 Song Liu    2017-10-23  194  		__array(__u8, saddr_v6, 16)
e8fce239 Song Liu    2017-10-23  195  		__array(__u8, daddr_v6, 16)
e8fce239 Song Liu    2017-10-23  196  	),
e8fce239 Song Liu    2017-10-23  197  
e8fce239 Song Liu    2017-10-23  198  	TP_fast_assign(
e8fce239 Song Liu    2017-10-23  199  		struct in6_addr *pin6;
e8fce239 Song Liu    2017-10-23  200  		__be32 *p32;
e8fce239 Song Liu    2017-10-23  201  
e8fce239 Song Liu    2017-10-23  202  		__entry->skaddr = sk;
e8fce239 Song Liu    2017-10-23  203  		__entry->oldstate = oldstate;
e8fce239 Song Liu    2017-10-23  204  		__entry->newstate = newstate;
e8fce239 Song Liu    2017-10-23  205  
e346c952 Yafang Shao 2017-11-09  206  		if (oldstate == TCP_TIME_WAIT) {
e346c952 Yafang Shao 2017-11-09  207  			__entry->sport = ntohs(inet_twsk(sk)->tw_sport);
e346c952 Yafang Shao 2017-11-09  208  			__entry->dport = ntohs(inet_twsk(sk)->tw_dport);
e8fce239 Song Liu    2017-10-23  209  
e8fce239 Song Liu    2017-10-23  210  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  211  			*p32 = inet_twsk(sk)->tw_rcv_saddr;
e8fce239 Song Liu    2017-10-23  212  
e8fce239 Song Liu    2017-10-23  213  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  214  			*p32 = inet_twsk(sk)->tw_daddr;
e346c952 Yafang Shao 2017-11-09  215  		} else if (oldstate == TCP_NEW_SYN_RECV) {
e346c952 Yafang Shao 2017-11-09  216  			__entry->sport = inet_rsk(inet_reqsk(sk))->ir_num;
e346c952 Yafang Shao 2017-11-09  217  			__entry->dport = ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port);
e346c952 Yafang Shao 2017-11-09  218  
e346c952 Yafang Shao 2017-11-09  219  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  220  			*p32 = inet_rsk(inet_reqsk(sk))->ir_loc_addr;
e346c952 Yafang Shao 2017-11-09  221  
e346c952 Yafang Shao 2017-11-09  222  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  223  			*p32 = inet_rsk(inet_reqsk(sk))->ir_rmt_addr;
e346c952 Yafang Shao 2017-11-09  224  		} else {
e346c952 Yafang Shao 2017-11-09  225  			__entry->sport = ntohs(inet_sk(sk)->inet_sport);
e346c952 Yafang Shao 2017-11-09  226  			__entry->dport = ntohs(inet_sk(sk)->inet_dport);
e346c952 Yafang Shao 2017-11-09  227  
e346c952 Yafang Shao 2017-11-09  228  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  229  			*p32 = inet_sk(sk)->inet_saddr;
e346c952 Yafang Shao 2017-11-09  230  
e346c952 Yafang Shao 2017-11-09  231  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  232  			*p32 =  inet_sk(sk)->inet_daddr;
e346c952 Yafang Shao 2017-11-09  233  		}
e8fce239 Song Liu    2017-10-23  234  
e8fce239 Song Liu    2017-10-23  235  #if IS_ENABLED(CONFIG_IPV6)
e8fce239 Song Liu    2017-10-23  236  		if (sk->sk_family == AF_INET6) {
e8fce239 Song Liu    2017-10-23  237  			pin6 = (struct in6_addr *)__entry->saddr_v6;
e8fce239 Song Liu    2017-10-23  238  			*pin6 = sk->sk_v6_rcv_saddr;
e8fce239 Song Liu    2017-10-23  239  			pin6 = (struct in6_addr *)__entry->daddr_v6;
e8fce239 Song Liu    2017-10-23  240  			*pin6 = sk->sk_v6_daddr;
e8fce239 Song Liu    2017-10-23  241  		} else
e8fce239 Song Liu    2017-10-23  242  #endif
e8fce239 Song Liu    2017-10-23  243  		{
e8fce239 Song Liu    2017-10-23  244  			pin6 = (struct in6_addr *)__entry->saddr_v6;
e8fce239 Song Liu    2017-10-23 @245  			ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
e8fce239 Song Liu    2017-10-23  246  			pin6 = (struct in6_addr *)__entry->daddr_v6;
e8fce239 Song Liu    2017-10-23  247  			ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
e8fce239 Song Liu    2017-10-23  248  		}
e8fce239 Song Liu    2017-10-23  249  	),
e8fce239 Song Liu    2017-10-23  250  
e8fce239 Song Liu    2017-10-23  251  	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
e8fce239 Song Liu    2017-10-23  252  		  __entry->sport, __entry->dport,
e8fce239 Song Liu    2017-10-23  253  		  __entry->saddr, __entry->daddr,
e8fce239 Song Liu    2017-10-23  254  		  __entry->saddr_v6, __entry->daddr_v6,
e8fce239 Song Liu    2017-10-23  255  		  show_tcp_state_name(__entry->oldstate),
e8fce239 Song Liu    2017-10-23  256  		  show_tcp_state_name(__entry->newstate))
e8fce239 Song Liu    2017-10-23  257  );
e8fce239 Song Liu    2017-10-23  258  
cf34ce3d Song Liu    2017-10-30  259  TRACE_EVENT(tcp_retransmit_synack,
cf34ce3d Song Liu    2017-10-30  260  
cf34ce3d Song Liu    2017-10-30  261  	TP_PROTO(const struct sock *sk, const struct request_sock *req),
cf34ce3d Song Liu    2017-10-30  262  
cf34ce3d Song Liu    2017-10-30  263  	TP_ARGS(sk, req),
cf34ce3d Song Liu    2017-10-30  264  
cf34ce3d Song Liu    2017-10-30  265  	TP_STRUCT__entry(
cf34ce3d Song Liu    2017-10-30  266  		__field(const void *, skaddr)
cf34ce3d Song Liu    2017-10-30  267  		__field(const void *, req)
cf34ce3d Song Liu    2017-10-30  268  		__field(__u16, sport)
cf34ce3d Song Liu    2017-10-30  269  		__field(__u16, dport)
cf34ce3d Song Liu    2017-10-30  270  		__array(__u8, saddr, 4)
cf34ce3d Song Liu    2017-10-30  271  		__array(__u8, daddr, 4)
cf34ce3d Song Liu    2017-10-30  272  		__array(__u8, saddr_v6, 16)
cf34ce3d Song Liu    2017-10-30  273  		__array(__u8, daddr_v6, 16)
cf34ce3d Song Liu    2017-10-30  274  	),
cf34ce3d Song Liu    2017-10-30  275  
cf34ce3d Song Liu    2017-10-30  276  	TP_fast_assign(
cf34ce3d Song Liu    2017-10-30  277  		struct inet_request_sock *ireq = inet_rsk(req);
cf34ce3d Song Liu    2017-10-30  278  		struct in6_addr *pin6;
cf34ce3d Song Liu    2017-10-30  279  		__be32 *p32;
cf34ce3d Song Liu    2017-10-30  280  
cf34ce3d Song Liu    2017-10-30  281  		__entry->skaddr = sk;
cf34ce3d Song Liu    2017-10-30  282  		__entry->req = req;
cf34ce3d Song Liu    2017-10-30  283  
cf34ce3d Song Liu    2017-10-30  284  		__entry->sport = ireq->ir_num;
cf34ce3d Song Liu    2017-10-30  285  		__entry->dport = ntohs(ireq->ir_rmt_port);
cf34ce3d Song Liu    2017-10-30  286  
cf34ce3d Song Liu    2017-10-30  287  		p32 = (__be32 *) __entry->saddr;
cf34ce3d Song Liu    2017-10-30  288  		*p32 = ireq->ir_loc_addr;
cf34ce3d Song Liu    2017-10-30  289  
cf34ce3d Song Liu    2017-10-30  290  		p32 = (__be32 *) __entry->daddr;
cf34ce3d Song Liu    2017-10-30  291  		*p32 = ireq->ir_rmt_addr;
cf34ce3d Song Liu    2017-10-30  292  
cf34ce3d Song Liu    2017-10-30  293  #if IS_ENABLED(CONFIG_IPV6)
cf34ce3d Song Liu    2017-10-30  294  		if (sk->sk_family == AF_INET6) {
cf34ce3d Song Liu    2017-10-30  295  			pin6 = (struct in6_addr *)__entry->saddr_v6;
cf34ce3d Song Liu    2017-10-30  296  			*pin6 = ireq->ir_v6_loc_addr;
cf34ce3d Song Liu    2017-10-30  297  			pin6 = (struct in6_addr *)__entry->daddr_v6;
cf34ce3d Song Liu    2017-10-30  298  			*pin6 = ireq->ir_v6_rmt_addr;
cf34ce3d Song Liu    2017-10-30  299  		} else
cf34ce3d Song Liu    2017-10-30  300  #endif
cf34ce3d Song Liu    2017-10-30  301  		{
cf34ce3d Song Liu    2017-10-30  302  			pin6 = (struct in6_addr *)__entry->saddr_v6;
cf34ce3d Song Liu    2017-10-30  303  			ipv6_addr_set_v4mapped(ireq->ir_loc_addr, pin6);
cf34ce3d Song Liu    2017-10-30  304  			pin6 = (struct in6_addr *)__entry->daddr_v6;
cf34ce3d Song Liu    2017-10-30  305  			ipv6_addr_set_v4mapped(ireq->ir_rmt_addr, pin6);
cf34ce3d Song Liu    2017-10-30  306  		}
cf34ce3d Song Liu    2017-10-30  307  	),
cf34ce3d Song Liu    2017-10-30  308  
cf34ce3d Song Liu    2017-10-30  309  	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
cf34ce3d Song Liu    2017-10-30  310  		  __entry->sport, __entry->dport,
cf34ce3d Song Liu    2017-10-30  311  		  __entry->saddr, __entry->daddr,
cf34ce3d Song Liu    2017-10-30  312  		  __entry->saddr_v6, __entry->daddr_v6)
cf34ce3d Song Liu    2017-10-30  313  );
cf34ce3d Song Liu    2017-10-30  314  
e086101b Cong Wang   2017-10-13  315  #endif /* _TRACE_TCP_H */
e086101b Cong Wang   2017-10-13  316  
e086101b Cong Wang   2017-10-13  317  /* This part must be outside protection */
e086101b Cong Wang   2017-10-13 @318  #include <trace/define_trace.h>

:::::: The code at line 245 was first introduced by commit
:::::: e8fce23946b7e7eadf25ad78d8207c22903dfe27 tcp: add tracepoint trace_tcp_set_state()

:::::: TO: Song Liu <songliubraving@fb.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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 23936 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state
  2017-11-09 14:26 [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state Yafang Shao
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
  2017-11-12 13:46 ` [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state kbuild test robot
@ 2017-11-12 15:10 ` kbuild test robot
  2017-11-12 17:15 ` kbuild test robot
  3 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2017-11-12 15:10 UTC (permalink / raw)
  To: Yafang Shao
  Cc: kbuild-all, davem, kuznet, yoshfuji, rostedt, mingo, netdev,
	linux-kernel, Yafang Shao

[-- Attachment #1: Type: text/plain, Size: 4101 bytes --]

Hi Yafang,

Thank you for the patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Yafang-Shao/net-tcp-track-all-TCP-IP-state-transition-in-tcp_set_state/20171112-203643
config: mips-malta_kvm_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   In file included from include/net/tcp.h:49:0,
                    from net/netfilter/ipvs/ip_vs_proto_tcp.c:27:
   include/trace/events/tcp.h:12:31: error: expected identifier or '(' before '{' token
    #define tcp_state_name(state) { state, #state }
                                  ^
   net/netfilter/ipvs/ip_vs_proto_tcp.c:424:21: note: in expansion of macro 'tcp_state_name'
    static const char * tcp_state_name(int state)
                        ^~~~~~~~~~~~~~
   net/netfilter/ipvs/ip_vs_proto_tcp.c:425:1: error: expected identifier or '(' before '{' token
    {
    ^
>> net/netfilter/ipvs/ip_vs_proto_tcp.c:737:17: error: 'tcp_state_name' undeclared here (not in a function); did you mean 'tcp_state_idx'?
     .state_name =  tcp_state_name,
                    ^~~~~~~~~~~~~~
                    tcp_state_idx

vim +737 net/netfilter/ipvs/ip_vs_proto_tcp.c

^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  718  
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  719  
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  720  struct ip_vs_protocol ip_vs_protocol_tcp = {
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  721  	.name =			"TCP",
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  722  	.protocol =		IPPROTO_TCP,
2ad17defd net/ipv4/ipvs/ip_vs_proto_tcp.c      Julian Anastasov 2008-04-29  723  	.num_states =		IP_VS_TCP_S_LAST,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  724  	.dont_defrag =		0,
4a85b96c0 net/netfilter/ipvs/ip_vs_proto_tcp.c Hans Schillstrom 2011-01-03  725  	.init =			NULL,
4a85b96c0 net/netfilter/ipvs/ip_vs_proto_tcp.c Hans Schillstrom 2011-01-03  726  	.exit =			NULL,
4a85b96c0 net/netfilter/ipvs/ip_vs_proto_tcp.c Hans Schillstrom 2011-01-03  727  	.init_netns =		__ip_vs_tcp_init,
4a85b96c0 net/netfilter/ipvs/ip_vs_proto_tcp.c Hans Schillstrom 2011-01-03  728  	.exit_netns =		__ip_vs_tcp_exit,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  729  	.register_app =		tcp_register_app,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  730  	.unregister_app =	tcp_unregister_app,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  731  	.conn_schedule =	tcp_conn_schedule,
5c0d2374a net/netfilter/ipvs/ip_vs_proto_tcp.c Simon Horman     2010-08-02  732  	.conn_in_get =		ip_vs_conn_in_get_proto,
5c0d2374a net/netfilter/ipvs/ip_vs_proto_tcp.c Simon Horman     2010-08-02  733  	.conn_out_get =		ip_vs_conn_out_get_proto,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  734  	.snat_handler =		tcp_snat_handler,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  735  	.dnat_handler =		tcp_dnat_handler,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16  736  	.csum_check =		tcp_csum_check,
^1da177e4 net/ipv4/ipvs/ip_vs_proto_tcp.c      Linus Torvalds   2005-04-16 @737  	.state_name =		tcp_state_name,

:::::: The code at line 737 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 19170 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint
  2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
  2017-11-09 14:52   ` Eric Dumazet
  2017-11-12 14:15   ` kbuild test robot
@ 2017-11-12 15:40   ` kbuild test robot
  2 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2017-11-12 15:40 UTC (permalink / raw)
  To: Yafang Shao
  Cc: kbuild-all, davem, kuznet, yoshfuji, rostedt, mingo, netdev,
	linux-kernel, Yafang Shao

[-- Attachment #1: Type: text/plain, Size: 12603 bytes --]

Hi Yafang,

Thank you for the patch! Yet something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Yafang-Shao/net-tcp-track-all-TCP-IP-state-transition-in-tcp_set_state/20171112-203643
config: mips-malta_kvm_defconfig (attached as .config)
compiler: mipsel-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=mips 

All errors (new ones prefixed by >>):

   In file included from include/trace/define_trace.h:96:0,
                    from include/trace/events/tcp.h:318,
                    from net//core/net-traces.c:35:
   include/trace/events/tcp.h: In function 'trace_event_raw_event_tcp_set_state':
>> include/trace/events/tcp.h:245:27: error: 'inet' undeclared (first use in this function); did you mean 'net'?
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   include/trace/events/tcp.h:245:27: note: each undeclared identifier is reported only once for each function it appears in
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/trace_events.h:719:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~
   In file included from include/trace/define_trace.h:97:0,
                    from include/trace/events/tcp.h:318,
                    from net//core/net-traces.c:35:
   include/trace/events/tcp.h: In function 'perf_trace_tcp_set_state':
>> include/trace/events/tcp.h:245:27: error: 'inet' undeclared (first use in this function); did you mean 'net'?
       ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
                              ^
   include/trace/perf.h:66:4: note: in definition of macro 'DECLARE_EVENT_CLASS'
     { assign; }       \
       ^~~~~~
   include/trace/trace_events.h:78:9: note: in expansion of macro 'PARAMS'
            PARAMS(assign),         \
            ^~~~~~
   include/trace/events/tcp.h:180:1: note: in expansion of macro 'TRACE_EVENT'
    TRACE_EVENT(tcp_set_state,
    ^~~~~~~~~~~
   include/trace/events/tcp.h:198:2: note: in expansion of macro 'TP_fast_assign'
     TP_fast_assign(
     ^~~~~~~~~~~~~~

vim +245 include/trace/events/tcp.h

e8fce239 Song Liu    2017-10-23  181  
e8fce239 Song Liu    2017-10-23  182  	TP_PROTO(const struct sock *sk, const int oldstate, const int newstate),
e8fce239 Song Liu    2017-10-23  183  
e8fce239 Song Liu    2017-10-23  184  	TP_ARGS(sk, oldstate, newstate),
e8fce239 Song Liu    2017-10-23  185  
e8fce239 Song Liu    2017-10-23  186  	TP_STRUCT__entry(
e8fce239 Song Liu    2017-10-23  187  		__field(const void *, skaddr)
e8fce239 Song Liu    2017-10-23  188  		__field(int, oldstate)
e8fce239 Song Liu    2017-10-23  189  		__field(int, newstate)
e8fce239 Song Liu    2017-10-23  190  		__field(__u16, sport)
e8fce239 Song Liu    2017-10-23  191  		__field(__u16, dport)
e8fce239 Song Liu    2017-10-23  192  		__array(__u8, saddr, 4)
e8fce239 Song Liu    2017-10-23  193  		__array(__u8, daddr, 4)
e8fce239 Song Liu    2017-10-23  194  		__array(__u8, saddr_v6, 16)
e8fce239 Song Liu    2017-10-23  195  		__array(__u8, daddr_v6, 16)
e8fce239 Song Liu    2017-10-23  196  	),
e8fce239 Song Liu    2017-10-23  197  
e8fce239 Song Liu    2017-10-23  198  	TP_fast_assign(
e8fce239 Song Liu    2017-10-23  199  		struct in6_addr *pin6;
e8fce239 Song Liu    2017-10-23  200  		__be32 *p32;
e8fce239 Song Liu    2017-10-23  201  
e8fce239 Song Liu    2017-10-23  202  		__entry->skaddr = sk;
e8fce239 Song Liu    2017-10-23  203  		__entry->oldstate = oldstate;
e8fce239 Song Liu    2017-10-23  204  		__entry->newstate = newstate;
e8fce239 Song Liu    2017-10-23  205  
e346c952 Yafang Shao 2017-11-09  206  		if (oldstate == TCP_TIME_WAIT) {
e346c952 Yafang Shao 2017-11-09  207  			__entry->sport = ntohs(inet_twsk(sk)->tw_sport);
e346c952 Yafang Shao 2017-11-09  208  			__entry->dport = ntohs(inet_twsk(sk)->tw_dport);
e8fce239 Song Liu    2017-10-23  209  
e8fce239 Song Liu    2017-10-23  210  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  211  			*p32 = inet_twsk(sk)->tw_rcv_saddr;
e8fce239 Song Liu    2017-10-23  212  
e8fce239 Song Liu    2017-10-23  213  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  214  			*p32 = inet_twsk(sk)->tw_daddr;
e346c952 Yafang Shao 2017-11-09  215  		} else if (oldstate == TCP_NEW_SYN_RECV) {
e346c952 Yafang Shao 2017-11-09  216  			__entry->sport = inet_rsk(inet_reqsk(sk))->ir_num;
e346c952 Yafang Shao 2017-11-09  217  			__entry->dport = ntohs(inet_rsk(inet_reqsk(sk))->ir_rmt_port);
e346c952 Yafang Shao 2017-11-09  218  
e346c952 Yafang Shao 2017-11-09  219  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  220  			*p32 = inet_rsk(inet_reqsk(sk))->ir_loc_addr;
e346c952 Yafang Shao 2017-11-09  221  
e346c952 Yafang Shao 2017-11-09  222  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  223  			*p32 = inet_rsk(inet_reqsk(sk))->ir_rmt_addr;
e346c952 Yafang Shao 2017-11-09  224  		} else {
e346c952 Yafang Shao 2017-11-09  225  			__entry->sport = ntohs(inet_sk(sk)->inet_sport);
e346c952 Yafang Shao 2017-11-09  226  			__entry->dport = ntohs(inet_sk(sk)->inet_dport);
e346c952 Yafang Shao 2017-11-09  227  
e346c952 Yafang Shao 2017-11-09  228  			p32 = (__be32 *) __entry->saddr;
e346c952 Yafang Shao 2017-11-09  229  			*p32 = inet_sk(sk)->inet_saddr;
e346c952 Yafang Shao 2017-11-09  230  
e346c952 Yafang Shao 2017-11-09  231  			p32 = (__be32 *) __entry->daddr;
e346c952 Yafang Shao 2017-11-09  232  			*p32 =  inet_sk(sk)->inet_daddr;
e346c952 Yafang Shao 2017-11-09  233  		}
e8fce239 Song Liu    2017-10-23  234  
e8fce239 Song Liu    2017-10-23  235  #if IS_ENABLED(CONFIG_IPV6)
e8fce239 Song Liu    2017-10-23  236  		if (sk->sk_family == AF_INET6) {
e8fce239 Song Liu    2017-10-23  237  			pin6 = (struct in6_addr *)__entry->saddr_v6;
e8fce239 Song Liu    2017-10-23  238  			*pin6 = sk->sk_v6_rcv_saddr;
e8fce239 Song Liu    2017-10-23  239  			pin6 = (struct in6_addr *)__entry->daddr_v6;
e8fce239 Song Liu    2017-10-23  240  			*pin6 = sk->sk_v6_daddr;
e8fce239 Song Liu    2017-10-23  241  		} else
e8fce239 Song Liu    2017-10-23  242  #endif
e8fce239 Song Liu    2017-10-23  243  		{
e8fce239 Song Liu    2017-10-23  244  			pin6 = (struct in6_addr *)__entry->saddr_v6;
e8fce239 Song Liu    2017-10-23 @245  			ipv6_addr_set_v4mapped(inet->inet_saddr, pin6);
e8fce239 Song Liu    2017-10-23  246  			pin6 = (struct in6_addr *)__entry->daddr_v6;
e8fce239 Song Liu    2017-10-23  247  			ipv6_addr_set_v4mapped(inet->inet_daddr, pin6);
e8fce239 Song Liu    2017-10-23  248  		}
e8fce239 Song Liu    2017-10-23  249  	),
e8fce239 Song Liu    2017-10-23  250  
e8fce239 Song Liu    2017-10-23  251  	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c oldstate=%s newstate=%s",
e8fce239 Song Liu    2017-10-23  252  		  __entry->sport, __entry->dport,
e8fce239 Song Liu    2017-10-23  253  		  __entry->saddr, __entry->daddr,
e8fce239 Song Liu    2017-10-23  254  		  __entry->saddr_v6, __entry->daddr_v6,
e8fce239 Song Liu    2017-10-23  255  		  show_tcp_state_name(__entry->oldstate),
e8fce239 Song Liu    2017-10-23  256  		  show_tcp_state_name(__entry->newstate))
e8fce239 Song Liu    2017-10-23  257  );
e8fce239 Song Liu    2017-10-23  258  
cf34ce3d Song Liu    2017-10-30  259  TRACE_EVENT(tcp_retransmit_synack,
cf34ce3d Song Liu    2017-10-30  260  
cf34ce3d Song Liu    2017-10-30  261  	TP_PROTO(const struct sock *sk, const struct request_sock *req),
cf34ce3d Song Liu    2017-10-30  262  
cf34ce3d Song Liu    2017-10-30  263  	TP_ARGS(sk, req),
cf34ce3d Song Liu    2017-10-30  264  
cf34ce3d Song Liu    2017-10-30  265  	TP_STRUCT__entry(
cf34ce3d Song Liu    2017-10-30  266  		__field(const void *, skaddr)
cf34ce3d Song Liu    2017-10-30  267  		__field(const void *, req)
cf34ce3d Song Liu    2017-10-30  268  		__field(__u16, sport)
cf34ce3d Song Liu    2017-10-30  269  		__field(__u16, dport)
cf34ce3d Song Liu    2017-10-30  270  		__array(__u8, saddr, 4)
cf34ce3d Song Liu    2017-10-30  271  		__array(__u8, daddr, 4)
cf34ce3d Song Liu    2017-10-30  272  		__array(__u8, saddr_v6, 16)
cf34ce3d Song Liu    2017-10-30  273  		__array(__u8, daddr_v6, 16)
cf34ce3d Song Liu    2017-10-30  274  	),
cf34ce3d Song Liu    2017-10-30  275  
cf34ce3d Song Liu    2017-10-30  276  	TP_fast_assign(
cf34ce3d Song Liu    2017-10-30  277  		struct inet_request_sock *ireq = inet_rsk(req);
cf34ce3d Song Liu    2017-10-30  278  		struct in6_addr *pin6;
cf34ce3d Song Liu    2017-10-30  279  		__be32 *p32;
cf34ce3d Song Liu    2017-10-30  280  
cf34ce3d Song Liu    2017-10-30  281  		__entry->skaddr = sk;
cf34ce3d Song Liu    2017-10-30  282  		__entry->req = req;
cf34ce3d Song Liu    2017-10-30  283  
cf34ce3d Song Liu    2017-10-30  284  		__entry->sport = ireq->ir_num;
cf34ce3d Song Liu    2017-10-30  285  		__entry->dport = ntohs(ireq->ir_rmt_port);
cf34ce3d Song Liu    2017-10-30  286  
cf34ce3d Song Liu    2017-10-30  287  		p32 = (__be32 *) __entry->saddr;
cf34ce3d Song Liu    2017-10-30  288  		*p32 = ireq->ir_loc_addr;
cf34ce3d Song Liu    2017-10-30  289  
cf34ce3d Song Liu    2017-10-30  290  		p32 = (__be32 *) __entry->daddr;
cf34ce3d Song Liu    2017-10-30  291  		*p32 = ireq->ir_rmt_addr;
cf34ce3d Song Liu    2017-10-30  292  
cf34ce3d Song Liu    2017-10-30  293  #if IS_ENABLED(CONFIG_IPV6)
cf34ce3d Song Liu    2017-10-30  294  		if (sk->sk_family == AF_INET6) {
cf34ce3d Song Liu    2017-10-30  295  			pin6 = (struct in6_addr *)__entry->saddr_v6;
cf34ce3d Song Liu    2017-10-30  296  			*pin6 = ireq->ir_v6_loc_addr;
cf34ce3d Song Liu    2017-10-30  297  			pin6 = (struct in6_addr *)__entry->daddr_v6;
cf34ce3d Song Liu    2017-10-30  298  			*pin6 = ireq->ir_v6_rmt_addr;
cf34ce3d Song Liu    2017-10-30  299  		} else
cf34ce3d Song Liu    2017-10-30  300  #endif
cf34ce3d Song Liu    2017-10-30  301  		{
cf34ce3d Song Liu    2017-10-30  302  			pin6 = (struct in6_addr *)__entry->saddr_v6;
cf34ce3d Song Liu    2017-10-30  303  			ipv6_addr_set_v4mapped(ireq->ir_loc_addr, pin6);
cf34ce3d Song Liu    2017-10-30  304  			pin6 = (struct in6_addr *)__entry->daddr_v6;
cf34ce3d Song Liu    2017-10-30  305  			ipv6_addr_set_v4mapped(ireq->ir_rmt_addr, pin6);
cf34ce3d Song Liu    2017-10-30  306  		}
cf34ce3d Song Liu    2017-10-30  307  	),
cf34ce3d Song Liu    2017-10-30  308  
cf34ce3d Song Liu    2017-10-30  309  	TP_printk("sport=%hu dport=%hu saddr=%pI4 daddr=%pI4 saddrv6=%pI6c daddrv6=%pI6c",
cf34ce3d Song Liu    2017-10-30  310  		  __entry->sport, __entry->dport,
cf34ce3d Song Liu    2017-10-30  311  		  __entry->saddr, __entry->daddr,
cf34ce3d Song Liu    2017-10-30  312  		  __entry->saddr_v6, __entry->daddr_v6)
cf34ce3d Song Liu    2017-10-30  313  );
cf34ce3d Song Liu    2017-10-30  314  
e086101b Cong Wang   2017-10-13  315  #endif /* _TRACE_TCP_H */
e086101b Cong Wang   2017-10-13  316  
e086101b Cong Wang   2017-10-13  317  /* This part must be outside protection */
e086101b Cong Wang   2017-10-13 @318  #include <trace/define_trace.h>

:::::: The code at line 245 was first introduced by commit
:::::: e8fce23946b7e7eadf25ad78d8207c22903dfe27 tcp: add tracepoint trace_tcp_set_state()

:::::: TO: Song Liu <songliubraving@fb.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

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 19170 bytes --]

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state
  2017-11-09 14:26 [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state Yafang Shao
                   ` (2 preceding siblings ...)
  2017-11-12 15:10 ` kbuild test robot
@ 2017-11-12 17:15 ` kbuild test robot
  3 siblings, 0 replies; 11+ messages in thread
From: kbuild test robot @ 2017-11-12 17:15 UTC (permalink / raw)
  To: Yafang Shao
  Cc: kbuild-all, davem, kuznet, yoshfuji, rostedt, mingo, netdev,
	linux-kernel, Yafang Shao

Hi Yafang,

Thank you for the patch! Perhaps something to improve:

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

url:    https://github.com/0day-ci/linux/commits/Yafang-Shao/net-tcp-track-all-TCP-IP-state-transition-in-tcp_set_state/20171112-203643
reproduce:
        # apt-get install sparse
        make ARCH=x86_64 allmodconfig
        make C=1 CF=-D__CHECK_ENDIAN__


sparse warnings: (new ones prefixed by >>)


vim +/return +428 net/netfilter/ipvs/ip_vs_proto_tcp.c

^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  423  
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16 @424  static const char * tcp_state_name(int state)
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  425  {
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  426  	if (state >= IP_VS_TCP_S_LAST)
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  427  		return "ERR!";
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16 @428  	return tcp_state_name_table[state] ? tcp_state_name_table[state] : "?";
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  429  }
^1da177e net/ipv4/ipvs/ip_vs_proto_tcp.c Linus Torvalds 2005-04-16  430  

:::::: The code at line 428 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2017-11-12 17:16 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 14:26 [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state Yafang Shao
2017-11-09 14:26 ` [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Yafang Shao
2017-11-09 14:52   ` Eric Dumazet
2017-11-09 14:58     ` Eric Dumazet
2017-11-09 15:11       ` Yafang Shao
2017-11-09 15:18         ` Eric Dumazet
2017-11-12 14:15   ` kbuild test robot
2017-11-12 15:40   ` kbuild test robot
2017-11-12 13:46 ` [PATCH net-next 1/2] net/tcp: track all TCP/IP state transition in tcp_set_state kbuild test robot
2017-11-12 15:10 ` kbuild test robot
2017-11-12 17:15 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).