From patchwork Fri Sep 5 23:54:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 386544 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 7DD1F1400D7 for ; Sat, 6 Sep 2014 09:54:12 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751405AbaIEXyJ (ORCPT ); Fri, 5 Sep 2014 19:54:09 -0400 Received: from mail-pa0-f44.google.com ([209.85.220.44]:61164 "EHLO mail-pa0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751047AbaIEXyG (ORCPT ); Fri, 5 Sep 2014 19:54:06 -0400 Received: by mail-pa0-f44.google.com with SMTP id rd3so23326449pab.31 for ; Fri, 05 Sep 2014 16:54:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:subject:from:to:cc:date:content-type :content-transfer-encoding:mime-version; bh=QM9kulZMpoYNOddbiRqeWxNELZixaPy10wf++pL2PaI=; b=lydshjUNiemrAdXi/m3QTss/lAyHWuc92xQOWfB5Fq8gjk5fbgd79sIKjfHjIcBoYc iiBLMx2UMAg7E9fCSNtlz8HXSevt3Rd+vfY2U0TikzzlVZEkDTwkdsXTeqypym732aBQ 3iLJ96qjdlYcUoWumj6jCZmEaTX/TtHxL33yoveh4zeb9kMrocPHM8CT/NcGCmExptxO os+5DLeKN98/3K/g9vC5lu7TOb1UdMwwTKaIcEgYYCnMGtRhJ0ppqoMb/YpetkbckUTm +MceindxZJqkbFOwl6UYZfbVlcqhimlqsFgJ9r9ko7SXp6HjQi/AgmKTQNVwf0+SYvSe S6fg== X-Received: by 10.70.131.70 with SMTP id ok6mr26540789pdb.133.1409961245150; Fri, 05 Sep 2014 16:54:05 -0700 (PDT) Received: from ?IPv6:2620:0:1000:3e02:85f:b410:9535:d5c1? ([2620:0:1000:3e02:85f:b410:9535:d5c1]) by mx.google.com with ESMTPSA id kk7sm2841709pab.31.2014.09.05.16.54.04 for (version=SSLv3 cipher=RC4-SHA bits=128/128); Fri, 05 Sep 2014 16:54:04 -0700 (PDT) Message-ID: <1409961244.26422.142.camel@edumazet-glaptop2.roam.corp.google.com> Subject: [PATCH iproute2] ip: support of usec rtt in tcp_metrics From: Eric Dumazet To: Stephen Hemminger Cc: netdev Date: Fri, 05 Sep 2014 16:54:04 -0700 X-Mailer: Evolution 3.2.3-0ubuntu6 Mime-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet Starting from linux-3.15, kernel supports new tcp metric attributes : TCP_METRIC_RTT_US & TCP_METRIC_RTTVAR_US Update ip command to detect their use. Signed-off-by: Eric Dumazet --- ip/tcp_metrics.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/ip/tcp_metrics.c b/ip/tcp_metrics.c index e0f0344..bbbb4cc 100644 --- a/ip/tcp_metrics.c +++ b/ip/tcp_metrics.c @@ -216,6 +216,7 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, a = attrs[TCP_METRICS_ATTR_VALS]; if (a) { struct rtattr *m[TCP_METRIC_MAX + 1 + 1]; + unsigned long rtt = 0, rttvar = 0; parse_rtattr_nested(m, TCP_METRIC_MAX + 1, a); @@ -225,18 +226,30 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, a = m[i + 1]; if (!a) continue; - if (metric_name[i]) - fprintf(fp, " %s ", metric_name[i]); - else - fprintf(fp, " metric_%d ", i); - + if (i != TCP_METRIC_RTT && + i != TCP_METRIC_RTT_US && + i != TCP_METRIC_RTTVAR && + i != TCP_METRIC_RTTVAR_US) { + if (metric_name[i]) + fprintf(fp, " %s ", metric_name[i]); + else + fprintf(fp, " metric_%d ", i); + } val = rta_getattr_u32(a); switch (i) { case TCP_METRIC_RTT: - fprintf(fp, "%luus", (val * 1000UL) >> 3); + if (!rtt) + rtt = (val * 1000UL) >> 3; break; case TCP_METRIC_RTTVAR: - fprintf(fp, "%luus", (val * 1000UL) >> 2); + if (!rttvar) + rttvar = (val * 1000UL) >> 2; + break; + case TCP_METRIC_RTT_US: + rtt = val >> 3; + break; + case TCP_METRIC_RTTVAR_US: + rttvar = val >> 2; break; case TCP_METRIC_SSTHRESH: case TCP_METRIC_CWND: @@ -246,6 +259,10 @@ static int process_msg(const struct sockaddr_nl *who, struct nlmsghdr *n, break; } } + if (rtt) + fprintf(fp, " rtt %luus", rtt); + if (rttvar) + fprintf(fp, " rttvar %luus", rttvar); } a = attrs[TCP_METRICS_ATTR_FOPEN_MSS];