aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlfred Perlstein <alfred@FreeBSD.org>2016-02-02 05:57:59 +0000
committerAlfred Perlstein <alfred@FreeBSD.org>2016-02-02 05:57:59 +0000
commit7325dfbb59e38848a70546ab4c6a09d7b676fea7 (patch)
tree1d237b239ea69d18618f1b1b173368ea98474a31
parent92deafc3a3a9fb9221c49e574db99571b8080a9f (diff)
downloadsrc-7325dfbb59e38848a70546ab4c6a09d7b676fea7.tar.gz
src-7325dfbb59e38848a70546ab4c6a09d7b676fea7.zip
Increase max allowed backlog for listen sockets
from short to int. PR: 203922 Submitted by: White Knight <white_knight@2ch.net> MFC After: 4 weeks
Notes
Notes: svn path=/head/; revision=295136
-rw-r--r--sys/kern/uipc_debug.c6
-rw-r--r--sys/kern/uipc_socket.c10
-rw-r--r--sys/netinet/sctp_sysctl.c4
-rw-r--r--sys/netinet/sctp_uio.h10
-rw-r--r--sys/sys/socketvar.h12
-rw-r--r--usr.bin/netstat/inet.c6
-rw-r--r--usr.bin/netstat/sctp.c5
-rw-r--r--usr.bin/netstat/unix.c8
8 files changed, 37 insertions, 24 deletions
diff --git a/sys/kern/uipc_debug.c b/sys/kern/uipc_debug.c
index caecad9bac84..7c8b93cdbd92 100644
--- a/sys/kern/uipc_debug.c
+++ b/sys/kern/uipc_debug.c
@@ -461,9 +461,9 @@ db_print_socket(struct socket *so, const char *socketname, int indent)
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);
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 350ca3cdd0b0..5d2247fddb1d 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -196,7 +196,7 @@ VNET_DEFINE(struct hhook_head *, socket_hhh[HHOOK_SOCKET_LAST + 1]);
* 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;
diff --git a/sys/netinet/sctp_sysctl.c b/sys/netinet/sctp_sysctl.c
index b72e896cd223..e19793679984 100644
--- a/sys/netinet/sctp_sysctl.c
+++ b/sys/netinet/sctp_sysctl.c
@@ -426,7 +426,11 @@ sctp_sysctl_handle_assoclist(SYSCTL_HANDLER_ARGS)
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);
diff --git a/sys/netinet/sctp_uio.h b/sys/netinet/sctp_uio.h
index cfc79788adda..2299f66fa51d 100644
--- a/sys/netinet/sctp_uio.h
+++ b/sys/netinet/sctp_uio.h
@@ -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
};
diff --git a/sys/sys/socketvar.h b/sys/sys/socketvar.h
index 26cf9a6721ed..55a7950cebb7 100644
--- a/sys/sys/socketvar.h
+++ b/sys/sys/socketvar.h
@@ -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;
diff --git a/usr.bin/netstat/inet.c b/usr.bin/netstat/inet.c
index 6a933145e7e8..b0a0a7fca050 100644
--- a/usr.bin/netstat/inet.c
+++ b/usr.bin/netstat/inet.c
@@ -486,11 +486,11 @@ protopr(u_long off, const char *name, int af1, int proto)
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} "
diff --git a/usr.bin/netstat/sctp.c b/usr.bin/netstat/sctp.c
index 5f609a077d24..6c766b2ad082 100644
--- a/usr.bin/netstat/sctp.c
+++ b/usr.bin/netstat/sctp.c
@@ -467,9 +467,10 @@ sctp_process_inpcb(struct xsctp_inpcb *xinpcb,
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}"
diff --git a/usr.bin/netstat/unix.c b/usr.bin/netstat/unix.c
index a7503f5f4725..04e4ae5e0aa7 100644
--- a/usr.bin/netstat/unix.c
+++ b/usr.bin/netstat/unix.c
@@ -271,7 +271,7 @@ unixdomainpr(struct xunpcb *xunp, struct xsocket *so)
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 xsocket *so)
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],