]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[v4_1_esv] Add patch to limit the value of an fd we accept for a connection.
authorShawn Routhier <sar@isc.org>
Fri, 4 Mar 2016 20:29:19 +0000 (12:29 -0800)
committerShawn Routhier <sar@isc.org>
Fri, 4 Mar 2016 20:29:19 +0000 (12:29 -0800)
By limiting the highest value we accept for an fd we limit the number
of connections.

RELNOTES
includes/site.h
omapip/listener.c

index 73db3567e23a8f052b47544d9213b8663146fcca..a01abe52ce284af3950092878dbc0c08ee0d848e 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -192,6 +192,10 @@ by Eric Young (eay@cryptsoft.com).
   decoding a packet and clean up some memory on error conditions.
   [ISC-Bugs #41774]
 
+! Add an option in site.h to limit the number of failover and control
+  connections the server will accept.  By default this is 200.
+  [ISC-Bugs #41845]
+
                        Changes since 4.1-ESV-R12b1
 
 - None
index 009c7bad670bf11c1a97f70eb190adb1b537a163..803f2399700acc851c16d05b24d4e41173e2a663 100644 (file)
    messages, as we don't expect that is necessary it is on by
    default. */
 #define PRINT_SPECIFIC_CL_ERRORS
+
+/* Limit the value of a file descriptor the serve will use
+   when accepting a connecting request.  This can be used to
+   limit the number of TCP connections that the server will
+   allow at one time.  A value of 0 means there is no limit.*/
+#define MAX_FD_VALUE 200
index cfaadb29222d2f94bb162a4e779c38116e30dd97..f704d9942e86e443d9a657c0d480d065b184205a 100644 (file)
@@ -3,7 +3,7 @@
    Subroutines that support the generic listener object. */
 
 /*
- * Copyright (c) 2012,2014 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2012,2014,2016 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 2004,2007,2009 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1999-2003 by Internet Software Consortium
  *
@@ -233,7 +233,12 @@ isc_result_t omapi_accept (omapi_object_t *h)
                        return ISC_R_NORESOURCES;
                return ISC_R_UNEXPECTED;
        }
-       
+
+       if ((MAX_FD_VALUE != 0) && (socket > MAX_FD_VALUE)) {
+               close(socket);
+               return (ISC_R_NORESOURCES);
+       }
+
 #if defined (TRACING)
        /* If we're recording a trace, remember the connection. */
        if (trace_record ()) {