aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/netstat/inet.c
diff options
context:
space:
mode:
authorRichard Scheffenegger <rscheff@FreeBSD.org>2020-10-09 10:07:41 +0000
committerRichard Scheffenegger <rscheff@FreeBSD.org>2020-10-09 10:07:41 +0000
commit0e5e35e32239e0aa67726b6ff6fcaa86a79aff56 (patch)
tree5f8e4d40f4558d0f810e1cccd1918628896e66b5 /usr.bin/netstat/inet.c
parentf15e9afb1f64d00403e702d41934dacc425582d7 (diff)
Notes
Diffstat (limited to 'usr.bin/netstat/inet.c')
-rw-r--r--usr.bin/netstat/inet.c58
1 files changed, 54 insertions, 4 deletions
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index f243f7358e268..95b0d8931b264 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -85,6 +85,8 @@ __FBSDID("$FreeBSD$");
#include "netstat.h"
#include "nl_defs.h"
+#define max(a, b) (((a) > (b)) ? (a) : (b))
+
#ifdef INET
static void inetprint(const char *, struct in_addr *, int, const char *, int,
const int);
@@ -204,6 +206,7 @@ protopr(u_long off, const char *name, int af1, int proto)
struct xinpcb *inp;
struct xinpgen *xig, *oxig;
struct xsocket *so;
+ int fnamelen, cnamelen;
istcp = 0;
switch (proto) {
@@ -236,6 +239,28 @@ protopr(u_long off, const char *name, int af1, int proto)
if (!pcblist_sysctl(proto, name, &buf))
return;
+ if (cflag || Cflag) {
+ fnamelen = strlen("Stack");
+ cnamelen = strlen("CC");
+ oxig = xig = (struct xinpgen *)buf;
+ for (xig = (struct xinpgen*)((char *)xig + xig->xig_len);
+ xig->xig_len > sizeof(struct xinpgen);
+ xig = (struct xinpgen *)((char *)xig + xig->xig_len)) {
+ if (istcp) {
+ tp = (struct xtcpcb *)xig;
+ inp = &tp->xt_inp;
+ } else {
+ continue;
+ }
+ if (so->xso_protocol != proto)
+ continue;
+ if (inp->inp_gencnt > oxig->xig_gen)
+ continue;
+ fnamelen = max(fnamelen, (int)strlen(tp->xt_stack));
+ cnamelen = max(cnamelen, (int)strlen(tp->xt_cc));
+ }
+ }
+
oxig = xig = (struct xinpgen *)buf;
for (xig = (struct xinpgen *)((char *)xig + xig->xig_len);
xig->xig_len > sizeof(struct xinpgen);
@@ -341,9 +366,19 @@ protopr(u_long off, const char *name, int af1, int proto)
xo_emit(" {T:/%8.8s} {T:/%5.5s}",
"flowid", "ftype");
}
+ if (cflag) {
+ xo_emit(" {T:/%-*.*s}",
+ fnamelen, fnamelen, "Stack");
+ }
if (Cflag)
- xo_emit(" {T:/%-*.*s}", TCP_CA_NAME_MAX,
- TCP_CA_NAME_MAX, "CC");
+ xo_emit(" {T:/%-*.*s} {T:/%10.10s}"
+ " {T:/%10.10s} {T:/%5.5s}"
+ " {T:/%3.3s}", cnamelen,
+ cnamelen, "CC",
+ "cwin",
+ "ssthresh",
+ "MSS",
+ "ECN");
if (Pflag)
xo_emit(" {T:/%s}", "Log ID");
xo_emit("\n");
@@ -518,9 +553,24 @@ protopr(u_long off, const char *name, int af1, int proto)
inp->inp_flowtype);
}
if (istcp) {
+ if (cflag)
+ xo_emit(" {:stack/%-*.*s}",
+
+ fnamelen, fnamelen, tp->xt_stack);
if (Cflag)
- xo_emit(" {:cc/%-*.*s}", TCP_CA_NAME_MAX,
- TCP_CA_NAME_MAX, tp->xt_cc);
+ xo_emit(" {:cc/%-*.*s}"
+ " {:snd-cwnd/%10lu}"
+ " {:snd-ssthresh/%10lu}"
+ " {:t-maxseg/%5u} {:ecn/%3s}",
+ cnamelen, cnamelen, tp->xt_cc,
+ tp->t_snd_cwnd, tp->t_snd_ssthresh,
+ tp->t_maxseg,
+ (tp->t_state >= TCPS_ESTABLISHED ?
+ (tp->xt_ecn > 0 ?
+ (tp->xt_ecn == 1 ?
+ "ecn" : "ace")
+ : "off")
+ : "n/a"));
if (Pflag)
xo_emit(" {:log-id/%s}",
tp->xt_logid[0] == '\0' ?