File dhcp-4.3.4-limit-the-value-of-an-fd-we-accept.patch of Package dhcp.24175
From d9a49cc635aef5a0f9e86a847dfaed2d7bd8ecad Mon Sep 17 00:00:00 2001
From: Nirmoy Das <ndas@suse.de>
Date: Thu, 16 Jun 2016 16:09:50 +0200
Subject: [PATCH] Add patch to limit the value of an fd we accept for a
connection.
By limiting the highest value we accept for an fd we limit the number
of connections.
References:bsc#969820
---
includes/site.h | 6 ++++++
omapip/listener.c | 5 +++++
2 files changed, 11 insertions(+)
diff --git a/includes/site.h b/includes/site.h
index f11fefb..b39ff34 100644
--- a/includes/site.h
+++ b/includes/site.h
@@ -292,6 +292,12 @@
this option will be removed at some time. */
/* #define INCLUDE_OLD_DHCP_ISC_ERROR_CODES */
+/* 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
+
/* Include definitions for various options. In general these
should be left as is, but if you have already defined one
of these and prefer your definition you can comment the
diff --git a/omapip/listener.c b/omapip/listener.c
index 8bdcdbd..2d5cd8a 100644
--- a/omapip/listener.c
+++ b/omapip/listener.c
@@ -234,6 +234,11 @@ isc_result_t omapi_accept (omapi_object_t *h)
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 ()) {
--
2.6.2