summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrwatson <rwatson@FreeBSD.org>2005-09-18 21:08:03 +0000
committerrwatson <rwatson@FreeBSD.org>2005-09-18 21:08:03 +0000
commitbfb05b4b93adffb0e9783a141f4a30195b6a6cb9 (patch)
tree932a863cafc38c7893adab688bcd73850f5a9100
parentb96257fb77a837506ac0d1f011c46207e1c45f58 (diff)
downloadFreeBSD-src-bfb05b4b93adffb0e9783a141f4a30195b6a6cb9.zip
FreeBSD-src-bfb05b4b93adffb0e9783a141f4a30195b6a6cb9.tar.gz
Add three new read-only socket options, which allow regression tests
and other applications to query the state of the stack regarding the accept queue on a listen socket: SO_LISTENQLIMIT Return the value of so_qlimit (socket backlog) SO_LISTENQLEN Return the value of so_qlen (complete sockets) SO_LISTENINCQLEN Return the value of so_incqlen (incomplete sockets) Minor white space tweaks to existing socket options to make them consistent. Discussed with: andre MFC after: 1 week
-rw-r--r--sys/kern/uipc_socket.c17
-rw-r--r--sys/sys/socket.h3
2 files changed, 20 insertions, 0 deletions
diff --git a/sys/kern/uipc_socket.c b/sys/kern/uipc_socket.c
index 378d542..c5aab5f 100644
--- a/sys/kern/uipc_socket.c
+++ b/sys/kern/uipc_socket.c
@@ -1677,6 +1677,7 @@ sosetopt(so, sopt)
break;
}
break;
+
case SO_LABEL:
#ifdef MAC
error = sooptcopyin(sopt, &extmac, sizeof extmac,
@@ -1689,6 +1690,7 @@ sosetopt(so, sopt)
error = EOPNOTSUPP;
#endif
break;
+
default:
error = ENOPROTOOPT;
break;
@@ -1817,6 +1819,7 @@ integer:
tv.tv_usec = (optval % hz) * tick;
error = sooptcopyout(sopt, &tv, sizeof tv);
break;
+
case SO_LABEL:
#ifdef MAC
error = sooptcopyin(sopt, &extmac, sizeof(extmac),
@@ -1832,6 +1835,7 @@ integer:
error = EOPNOTSUPP;
#endif
break;
+
case SO_PEERLABEL:
#ifdef MAC
error = sooptcopyin(sopt, &extmac, sizeof(extmac),
@@ -1847,6 +1851,19 @@ integer:
error = EOPNOTSUPP;
#endif
break;
+
+ case SO_LISTENQLIMIT:
+ optval = so->so_qlimit;
+ goto integer;
+
+ case SO_LISTENQLEN:
+ optval = so->so_qlen;
+ goto integer;
+
+ case SO_LISTENINCQLEN:
+ optval = so->so_incqlen;
+ goto integer;
+
default:
error = ENOPROTOOPT;
break;
diff --git a/sys/sys/socket.h b/sys/sys/socket.h
index 176343d..bb00346 100644
--- a/sys/sys/socket.h
+++ b/sys/sys/socket.h
@@ -133,6 +133,9 @@ typedef __uid_t uid_t;
#if __BSD_VISIBLE
#define SO_LABEL 0x1009 /* socket's MAC label */
#define SO_PEERLABEL 0x1010 /* socket's peer's MAC label */
+#define SO_LISTENQLIMIT 0x1011 /* socket's backlog limit */
+#define SO_LISTENQLEN 0x1012 /* socket's complete queue length */
+#define SO_LISTENINCQLEN 0x1013 /* socket's incomplete queue length */
#endif
/*
OpenPOWER on IntegriCloud