From owner-svn-src-head@FreeBSD.ORG Mon May 19 17:11:44 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id BE1A6A1C; Mon, 19 May 2014 17:11:44 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9FA5F206E; Mon, 19 May 2014 17:11:44 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s4JHBiTo088443; Mon, 19 May 2014 17:11:44 GMT (envelope-from adrian@svn.freebsd.org) Received: (from adrian@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s4JHBiZR088438; Mon, 19 May 2014 17:11:44 GMT (envelope-from adrian@svn.freebsd.org) Message-Id: <201405191711.s4JHBiZR088438@svn.freebsd.org> From: Adrian Chadd Date: Mon, 19 May 2014 17:11:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r266448 - head/usr.bin/netstat X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 19 May 2014 17:11:44 -0000 Author: adrian Date: Mon May 19 17:11:43 2014 New Revision: 266448 URL: http://svnweb.freebsd.org/changeset/base/266448 Log: Add -R to netstat to dump RSS/flow information. This is intended to help in diagnostics and debugging of NIC and stack flowid support. Eventually this will grow another column (RSS CPU ID) but that currently isn't cached in the inpcb. There's also no clean flowtype -> flowtype identifier string. This is the mbuf M_HASHTYPE_* values for RSS. Here's some example output: adrian@adrian-hackbox:~/work/freebsd/head/src % netstat -Rn | more Active Internet connections Proto Recv-Q Send-Q Local Address Foreign Address flowid ftype tcp4 0 0 10.11.1.65.22 10.11.1.64.12409 29041942 2 udp4 0 0 127.0.0.1.123 *.* 00000000 0 udp6 0 0 fe80::1%lo0.123 *.* 00000000 0 udp6 0 0 ::1.123 *.* 00000000 0 udp4 0 0 10.11.1.65.123 *.* 00000000 0 Tested: * amd64 system w/ igb NIC; local driver changes to expose RSS flowid in if_igb. Modified: head/usr.bin/netstat/inet.c head/usr.bin/netstat/main.c head/usr.bin/netstat/netstat.h Modified: head/usr.bin/netstat/inet.c ============================================================================== --- head/usr.bin/netstat/inet.c Mon May 19 16:15:27 2014 (r266447) +++ head/usr.bin/netstat/inet.c Mon May 19 17:11:43 2014 (r266448) @@ -429,7 +429,7 @@ protopr(u_long off, const char *name, in "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s", "Proto", "Recv-Q", "Send-Q", "Local Address", "Foreign Address"); - if (!xflag) + if (!xflag && !Rflag) printf(" (state)"); } if (xflag) { @@ -441,6 +441,9 @@ protopr(u_long off, const char *name, in printf(" %7.7s %7.7s %7.7s %7.7s %7.7s %7.7s", "rexmt", "persist", "keep", "2msl", "delack", "rcvtime"); + } else if (Rflag) { + printf (" %8.8s %5.5s", + "flowid", "ftype"); } putchar('\n'); first = 0; @@ -549,7 +552,7 @@ protopr(u_long off, const char *name, in timer->tt_delack / 1000, (timer->tt_delack % 1000) / 10, timer->t_rcvtime / 1000, (timer->t_rcvtime % 1000) / 10); } - if (istcp && !Lflag && !xflag && !Tflag) { + if (istcp && !Lflag && !xflag && !Tflag && !Rflag) { if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES) printf("%d", tp->t_state); else { @@ -560,7 +563,12 @@ protopr(u_long off, const char *name, in putchar('*'); #endif /* defined(TF_NEEDSYN) && defined(TF_NEEDFIN) */ } - } + } + if (Rflag) { + printf(" %08x %5d", + inp->inp_flowid, + inp->inp_flowtype); + } putchar('\n'); } if (xig != oxig && xig->xig_gen != oxig->xig_gen) { Modified: head/usr.bin/netstat/main.c ============================================================================== --- head/usr.bin/netstat/main.c Mon May 19 16:15:27 2014 (r266447) +++ head/usr.bin/netstat/main.c Mon May 19 17:11:43 2014 (r266448) @@ -295,6 +295,7 @@ int numeric_port; /* show ports numerica static int pflag; /* show given protocol */ int Qflag; /* show netisr information */ int rflag; /* show routing tables (or routing stats) */ +int Rflag; /* show flow / RSS statistics */ int sflag; /* show protocol statistics */ int Wflag; /* wide display */ int Tflag; /* TCP Information */ @@ -319,7 +320,7 @@ main(int argc, char *argv[]) af = AF_UNSPEC; - while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:np:Qq:rSTsuWw:xz")) + while ((ch = getopt(argc, argv, "46AaBbdF:f:ghI:iLlM:mN:np:Qq:RrSTsuWw:xz")) != -1) switch(ch) { case '4': @@ -433,6 +434,9 @@ main(int argc, char *argv[]) case 'r': rflag = 1; break; + case 'R': + Rflag = 1; + break; case 's': ++sflag; break; @@ -820,7 +824,7 @@ static void usage(void) { (void)fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n%s\n", -"usage: netstat [-46AaLnSTWx] [-f protocol_family | -p protocol]\n" +"usage: netstat [-46AaLnRSTWx] [-f protocol_family | -p protocol]\n" " [-M core] [-N system]", " netstat -i | -I interface [-46abdhnW] [-f address_family]\n" " [-M core] [-N system]", Modified: head/usr.bin/netstat/netstat.h ============================================================================== --- head/usr.bin/netstat/netstat.h Mon May 19 16:15:27 2014 (r266447) +++ head/usr.bin/netstat/netstat.h Mon May 19 17:11:43 2014 (r266448) @@ -45,6 +45,7 @@ extern int noutputs; /* how much outputs extern int numeric_addr; /* show addresses numerically */ extern int numeric_port; /* show ports numerically */ extern int rflag; /* show routing tables (or routing stats) */ +extern int Rflag; /* show flowid / RSS information */ extern int sflag; /* show protocol statistics */ extern int Tflag; /* show TCP control block info */ extern int Wflag; /* wide display */