Skip to content

Commit

Permalink
munged: Allow listen-backlog to specify default or SOMAXCONN
Browse files Browse the repository at this point in the history
Change the behavior of the "--listen-backlog" command-line
option in order for a value of 0 to use the software default
(MUNGE_SOCKET_BACKLOG), and a value of -1 to specify SOMAXCONN.

Note that SOMAXCONN is now 4096 on current Linux systems; it was 128
before Linux 5.4 which meant that the munged socket had been using
the maximum backlog up until that point.

Reference:
- https://www.kernel.org/doc/html/latest/networking/ip-sysctl.html

Tested:
- AlmaLinux 9.3, 8.9
- Arch Linux
- CentOS Linux Stream 9, Stream 8, 7.9.2009, 6.10
- Debian sid, 12.5, 11.9, 10.13, 9.13, 8.11, 7.11, 6.0.10, 5.0.10, 4.0
- Fedora 39, 38, 37
- FreeBSD 13.2
- NetBSD 9.3
- OpenBSD 7.4, 7.3
- openSUSE 15.5, 15.4
- Ubuntu 23.10, 22.04.4, 20.04.6, 18.04.6, 16.04.7, 14.04.6

PR #139
  • Loading branch information
dun committed Mar 10, 2024
1 parent 0b84056 commit 0689a1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/munged/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,11 +415,19 @@ parse_cmdline (conf_t conf, int argc, char **argv)
l = strtol (optarg, &p, 10);
if (((errno == ERANGE) && ((l == LONG_MIN) || (l == LONG_MAX)))
|| (optarg == p) || (*p != '\0')
|| (l <= 0) || (l > INT_MAX)) {
|| (l < -1) || (l > INT_MAX)) {
log_err (EMUNGE_SNAFU, LOG_ERR,
"Invalid value \"%s\" for listen-backlog", optarg);
}
conf->listen_backlog = l;
else if (l == 0) {
conf->listen_backlog = MUNGE_SOCKET_BACKLOG;
}
else if (l == -1) {
conf->listen_backlog = SOMAXCONN;
}
else {
conf->listen_backlog = l;
}
break;
case OPT_LOG_FILE:
_conf_set_string (&conf->logfile_name, optarg, conf->cwd,
Expand Down
5 changes: 4 additions & 1 deletion src/munged/munged.8.in
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,10 @@ triggered by a \fBSIGHUP\fR). A value of \-1 causes it to be disabled.
Specify an alternate pathname to the key file.
.TP
.BI "\-\-listen\-backlog " integer
Specify an alternate listen backlog size of the local domain socket.
Specify the socket's listen backlog limit; note that the kernel may impose
a lower limit. A value of 0 uses the software default. A value of \-1
specifies \fBSOMAXCONN\fR, the maximum listen backlog queue length defined
in \fI<sys/socket.h>\fR.
.TP
.BI "\-\-log\-file " path
Specify an alternate pathname to the log file.
Expand Down

0 comments on commit 0689a1f

Please sign in to comment.