1 This patch adds a method to manage the resource limit which was
2 introduced by the fix for ISC-Bugs #41845. This patch was developed
3 in-house. ISC did not express any interest in incorporating this patch
4 into their code since they consider the limit to be a mitigating
7 diff -r 1680283c6725 includes/omapip/omapip.h
8 --- a/includes/omapip/omapip.h Tue Jan 16 13:35:26 2018 -0800
9 +++ b/includes/omapip/omapip.h Tue Jan 16 18:01:14 2018 -0800
12 extern omapi_object_type_t *omapi_object_types;
15 +void omapi_set_max_fd_value (void);
17 void omapi_type_relinquish (void);
18 isc_result_t omapi_init (void);
19 isc_result_t omapi_object_type_register (omapi_object_type_t **,
20 diff -r 1680283c6725 omapip/listener.c
21 --- a/omapip/listener.c Tue Jan 16 13:35:26 2018 -0800
22 +++ b/omapip/listener.c Tue Jan 16 18:01:14 2018 -0800
24 trace_type_t *trace_listener_accept;
28 +static int conn_limit = MAX_FD_VALUE; /* max number of open sockets allowed */
31 OMAPI_OBJECT_ALLOC (omapi_listener,
32 omapi_listener_object_t, omapi_type_listener)
39 +/* If OMAPI_CONN_LIMIT environment variable is set, obtain value. */
40 +const char *fname = "omapi_set_max_fd_value";
41 +void omapi_set_max_fd_value (void)
45 + int envval = conn_limit;
47 + env = getenv("OMAPI_CONN_LIMIT");
50 + envval = (int)strtol(env, &end, 10);
51 + if (errno != 0 || env == end || *end != '\0' || envval < 0) {
52 + (void) log_error("%s: \"%s\" is not a valid connection "
53 + "limit value\n", fname, env);
56 + conn_limit = envval;
59 + (void) log_debug("%s: conn_limit = %d%s\n", fname, conn_limit,
60 + (conn_limit == MAX_FD_VALUE) ? " (default)" :
61 + (conn_limit == 0) ? " (unlimited)" : "");
67 /* Reader callback for a listener object. Accept an incoming connection. */
68 isc_result_t omapi_accept (omapi_object_t *h)
71 return ISC_R_UNEXPECTED;
75 if ((MAX_FD_VALUE != 0) && (socket > MAX_FD_VALUE)) {
77 + if ((conn_limit != 0) && (socket > conn_limit)) {
78 + (void) log_debug("omapi_accept: No more available "
79 + "sockets - closing latest.\n");
82 return (ISC_R_NORESOURCES);
84 diff -r 1680283c6725 server/dhcpd.c
85 --- a/server/dhcpd.c Tue Jan 16 13:35:26 2018 -0800
86 +++ b/server/dhcpd.c Tue Jan 16 18:01:14 2018 -0800
92 + omapi_set_max_fd_value ();
96 if (local_family == AF_INET6) {
97 /* DHCPv6: override DHCPv4 lease and pid filenames */