Author: tuexen
Date: Sun Sep 13 09:14:32 2020
New Revision: 365688
URL: https://svnweb.freebsd.org/changeset/base/365688

Log:
  Add a -C option to netstat to display the congestion control for
  TCP connections.
  
  Reviewed by:          rscheff
  MFC after:            1 week
  Sponsored by:         Netflix, Inc.
  Differential Revision:        https://reviews.freebsd.org/D26414

Modified:
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/main.c
  head/usr.bin/netstat/netstat.1
  head/usr.bin/netstat/netstat.h

Modified: head/usr.bin/netstat/inet.c
==============================================================================
--- head/usr.bin/netstat/inet.c Sun Sep 13 09:12:25 2020        (r365687)
+++ head/usr.bin/netstat/inet.c Sun Sep 13 09:14:32 2020        (r365688)
@@ -341,6 +341,9 @@ protopr(u_long off, const char *name, int af1, int pro
                                xo_emit("  {T:/%8.8s} {T:/%5.5s}",
                                    "flowid", "ftype");
                        }
+                       if (Cflag)
+                               xo_emit(" {T:/%-*.*s}", TCP_CA_NAME_MAX,
+                                   TCP_CA_NAME_MAX, "CC");
                        if (Pflag)
                                xo_emit(" {T:/%s}", "Log ID");
                        xo_emit("\n");
@@ -514,9 +517,15 @@ protopr(u_long off, const char *name, int af1, int pro
                            inp->inp_flowid,
                            inp->inp_flowtype);
                }
-               if (istcp && Pflag)
-                       xo_emit(" {:log-id/%s}", tp->xt_logid[0] == '\0' ?
-                           "-" : tp->xt_logid);
+               if (istcp) {
+                       if (Cflag)
+                               xo_emit(" {:cc/%-*.*s}", TCP_CA_NAME_MAX,
+                                   TCP_CA_NAME_MAX, tp->xt_cc);
+                       if (Pflag)
+                               xo_emit(" {:log-id/%s}",
+                                   tp->xt_logid[0] == '\0' ?
+                                   "-" : tp->xt_logid);
+               }
                xo_emit("\n");
                xo_close_instance("socket");
        }

Modified: head/usr.bin/netstat/main.c
==============================================================================
--- head/usr.bin/netstat/main.c Sun Sep 13 09:12:25 2020        (r365687)
+++ head/usr.bin/netstat/main.c Sun Sep 13 09:14:32 2020        (r365688)
@@ -205,6 +205,7 @@ int Aflag;          /* show addresses of protocol control 
bloc
 int    aflag;          /* show all sockets (including servers) */
 static int     Bflag;          /* show information about bpf consumers */
 int    bflag;          /* show i/f total bytes in/out */
+int    Cflag;          /* show congestion control */
 int    dflag;          /* show i/f dropped packets */
 int    gflag;          /* show group (multicast) routing or stats */
 int    hflag;          /* show counters in human readable format */
@@ -249,7 +250,7 @@ main(int argc, char *argv[])
        if (argc < 0)
                exit(EXIT_FAILURE);
 
-       while ((ch = getopt(argc, argv, 
"46AaBbdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz"))
+       while ((ch = getopt(argc, argv, 
"46AaBbCdF:f:ghI:iLlM:mN:noPp:Qq:RrSTsuWw:xz"))
            != -1)
                switch(ch) {
                case '4':
@@ -277,6 +278,9 @@ main(int argc, char *argv[])
                        break;
                case 'b':
                        bflag = 1;
+                       break;
+               case 'C':
+                       Cflag = 1;
                        break;
                case 'd':
                        dflag = 1;

Modified: head/usr.bin/netstat/netstat.1
==============================================================================
--- head/usr.bin/netstat/netstat.1      Sun Sep 13 09:12:25 2020        
(r365687)
+++ head/usr.bin/netstat/netstat.1      Sun Sep 13 09:14:32 2020        
(r365688)
@@ -28,7 +28,7 @@
 .\"    @(#)netstat.1   8.8 (Berkeley) 4/18/94
 .\" $FreeBSD$
 .\"
-.Dd July 21, 2020
+.Dd September 13, 2020
 .Dt NETSTAT 1
 .Os
 .Sh NAME
@@ -39,7 +39,7 @@
 .Bl -tag -width "netstat"
 .It Nm
 .Op Fl -libxo
-.Op Fl 46AaLnPRSTWx
+.Op Fl 46AaCLnPRSTWx
 .Op Fl f Ar protocol_family | Fl p Ar protocol
 .Op Fl M Ar core
 .Op Fl N Ar system
@@ -111,7 +111,7 @@ depending on the options for the information presented
 .It Xo
 .Bk -words
 .Nm
-.Op Fl 46AaLnRSTWx
+.Op Fl 46AaCLnRSTWx
 .Op Fl f Ar protocol_family | Fl p Ar protocol
 .Op Fl M Ar core
 .Op Fl N Ar system
@@ -172,6 +172,8 @@ associated with a socket; used for debugging.
 .It Fl a
 Show the state of all sockets;
 normally sockets used by server processes are not shown.
+.It Fl C
+Show the congestion control of TCP sockets.
 .It Fl L
 Show the size of the various listen queues.
 The first count shows the number of unaccepted connections,

Modified: head/usr.bin/netstat/netstat.h
==============================================================================
--- head/usr.bin/netstat/netstat.h      Sun Sep 13 09:12:25 2020        
(r365687)
+++ head/usr.bin/netstat/netstat.h      Sun Sep 13 09:14:32 2020        
(r365688)
@@ -41,6 +41,7 @@
 extern int     Aflag;  /* show addresses of protocol control block */
 extern int     aflag;  /* show all sockets (including servers) */
 extern int     bflag;  /* show i/f total bytes in/out */
+extern int     Cflag;  /* show congestion control */
 extern int     dflag;  /* show i/f dropped packets */
 extern int     gflag;  /* show group (multicast) routing or stats */
 extern int     hflag;  /* show counters in human readable format */
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to