summaryrefslogtreecommitdiffstats
path: root/usr.bin/netstat
diff options
context:
space:
mode:
authorguido <guido@FreeBSD.org>1999-12-13 20:08:44 +0000
committerguido <guido@FreeBSD.org>1999-12-13 20:08:44 +0000
commit39eef9ac50edc8fec68a286507de869f0ca3af45 (patch)
tree5c8458da709a6ad586a76fb65aa529abd8f8a4bf /usr.bin/netstat
parentcdc2842a0cd96f5e492c5b721ec3bf6dc5735810 (diff)
downloadFreeBSD-src-39eef9ac50edc8fec68a286507de869f0ca3af45.zip
FreeBSD-src-39eef9ac50edc8fec68a286507de869f0ca3af45.tar.gz
Add new option, -L that will listen the various listen queue lengths.
Reviewed by: Garrett Wollman <wollman@khavrinen.lcs.mit.edu>, Clive Lin <clive@GnatS.CirX.ORG>
Diffstat (limited to 'usr.bin/netstat')
-rw-r--r--usr.bin/netstat/inet.c85
-rw-r--r--usr.bin/netstat/main.c7
-rw-r--r--usr.bin/netstat/netstat.17
-rw-r--r--usr.bin/netstat/netstat.h1
4 files changed, 68 insertions, 32 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 4a8cda1..064fcbb 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -208,17 +208,26 @@ protopr(proto, name, af)
continue;
if (first) {
- printf("Active Internet connections");
- if (aflag)
- printf(" (including servers)");
+ if (!Lflag) {
+ printf("Active Internet connections");
+ if (aflag)
+ printf(" (including servers)");
+ } else
+ printf(
+ "Current listen queue sizes (qlen/incqlen/maxqlen)");
putchar('\n');
if (Aflag)
printf("%-8.8s ", "Socket");
- printf(Aflag ?
- "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
- "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
- "Proto", "Recv-Q", "Send-Q",
- "Local Address", "Foreign Address", "(state)");
+ if (Lflag)
+ printf("%-14.14s %-21.21s\n",
+ "Listen", "Local Address");
+ else
+ printf(Aflag ?
+ "%-5.5s %-6.6s %-6.6s %-18.18s %-18.18s %s\n" :
+ "%-5.5s %-6.6s %-6.6s %-22.22s %-22.22s %s\n",
+ "Proto", "Recv-Q", "Send-Q",
+ "Local Address", "Foreign Address",
+ "(state)");
first = 0;
}
if (Aflag) {
@@ -227,63 +236,81 @@ protopr(proto, name, af)
else
printf("%8lx ", (u_long)so->so_pcb);
}
- printf("%-3.3s%s%s %6ld %6ld ", name,
- (inp->inp_vflag & INP_IPV4) ? "4" : "",
+ if (Lflag)
+ if (so->so_qlimit) {
+ char buf[15];
+
+ snprintf(buf, 15, "%d/%d/%d", so->so_qlen,
+ so->so_incqlen, so->so_qlimit);
+ printf("%-14.14s ", buf);
+ } else
+ continue;
+ else
+ printf("%-3.3s%s%s %6ld %6ld ", name,
+ (inp->inp_vflag & INP_IPV4) ? "4" : "",
#ifdef INET6
- (inp->inp_vflag & INP_IPV6) ? "6" :
+ (inp->inp_vflag & INP_IPV6) ? "6" :
#endif
- "",
- so->so_rcv.sb_cc,
- so->so_snd.sb_cc);
+ "",
+ so->so_rcv.sb_cc,
+ so->so_snd.sb_cc);
if (nflag) {
if (inp->inp_vflag & INP_IPV4) {
inetprint(&inp->inp_laddr, (int)inp->inp_lport,
name, 1);
- inetprint(&inp->inp_faddr, (int)inp->inp_fport,
- name, 1);
+ if (!Lflag)
+ inetprint(&inp->inp_faddr,
+ (int)inp->inp_fport, name, 1);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
inet6print(&inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
- inet6print(&inp->in6p_faddr,
- (int)inp->inp_fport, name, 1);
+ if (!Lflag)
+ inet6print(&inp->in6p_faddr,
+ (int)inp->inp_fport, name, 1);
} /* else nothing printed now */
#endif /* INET6 */
} else if (inp->inp_flags & INP_ANONPORT) {
if (inp->inp_vflag & INP_IPV4) {
inetprint(&inp->inp_laddr, (int)inp->inp_lport,
name, 1);
- inetprint(&inp->inp_faddr, (int)inp->inp_fport,
- name, 0);
+ if (!Lflag)
+ inetprint(&inp->inp_faddr,
+ (int)inp->inp_fport, name, 0);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
inet6print(&inp->in6p_laddr,
(int)inp->inp_lport, name, 1);
- inet6print(&inp->in6p_faddr,
- (int)inp->inp_fport, name, 0);
+ if (!Lflag)
+ inet6print(&inp->in6p_faddr,
+ (int)inp->inp_fport, name, 0);
} /* else nothing printed now */
#endif /* INET6 */
} else {
if (inp->inp_vflag & INP_IPV4) {
inetprint(&inp->inp_laddr, (int)inp->inp_lport,
name, 0);
- inetprint(&inp->inp_faddr, (int)inp->inp_fport,
- name,
- inp->inp_lport != inp->inp_fport);
+ if (!Lflag)
+ inetprint(&inp->inp_faddr,
+ (int)inp->inp_fport, name,
+ inp->inp_lport !=
+ inp->inp_fport);
}
#ifdef INET6
else if (inp->inp_vflag & INP_IPV6) {
inet6print(&inp->in6p_laddr,
(int)inp->inp_lport, name, 0);
- inet6print(&inp->in6p_faddr,
- (int)inp->inp_fport, name,
- inp->inp_lport != inp->inp_fport);
+ if (!Lflag)
+ inet6print(&inp->in6p_faddr,
+ (int)inp->inp_fport, name,
+ inp->inp_lport !=
+ inp->inp_fport);
} /* else nothing printed now */
#endif /* INET6 */
}
- if (istcp) {
+ if (istcp && !Lflag) {
if (tp->t_state < 0 || tp->t_state >= TCP_NSTATES)
printf("%d", tp->t_state);
else {
diff --git a/usr.bin/netstat/main.c b/usr.bin/netstat/main.c
index 034ffbd..5bf9759 100644
--- a/usr.bin/netstat/main.c
+++ b/usr.bin/netstat/main.c
@@ -290,7 +290,7 @@ main(argc, argv)
af = AF_UNSPEC;
- while ((ch = getopt(argc, argv, "Aabdf:ghI:liM:mN:np:rstuw:")) != -1)
+ while ((ch = getopt(argc, argv, "Aabdf:ghI:lLiM:mN:np:rstuw:")) != -1)
switch(ch) {
case 'A':
Aflag = 1;
@@ -351,6 +351,9 @@ main(argc, argv)
case 'l':
lflag = 1;
break;
+ case 'L':
+ Lflag = 1;
+ break;
case 'M':
memf = optarg;
break;
@@ -529,7 +532,7 @@ main(argc, argv)
for (tp = isoprotox; tp->pr_name; tp++)
printproto(tp, tp->pr_name);
#endif
- if ((af == AF_UNIX || af == AF_UNSPEC) && !sflag)
+ if ((af == AF_UNIX || af == AF_UNSPEC) && !Lflag && !sflag)
unixpr();
exit(0);
}
diff --git a/usr.bin/netstat/netstat.1 b/usr.bin/netstat/netstat.1
index 30a8249..680a0be 100644
--- a/usr.bin/netstat/netstat.1
+++ b/usr.bin/netstat/netstat.1
@@ -40,7 +40,7 @@
.Nd show network status
.Sh SYNOPSIS
.Nm netstat
-.Op Fl Aan
+.Op Fl AaLn
.Op Fl f Ar address_family
.Op Fl M Ar core
.Op Fl N Ar system
@@ -197,6 +197,11 @@ for the specfied
or
.Ar protocol,
respectively.
+.It Fl L
+Show the size of the various listen queues. The first count shows the
+number of unaccepted connections.
+The second count shows the amount of unaccepted incomplete connections.
+The third count is the maximum number of queued connections.
.It Fl M
Extract values associated with the name list from the specified core
instead of the default
diff --git a/usr.bin/netstat/netstat.h b/usr.bin/netstat/netstat.h
index fc46dee..c249547 100644
--- a/usr.bin/netstat/netstat.h
+++ b/usr.bin/netstat/netstat.h
@@ -43,6 +43,7 @@ int dflag; /* show i/f dropped packets */
int gflag; /* show group (multicast) routing or stats */
int iflag; /* show interfaces */
int lflag; /* show routing table with use and ref */
+int Lflag; /* show size of listen queues */
int mflag; /* show memory stats */
int nflag; /* show addresses numerically */
int pflag; /* show given protocol */
OpenPOWER on IntegriCloud