summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorclaudio <claudio@openbsd.org>2018-04-18 12:10:54 +0000
committerclaudio <claudio@openbsd.org>2018-04-18 12:10:54 +0000
commitea42f25a1503dc4315bda6fa3a08cbfe5c5e3d0c (patch)
treeaa34eae121d17471da7cf9cd18d017c351c806d4
parenthandle failure better in release_firmware()/request_firmware() (diff)
downloadwireguard-openbsd-ea42f25a1503dc4315bda6fa3a08cbfe5c5e3d0c.tar.xz
wireguard-openbsd-ea42f25a1503dc4315bda6fa3a08cbfe5c5e3d0c.zip
Remove RELAY_MAX_SESSIONS from relayd, there is no reason to limit relays
to 1024 session per process (esp. with keep-alive). Now the fd limit is the new maximum and relayd will make sure to not accept too many sessions. The tcp backlog config maximum is now 512, adjust manpage accordingly. OK benno@ deraadt@
-rw-r--r--usr.sbin/relayd/parse.y4
-rw-r--r--usr.sbin/relayd/relay.c5
-rw-r--r--usr.sbin/relayd/relay_udp.c8
-rw-r--r--usr.sbin/relayd/relayd.conf.56
-rw-r--r--usr.sbin/relayd/relayd.h4
5 files changed, 12 insertions, 15 deletions
diff --git a/usr.sbin/relayd/parse.y b/usr.sbin/relayd/parse.y
index 0f05f4ee01b..e9800260c18 100644
--- a/usr.sbin/relayd/parse.y
+++ b/usr.sbin/relayd/parse.y
@@ -1,4 +1,4 @@
-/* $OpenBSD: parse.y,v 1.221 2017/11/29 15:24:50 benno Exp $ */
+/* $OpenBSD: parse.y,v 1.222 2018/04/18 12:10:54 claudio Exp $ */
/*
* Copyright (c) 2007 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1081,7 +1081,7 @@ tcpflags : SACK { proto->tcpflags |= TCPFLAG_SACK; }
| SPLICE { /* default */ }
| NO SPLICE { proto->tcpflags |= TCPFLAG_NSPLICE; }
| BACKLOG NUMBER {
- if ($2 < 0 || $2 > RELAY_MAX_SESSIONS) {
+ if ($2 < 0 || $2 > RELAY_MAX_BACKLOG) {
yyerror("invalid backlog: %d", $2);
YYERROR;
}
diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c
index 510d867c162..bc2bdd1582e 100644
--- a/usr.sbin/relayd/relay.c
+++ b/usr.sbin/relayd/relay.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay.c,v 1.237 2017/12/27 15:53:30 benno Exp $ */
+/* $OpenBSD: relay.c,v 1.238 2018/04/18 12:10:54 claudio Exp $ */
/*
* Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org>
@@ -1077,8 +1077,7 @@ relay_accept(int fd, short event, void *arg)
}
return;
}
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
- rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
goto err;
if ((con = calloc(1, sizeof(*con))) == NULL)
diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c
index c3468d3d75b..fe5a1d587ed 100644
--- a/usr.sbin/relayd/relay_udp.c
+++ b/usr.sbin/relayd/relay_udp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: relay_udp.c,v 1.47 2017/07/04 19:59:51 benno Exp $ */
+/* $OpenBSD: relay_udp.c,v 1.48 2018/04/18 12:10:54 claudio Exp $ */
/*
* Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org>
@@ -191,8 +191,7 @@ relay_udp_response(int fd, short sig, void *arg)
return;
}
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
- rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
return;
slen = sizeof(ss);
@@ -226,8 +225,7 @@ relay_udp_server(int fd, short sig, void *arg)
event_add(&rlay->rl_ev, NULL);
- if (relay_sessions >= RELAY_MAX_SESSIONS ||
- rlay->rl_conf.flags & F_DISABLE)
+ if (rlay->rl_conf.flags & F_DISABLE)
return;
slen = sizeof(ss);
diff --git a/usr.sbin/relayd/relayd.conf.5 b/usr.sbin/relayd/relayd.conf.5
index b6fd6530d79..61ad3d47c94 100644
--- a/usr.sbin/relayd/relayd.conf.5
+++ b/usr.sbin/relayd/relayd.conf.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: relayd.conf.5,v 1.182 2017/11/29 21:17:51 jmc Exp $
+.\" $OpenBSD: relayd.conf.5,v 1.183 2018/04/18 12:10:54 claudio Exp $
.\"
.\" Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org>
.\" Copyright (c) 2006, 2007 Pierre-Yves Ritschard <pyr@openbsd.org>
@@ -15,7 +15,7 @@
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: November 29 2017 $
+.Dd $Mdocdate: April 18 2018 $
.Dt RELAYD.CONF 5
.Os
.Sh NAME
@@ -849,7 +849,7 @@ Valid options are:
.Bl -tag -width Ds
.It Ic backlog Ar number
Set the maximum length the queue of pending connections may grow to.
-The backlog option is 10 by default and is limited by the
+The backlog option is 10 by default, is limited to 512 and capped by the
.Ic kern.somaxconn
.Xr sysctl 8
variable.
diff --git a/usr.sbin/relayd/relayd.h b/usr.sbin/relayd/relayd.h
index a91c37f12b1..bcf47a6f709 100644
--- a/usr.sbin/relayd/relayd.h
+++ b/usr.sbin/relayd/relayd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: relayd.h,v 1.248 2017/11/28 18:25:53 claudio Exp $ */
+/* $OpenBSD: relayd.h,v 1.249 2018/04/18 12:10:54 claudio Exp $ */
/*
* Copyright (c) 2006 - 2016 Reyk Floeter <reyk@openbsd.org>
@@ -68,7 +68,7 @@
#define FD_RESERVE 5
-#define RELAY_MAX_SESSIONS 1024
+#define RELAY_MAX_BACKLOG 512
#define RELAY_TIMEOUT 600
#define RELAY_CACHESIZE -1 /* use default size */
#define RELAY_NUMPROC 3