Received: by 10.223.164.202 with SMTP id h10csp291094wrb; Thu, 9 Nov 2017 06:27:40 -0800 (PST) X-Google-Smtp-Source: ABhQp+SC9klt0ti1AKTtsBx5EMEBFHRsEjr2Vqr9klT4ddo4ND9SYRE/gm7BA4b0D1irsfzg/efV X-Received: by 10.101.67.66 with SMTP id k2mr662503pgq.20.1510237660267; Thu, 09 Nov 2017 06:27:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510237660; cv=none; d=google.com; s=arc-20160816; b=BH4R8fb9hMhhC2Z+viNL3HjuBwhUi7DD/gtdGqBbVXSnWjk2G9HhuaEStWUGrFOVsW Z2ppb+TnldQsJe9DbsXcrMc2j2vAHlw1EoBZLF/lBW0FA9LPXt/qz655P+VyPd/h2eMB hHIOuNtQrvVLO9aMRPk9hN9BgEeH0snnniQx/s+ioTWI6/r5rri1c0W8YJ4QA86rD+mo PaZqPXygaM8z73NuvrFLWBWSrP3eHjZjRVNrz/2anid1WSiWCQyxy82QiXrU0rzacueP A5C07D1tQqlfDNmK4+yiFFL7SSDKPvh3q5UPETFSLwix2mPiv+nuJfEHVMMiEAy1QdEJ dYPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=GbQ2504UsN8M1nUg10j36sxQzkXcS0gU7+++2H0xEag=; b=mFaTmEEjTjS1rDJ8TxXk8kOHXdt2kN5+du5UR/sYrpJFvbpToxfnd2wwCibmrgDam3 mhjkRfSnrp4igBb3GwyKX0z/XvnTB1Qu3eaR3LHXVGdCYxA81bs2hau+Ns7T22y1Ag+4 0bG/sGnsle2vKUxe+feOhsOvWZy+cbU+HrGswNXnH5WVcBhCZRL0h/yzLQt4C2NYpAT4 JNNpRB2s6gAORAO2yfMPJBBYllUZAfVuOhGdcMhQEhdvfcmJuPdrevu/EGyAMAriXAvF U2RYsZwzCxUKIQbs2EfBe+1QzRhcEQ/whfXaWfntun+uzf0Yc3VCIYzny0SkxPwHKSop PbEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cpoaDhSV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l30si6609692pgu.565.2017.11.09.06.27.29; Thu, 09 Nov 2017 06:27:40 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cpoaDhSV; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755091AbdKIO0l (ORCPT + 80 others); Thu, 9 Nov 2017 09:26:41 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:51187 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755066AbdKIO0i (ORCPT ); Thu, 9 Nov 2017 09:26:38 -0500 Received: by mail-pf0-f194.google.com with SMTP id b6so4376119pfh.7; Thu, 09 Nov 2017 06:26:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GbQ2504UsN8M1nUg10j36sxQzkXcS0gU7+++2H0xEag=; b=cpoaDhSVoGnfHxNBwB+GPlgWwsT+Bg9J43JIVPG+eeJlSS9MVbLuzhzenv7mIP96uo AUzSIf8bXn2guoUHxXUEN5URURowSs0VjZEB53YY0rh+ptXeaRLvbTxFE7rCqakXFUPr AdtwDE/Ba0b2dRp1fB1MMt2wXHlWqUVg7QiXl0oGRv/tP1GX4Gwi70QBx5D2HzBchkM5 F0cW9RhmjG05XSFxyFWP90v23qpSGdxo7c1J3xxVTgXpIQxkZpPDqUaTXfPPsrutgATq JV+ccRIE3KVdCTB/0iTH5q8DnM8N7QitvJzZIaoCg0Y9ZFdx/fD47B+X0TGdUTsasShF aiMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GbQ2504UsN8M1nUg10j36sxQzkXcS0gU7+++2H0xEag=; b=AHePhg+mP44D9Acrou7FRmBOeZETusQjpOVg1mFFCBTHpshpJ7/ZvJs9ExkUnA5gVP x7UoiGaiEKDgvuU75HX4NgIDQMMiaO97iMlaqs7gFnaJlbaepWZmpdwcK1igfkdA0czY cjztUL2Jhu1gZoh0sEUY8o7uuuVkWyed2aortAhWnlhTEsHq0ItwCVl5Hg4Gf8eRM4jr qE48PYC1zPe3PHhiRqpdwfv/QRwprY5dEbkxh4a+8VUi2SqP/4ydObyysjG5rAK9WVaW GOg23hjr+90/f/2bPQivSTJJ/PE+JeMyozi+3co9m7Tk4y+AFnNeEtjs5dlmExU4GO7w gqmA== X-Gm-Message-State: AJaThX5e8wHYds2kFYXa31Ki6sSPrNMrqPDx2QFrcHe50eqPL94rXvqS 8MpHzgL70N4ceO5UIIRg6jA= X-Received: by 10.98.137.156 with SMTP id n28mr655264pfk.93.1510237598438; Thu, 09 Nov 2017 06:26:38 -0800 (PST) Received: from li1588-6.members.linode.com (li1588-6.members.linode.com. [139.162.104.6]) by smtp.gmail.com with ESMTPSA id p12sm9073146pgn.60.2017.11.09.06.26.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Nov 2017 06:26:37 -0800 (PST) From: Yafang Shao To: davem@davemloft.net Cc: kuznet@ms2.inr.ac.ru, yoshfuji@linux-ipv6.org, rostedt@goodmis.org, mingo@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Yafang Shao Subject: [PATCH net-next 2/2] tcp: handle TCP_TIME_WAIT/TCP_NEW_SYN_RECV in tcp_set_state tracepoint Date: Thu, 9 Nov 2017 14:26:04 +0000 Message-Id: <1510237564-6013-2-git-send-email-laoar.shao@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1510237564-6013-1-git-send-email-laoar.shao@gmail.com> References: <1510237564-6013-1-git-send-email-laoar.shao@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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 From 1583749300694223771@xxx Sat Nov 11 06:17:11 +0000 2017 X-GM-THRID: 1583749300694223771 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread