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>
This commit is contained in:
parent
83350dce60
commit
ac55add06c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=54574
@ -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 {
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user