File dhcp-4.3.4-limit-the-value-of-an-fd-we-accept.patch of Package dhcp.2753
From 9b9f49d6078a31d9e18ac1484657ef73212b4c35 Mon Sep 17 00:00:00 2001
From: Nirmoy Das <ndas@suse.de>
Date: Thu, 16 Jun 2016 16:31:18 +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 | 5 +++++
omapip/listener.c | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/includes/site.h b/includes/site.h
index 1b6d0c0..36fa614 100644
--- a/includes/site.h
+++ b/includes/site.h
@@ -283,3 +283,8 @@
#define LOG_V6_ADDRESSES
+/* 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
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