aboutgitcodebugslistschat
path: root/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'tcp.c')
-rw-r--r--tcp.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/tcp.c b/tcp.c
index bab07ab..d70267b 100644
--- a/tcp.c
+++ b/tcp.c
@@ -319,7 +319,7 @@
#include "siphash.h"
/* Approximately maximum number of open descriptors per process */
-#define MAX_CONNS (256 * 1024)
+#define MAX_CONNS (1024 * 1024)
#define TCP_HASH_TABLE_LOAD 70 /* % */
#define TCP_HASH_TABLE_SIZE (MAX_CONNS * 100 / TCP_HASH_TABLE_LOAD)
@@ -924,6 +924,11 @@ static void tcp_conn_from_tap(struct ctx *c, int af, void *addr,
if (s < 0)
return;
+ if (s >= MAX_CONNS) {
+ close(s);
+ return;
+ }
+
tc[s].mss_guest = tcp_opt_get(th, len, OPT_MSS, NULL, NULL);
if (tc[s].mss_guest < 0)
tc[s].mss_guest = MSS_DEFAULT;
@@ -1003,6 +1008,11 @@ static void tcp_conn_from_sock(struct ctx *c, int fd, struct timespec *now)
if (s == -1)
return;
+ if (s >= MAX_CONNS) {
+ close(s);
+ return;
+ }
+
CHECK_SET_MIN_MAX(c->tcp.fd_, s);
CHECK_SET_MIN_MAX(c->tcp.fd_conn_, s);