Author: alfred
Date: Tue Feb  2 05:57:59 2016
New Revision: 295136
URL: https://svnweb.freebsd.org/changeset/base/295136

Log:
  Increase max allowed backlog for listen sockets
  from short to int.
  
  PR: 203922
  Submitted by: White Knight <white_kni...@2ch.net>
  MFC After: 4 weeks

Modified:
  head/sys/kern/uipc_debug.c
  head/sys/kern/uipc_socket.c
  head/sys/netinet/sctp_sysctl.c
  head/sys/netinet/sctp_uio.h
  head/sys/sys/socketvar.h
  head/usr.bin/netstat/inet.c
  head/usr.bin/netstat/sctp.c
  head/usr.bin/netstat/unix.c

Modified: head/sys/kern/uipc_debug.c
==============================================================================
--- head/sys/kern/uipc_debug.c  Tue Feb  2 03:08:37 2016        (r295135)
+++ head/sys/kern/uipc_debug.c  Tue Feb  2 05:57:59 2016        (r295136)
@@ -461,9 +461,9 @@ db_print_socket(struct socket *so, const
 
        db_print_indent(indent);
        /* so_list skipped */
-       db_printf("so_qlen: %d   ", so->so_qlen);
-       db_printf("so_incqlen: %d   ", so->so_incqlen);
-       db_printf("so_qlimit: %d   ", so->so_qlimit);
+       db_printf("so_qlen: %u   ", so->so_qlen);
+       db_printf("so_incqlen: %u   ", so->so_incqlen);
+       db_printf("so_qlimit: %u   ", so->so_qlimit);
        db_printf("so_timeo: %d   ", so->so_timeo);
        db_printf("so_error: %d\n", so->so_error);
 

Modified: head/sys/kern/uipc_socket.c
==============================================================================
--- head/sys/kern/uipc_socket.c Tue Feb  2 03:08:37 2016        (r295135)
+++ head/sys/kern/uipc_socket.c Tue Feb  2 05:57:59 2016        (r295136)
@@ -196,7 +196,7 @@ VNET_DEFINE(struct hhook_head *, socket_
  * NB: The orginal sysctl somaxconn is still available but hidden
  * to prevent confusion about the actual purpose of this number.
  */
-static int somaxconn = SOMAXCONN;
+static u_int somaxconn = SOMAXCONN;
 
 static int
 sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
@@ -209,7 +209,13 @@ sysctl_somaxconn(SYSCTL_HANDLER_ARGS)
        if (error || !req->newptr )
                return (error);
 
-       if (val < 1 || val > USHRT_MAX)
+       /*
+        * The purpose of the UINT_MAX / 3 limit, is so that the formula
+        *   3 * so_qlimit / 2
+        * below, will not overflow.
+         */
+
+       if (val < 1 || val > UINT_MAX / 3)
                return (EINVAL);
 
        somaxconn = val;

Modified: head/sys/netinet/sctp_sysctl.c
==============================================================================
--- head/sys/netinet/sctp_sysctl.c      Tue Feb  2 03:08:37 2016        
(r295135)
+++ head/sys/netinet/sctp_sysctl.c      Tue Feb  2 05:57:59 2016        
(r295136)
@@ -426,7 +426,11 @@ sctp_sysctl_handle_assoclist(SYSCTL_HAND
                        xinpcb.maxqlen = 0;
                } else {
                        xinpcb.qlen = so->so_qlen;
+                       xinpcb.qlen_old = so->so_qlen > USHRT_MAX ? 
+                               USHRT_MAX : (uint16_t) so->so_qlen;
                        xinpcb.maxqlen = so->so_qlimit;
+                       xinpcb.maxqlen_old = so->so_qlimit > USHRT_MAX ? 
+                               USHRT_MAX : (uint16_t) so->so_qlimit;
                }
                SCTP_INP_INCR_REF(inp);
                SCTP_INP_RUNLOCK(inp);

Modified: head/sys/netinet/sctp_uio.h
==============================================================================
--- head/sys/netinet/sctp_uio.h Tue Feb  2 03:08:37 2016        (r295135)
+++ head/sys/netinet/sctp_uio.h Tue Feb  2 05:57:59 2016        (r295136)
@@ -1170,13 +1170,15 @@ struct xsctp_inpcb {
        uint32_t total_nospaces;
        uint32_t fragmentation_point;
        uint16_t local_port;
-       uint16_t qlen;
-       uint16_t maxqlen;
+       uint16_t qlen_old;
+       uint16_t maxqlen_old;
        void *socket;
+       uint32_t qlen;
+       uint32_t maxqlen;
 #if defined(__LP64__)
-       uint32_t extra_padding[29];     /* future */
+       uint32_t extra_padding[27];     /* future */
 #else
-       uint32_t extra_padding[30];     /* future */
+       uint32_t extra_padding[28];     /* future */
 #endif
 };
 

Modified: head/sys/sys/socketvar.h
==============================================================================
--- head/sys/sys/socketvar.h    Tue Feb  2 03:08:37 2016        (r295135)
+++ head/sys/sys/socketvar.h    Tue Feb  2 05:57:59 2016        (r295136)
@@ -95,10 +95,10 @@ struct socket {
        TAILQ_HEAD(, socket) so_incomp; /* (e) queue of partial unaccepted 
connections */
        TAILQ_HEAD(, socket) so_comp;   /* (e) queue of complete unaccepted 
connections */
        TAILQ_ENTRY(socket) so_list;    /* (e) list of unaccepted connections */
-       u_short so_qlen;                /* (e) number of unaccepted connections 
*/
-       u_short so_incqlen;             /* (e) number of unaccepted incomplete
+       u_int   so_qlen;                /* (e) number of unaccepted connections 
*/
+       u_int   so_incqlen;             /* (e) number of unaccepted incomplete
                                           connections */
-       u_short so_qlimit;              /* (e) max number queued connections */
+       u_int   so_qlimit;              /* (e) max number queued connections */
        short   so_timeo;               /* (g) connection timeout */
        u_short so_error;               /* (f) error affecting connection */
        struct  sigio *so_sigio;        /* [sg] information for async I/O or
@@ -172,9 +172,9 @@ struct xsocket {
        caddr_t so_pcb;         /* another convenient handle */
        int     xso_protocol;
        int     xso_family;
-       u_short so_qlen;
-       u_short so_incqlen;
-       u_short so_qlimit;
+       u_int   so_qlen;
+       u_int   so_incqlen;
+       u_int   so_qlimit;
        short   so_timeo;
        u_short so_error;
        pid_t   so_pgid;

Modified: head/usr.bin/netstat/inet.c
==============================================================================
--- head/usr.bin/netstat/inet.c Tue Feb  2 03:08:37 2016        (r295135)
+++ head/usr.bin/netstat/inet.c Tue Feb  2 05:57:59 2016        (r295136)
@@ -486,11 +486,11 @@ protopr(u_long off, const char *name, in
                else
                        xo_emit("{:protocol/%-3.3s%-2.2s/%s%s} ", name, vchar);
                if (Lflag) {
-                       char buf1[15];
+                       char buf1[33];
 
-                       snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
+                       snprintf(buf1, sizeof buf1, "%u/%u/%u", so->so_qlen,
                            so->so_incqlen, so->so_qlimit);
-                       xo_emit("{:listen-queue-sizes/%-14.14s} ", buf1);
+                       xo_emit("{:listen-queue-sizes/%-32.32s} ", buf1);
                } else if (Tflag) {
                        if (istcp)
                                xo_emit("{:sent-retransmit-packets/%6u} "

Modified: head/usr.bin/netstat/sctp.c
==============================================================================
--- head/usr.bin/netstat/sctp.c Tue Feb  2 03:08:37 2016        (r295135)
+++ head/usr.bin/netstat/sctp.c Tue Feb  2 05:57:59 2016        (r295136)
@@ -467,9 +467,10 @@ sctp_process_inpcb(struct xsctp_inpcb *x
                tname = "????";
 
        if (Lflag) {
-               char buf1[9];
+               char buf1[22];
 
-               snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen);
+               snprintf(buf1, sizeof buf1, "%u/%u", 
+                   xinpcb->qlen, xinpcb->maxqlen);
                xo_emit("{:protocol/%-6.6s/%s} {:type/%-5.5s/%s} ",
                    pname, tname);
                xo_emit("{d:queues/%-8.8s}{e:queue-len/%hu}"

Modified: head/usr.bin/netstat/unix.c
==============================================================================
--- head/usr.bin/netstat/unix.c Tue Feb  2 03:08:37 2016        (r295135)
+++ head/usr.bin/netstat/unix.c Tue Feb  2 05:57:59 2016        (r295136)
@@ -271,7 +271,7 @@ unixdomainpr(struct xunpcb *xunp, struct
        struct unpcb *unp;
        struct sockaddr_un *sa;
        static int first = 1;
-       char buf1[15];
+       char buf1[33];
        static const char *titles[2] = {
            "{T:/%-8.8s} {T:/%-6.6s} {T:/%-6.6s} {T:/%-6.6s} {T:/%8.8s} "
            "{T:/%8.8s} {T:/%8.8s} {T:/%8.8s} {T:Addr}\n",
@@ -310,10 +310,10 @@ unixdomainpr(struct xunpcb *xunp, struct
                return;
 
        if (Lflag) {
-               snprintf(buf1, 15, "%d/%d/%d", so->so_qlen,
+               snprintf(buf1, sizeof buf1, "%u/%u/%u", so->so_qlen,
                    so->so_incqlen, so->so_qlimit);
-               xo_emit("unix  {d:socket/%-14.14s}{e:queue-length/%d}"
-                   "{e:incomplete-queue-length/%d}{e:queue-limit/%d}",
+               xo_emit("unix  {d:socket/%-32.32s}{e:queue-length/%u}"
+                   "{e:incomplete-queue-length/%u}{e:queue-limit/%u}",
                    buf1, so->so_qlen, so->so_incqlen, so->so_qlimit);
        } else {
                xo_emit(format[fmt],
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to