From patchwork Wed Sep 21 02:43:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Neal Cardwell X-Patchwork-Id: 672540 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sf3q965jSz9t0X for ; Wed, 21 Sep 2016 12:44:05 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b=cfXwlLNk; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755541AbcIUCoC (ORCPT ); Tue, 20 Sep 2016 22:44:02 -0400 Received: from mail-qk0-f175.google.com ([209.85.220.175]:34794 "EHLO mail-qk0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754843AbcIUCoB (ORCPT ); Tue, 20 Sep 2016 22:44:01 -0400 Received: by mail-qk0-f175.google.com with SMTP id n185so33948629qke.1 for ; Tue, 20 Sep 2016 19:44:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=K71pTCdQpKhCvTJX55fK7diFouY+wj/B5fmvjjjo6Ko=; b=cfXwlLNkK5RUpJyC+bgcLNiK0gV5XASI5L2bof94Ay1SNPqF14d2qENZi13Gu7jfcm suiH5lC9QOKYMBHagyFvQFoKGuWDQhJSB9WI/TYPrQhVzNppv583Goq5BfB4mUncoWmI AHBXlzg4gsBZ4SZDpURzEAZhbQM3Nq/UbMBkW62foNc6XJC2hlgBpDVOdFQIn5CBG2xP KrvpCvU4MZu8uc6O3919EZ3bMeXhsaB4Lmdq433+eKDUEgVyPTBPCtu2c9SYhcky2uTF ADJNaQ5jx5LXZMMswKYBWhqFVVJSRYG9Hvr6cIgQQlwKwNknwgmHFMqoW/OtOXOhcwJh obmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=K71pTCdQpKhCvTJX55fK7diFouY+wj/B5fmvjjjo6Ko=; b=hYiThtKJp8cMzuw9jmTiMKb0QJhLkjCjnSwfSJ3qK5ClKvBkvZ3Q00IG2mC2Y/4GPw IIh2+MvVmM8Wxr4X/80kNiSJjCYyfSGTg+4DzCRJ9MnUBZC33NoE1IAN+GZ/XY57+3ED mmQxsGI+rCnEXiUlGrbNDl7xhVD/XwHxZtbZooA8uggM9wvsbHyAmBuOuxRUOODoLtxw OHD3iobuVtDseCP96T7bBP8UWYySgZma+HHcD2bGnZdt4MmtUnY5SMTuMrwg1B2WDsIJ s1CBcuDO+7xlCAnvTHv/NeiLeJ5QY3FHeZhTXQeGuOuuxRs+LzKu39osQ4y2YvBhZbTl 57KA== X-Gm-Message-State: AE9vXwN1D9xdRmOoxRhSRnz8/E99ZWw47RzxLvtfpx44YixYySplqTpqL3eqzIpYr7KJbNWI X-Received: by 10.55.200.201 with SMTP id t70mr38122060qkl.238.1474425835279; Tue, 20 Sep 2016 19:43:55 -0700 (PDT) Received: from joy.nyc.corp.google.com ([100.101.230.104]) by smtp.gmail.com with ESMTPSA id r187sm17781451qkc.49.2016.09.20.19.43.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 20 Sep 2016 19:43:54 -0700 (PDT) From: Neal Cardwell To: Stephen Hemminger Cc: netdev@vger.kernel.org, Neal Cardwell , Yuchung Cheng , Eric Dumazet , Soheil Hassas Yeganeh Subject: [PATCH iproute2 3/3] ss: output TCP BBR diag information Date: Tue, 20 Sep 2016 22:43:44 -0400 Message-Id: <1474425824-22646-3-git-send-email-ncardwell@google.com> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1474425824-22646-1-git-send-email-ncardwell@google.com> References: <1474425824-22646-1-git-send-email-ncardwell@google.com> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Dump useful TCP BBR state information from a struct tcp_bbr_info that was grabbed using the inet_diag API. We tolerate info that is shorter or longer than expected, in case the kernel is older or newer than the ss binary. We simply print the minimum of what is expected from the kernel and what is provided from the kernel. We use the same trick as that used for struct tcp_info: when the info from the kernel is shorter than we hoped, we pad the end with zeroes, and don't print fields if they are zero. The BBR output looks like: bbr:(bw:1.2Mbps,mrtt:18.965,pacing_gain:2.88672,cwnd_gain:2.88672) The motivation here is to be consistent with DCTCP, which looks like: dctcp(ce_state:23,alpha:23,ab_ecn:23,ab_tot:23) Signed-off-by: Neal Cardwell Signed-off-by: Yuchung Cheng Signed-off-by: Eric Dumazet Signed-off-by: Soheil Hassas Yeganeh --- misc/ss.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/misc/ss.c b/misc/ss.c index 9c456d4..14fff46 100644 --- a/misc/ss.c +++ b/misc/ss.c @@ -784,6 +784,7 @@ struct tcpstat { bool has_fastopen_opt; bool has_wscale_opt; struct dctcpstat *dctcp; + struct tcp_bbr_info *bbr_info; }; static void sock_state_print(struct sockstat *s, const char *sock_name) @@ -1727,6 +1728,25 @@ static void tcp_stats_print(struct tcpstat *s) printf(" dctcp:fallback_mode"); } + if (s->bbr_info) { + __u64 bw; + + bw = s->bbr_info->bbr_bw_hi; + bw <<= 32; + bw |= s->bbr_info->bbr_bw_lo; + + printf(" bbr:(bw:%sbps,mrtt:%g", + sprint_bw(b1, bw * 8.0), + (double)s->bbr_info->bbr_min_rtt / 1000.0); + if (s->bbr_info->bbr_pacing_gain) + printf(",pacing_gain:%g", + (double)s->bbr_info->bbr_pacing_gain / 256.0); + if (s->bbr_info->bbr_cwnd_gain) + printf(",cwnd_gain:%g", + (double)s->bbr_info->bbr_cwnd_gain / 256.0); + printf(")"); + } + if (s->send_bps) printf(" send %sbps", sprint_bw(b1, s->send_bps)); if (s->lastsnd) @@ -2005,6 +2025,16 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r, s.dctcp = dctcp; } + if (tb[INET_DIAG_BBRINFO]) { + const void *bbr_info = RTA_DATA(tb[INET_DIAG_BBRINFO]); + int len = min(RTA_PAYLOAD(tb[INET_DIAG_BBRINFO]), + sizeof(*s.bbr_info)); + + s.bbr_info = calloc(1, sizeof(*s.bbr_info)); + if (s.bbr_info && bbr_info) + memcpy(s.bbr_info, bbr_info, len); + } + if (rtt > 0 && info->tcpi_snd_mss && info->tcpi_snd_cwnd) { s.send_bps = (double) info->tcpi_snd_cwnd * (double)info->tcpi_snd_mss * 8000000. / rtt; @@ -2027,6 +2057,7 @@ static void tcp_show_info(const struct nlmsghdr *nlh, struct inet_diag_msg *r, s.min_rtt = (double) info->tcpi_min_rtt / 1000; tcp_stats_print(&s); free(s.dctcp); + free(s.bbr_info); } }