Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 19 May 2014 17:11:44 +0000 (UTC)
From:      Adrian Chadd <adrian@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r266448 - head/usr.bin/netstat
Message-ID:  <201405191711.s4JHBiZR088438@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201405191711.s4JHBiZR088438>