summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authoradrian <adrian@FreeBSD.org>2014-05-19 17:11:43 +0000
committeradrian <adrian@FreeBSD.org>2014-05-19 17:11:43 +0000
commita2ba9f176ff963b871323eae90c27c214cbb165c (patch)
treee1d3b868a0dfb3c0d8e059386c09218755b570b7 /usr.bin/netstat
parent736a6790af0253ee384fe72d74c62a453814442d (diff)
downloadFreeBSD-src-a2ba9f176ff963b871323eae90c27c214cbb165c.zip
FreeBSD-src-a2ba9f176ff963b871323eae90c27c214cbb165c.tar.gz
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.
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/inet.c14
-rw-r--r--usr.bin/netstat/main.c8
-rw-r--r--usr.bin/netstat/netstat.h1
3 files changed, 18 insertions, 5 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 9f8f1d2..10d0698 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -429,7 +429,7 @@ protopr(u_long off, const char *name, int af1, int proto)
"%-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, int af1, int proto)
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, int af1, int proto)
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, int af1, int proto)
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) {
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 5fe4917..4f104ff 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -295,6 +295,7 @@ int numeric_port; /* show ports numerically */
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]",
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index ebbdd5d..cb46c0f 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -45,6 +45,7 @@ extern int noutputs; /* how much outputs before we exit */
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 */
OpenPOWER on IntegriCloud