Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754281AbdLHPnA (ORCPT ); Fri, 8 Dec 2017 10:43:00 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:54810 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754041AbdLHPm6 (ORCPT ); Fri, 8 Dec 2017 10:42:58 -0500 Date: Fri, 08 Dec 2017 10:42:56 -0500 (EST) Message-Id: <20171208.104256.1026704308758536035.davem@davemloft.net> To: laoar.shao@gmail.com Cc: marcelo.leitner@gmail.com, songliubraving@fb.com, kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, rostedt@goodmis.org, bgregg@netflix.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v5 net-next] net/tcp: trace all TCP/IP state transition with tcp_set_state tracepoint From: David Miller In-Reply-To: References: <20171207200245.GQ13341@localhost.localdomain> X-Mailer: Mew version 6.7 on Emacs 25.3 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Fri, 08 Dec 2017 07:42:57 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 775 Lines: 29 From: Yafang Shao Date: Fri, 8 Dec 2017 11:40:23 +0800 > It will looks like these, > > if (sk->sk_protocol == IPPROTO_TCP) > __tcp_set_state(newsk, TCP_SYN_RECV); > else > newsk->sk_state = TCP_SYN_RECV; > > > if (sk->sk_protocol == IPPROTO_TCP) > __tcp_set_state(sk, TCP_CLOSE); > else > sk->sk_state = TCP_CLOSE; > > if (sk->sk_protocol == IPPROTO_TCP) > tcp_state_store(sk, state); > else > sk_state_store(sk, state); > > > Some redundant code. > > IMO, put these similar code into a wrapper is more nice. I think this discussion and how ugly this is getting shows that tracing the state transitions of a socket is perhaps not best as a TCP specific feature.