Compare commits

...
Author SHA1 Message Date
Ondřej Surý ae9b3bdbae Add CHANGES and release note for [GL #3958] 2023-09-12 11:05:07 +02:00
Ondřej Surý 45f7b201b7 Allow the tcp-clients to be specified as percent, set default to 50%
Change the tcp-clients configuration value to allow specifying
percents (out of the maximum allowed file descriptors) and set the
default to 50% of that value.
2023-09-12 11:04:49 +02:00
11 changed files with 58 additions and 11 deletions
+6
View File
@@ -1,3 +1,7 @@
6247. [performance] Change the "tcp-clients" value to allow specifying
percents of the maximum allowed file descriptors and
set the default value to 50%. [GL #3958]
6246. [placeholder]
6245. [placeholder]
@@ -303,6 +307,8 @@
file. [GL #3991]
6160. [bug] 'delv +ns' could print duplicate output. [GL #4020]
=======
>>>>>>> 25abcb8750 (Add CHANGES and release note for [GL #3958])
6159. [bug] Fix use-after-free bug in TCP accept connection
failure. [GL #4018]
+1 -1
View File
@@ -112,7 +112,7 @@ options {\n\
startup-notify-rate 20;\n\
statistics-file \"named.stats\";\n\
tcp-advertised-timeout 300;\n\
tcp-clients 150;\n\
tcp-clients 50%;\n\
tcp-idle-timeout 300;\n\
tcp-initial-timeout 300;\n\
tcp-keepalive-timeout 300;\n\
+2
View File
@@ -16,6 +16,7 @@
/*! \file */
#include <stdbool.h>
#include <sys/resource.h>
#include <isc/log.h>
#include <isc/loop.h>
@@ -115,6 +116,7 @@ EXTERN bool named_g_foreground INIT(false);
EXTERN bool named_g_logstderr INIT(false);
EXTERN bool named_g_nosyslog INIT(false);
EXTERN const char *named_g_logfile INIT(NULL);
EXTERN rlim_t named_g_nofiles INIT(0);
EXTERN const char *named_g_defaultsessionkeyfile INIT(NAMED_LOCALSTATEDIR
"/run/named/"
+2 -1
View File
@@ -17,6 +17,7 @@
#include <pwd.h>
#include <stdbool.h>
#include <sys/resource.h>
#include <isc/types.h>
@@ -44,7 +45,7 @@ named_os_changeuser(void);
uid_t
ns_os_uid(void);
void
rlim_t
named_os_adjustnofile(void);
void
+1 -1
View File
@@ -1283,7 +1283,7 @@ setup(void) {
* System resources cannot effectively be tuned on some systems.
* Raise the limit in such cases for safety.
*/
named_os_adjustnofile();
named_g_nofiles = named_os_adjustnofile();
/*
* If the named configuration filename is relative, prepend the current
+4 -4
View File
@@ -613,7 +613,7 @@ ns_os_uid(void) {
return (runas_pw->pw_uid);
}
void
rlim_t
named_os_adjustnofile(void) {
int r;
struct rlimit rl;
@@ -634,7 +634,7 @@ named_os_adjustnofile(void) {
"maximum allowed value: "
"%" PRIu64,
(uint64_t)rl.rlim_max);
return;
return (rl.rlim_cur);
}
rl.rlim_cur = rl.rlim_max;
@@ -649,13 +649,13 @@ named_os_adjustnofile(void) {
"%" PRIu64 " to "
"%" PRIu64,
(uint64_t)rlim_old, (uint64_t)rl.rlim_cur);
return;
return (rl.rlim_cur);
fail:
strerror_r(errno, strbuf, sizeof(strbuf));
named_main_earlywarning("adjusting limit on open files failed: %s",
strbuf);
return;
return (0);
}
void
+34 -1
View File
@@ -8459,7 +8459,6 @@ load_configuration(const char *filename, named_server_t *server,
*/
configure_server_quota(maps, "transfers-out",
&server->sctx->xfroutquota);
configure_server_quota(maps, "tcp-clients", &server->sctx->tcpquota);
configure_server_quota(maps, "recursive-clients",
&server->sctx->recursionquota);
configure_server_quota(maps, "update-quota", &server->sctx->updquota);
@@ -8484,6 +8483,40 @@ load_configuration(const char *filename, named_server_t *server,
isc_quota_soft(&server->sctx->recursionquota, softquota);
obj = NULL;
result = named_config_get(maps, "tcp-clients", &obj);
INSIST(result == ISC_R_SUCCESS);
uint32_t tcp_clients = 0;
if (cfg_obj_isstring(obj)) {
const char *str = cfg_obj_asstring(obj);
INSIST(strcasecmp(str, "unlimited") == 0);
tcp_clients = UINT32_MAX;
} else if (cfg_obj_ispercentage(obj)) {
INSIST(named_g_nofiles != 0);
uint32_t tcp_clients_percent = cfg_obj_aspercentage(obj);
tcp_clients = named_g_nofiles * tcp_clients_percent / 100;
cfg_obj_log(obj, named_g_lctx, ISC_LOG_INFO,
"'tcp-clients %" PRIu32 "%%' - setting to %" PRIu32
" (out of %" PRIu32 " file descriptors)",
tcp_clients_percent, tcp_clients,
(uint32_t)named_g_nofiles);
} else {
uint64_t value = cfg_obj_asuint64(obj);
if (value > UINT32_MAX) {
cfg_obj_log(obj, named_g_lctx, ISC_LOG_WARNING,
"'tcp-clients "
"%" PRIu64 "' "
"is too large for this "
"system; reducing to %" PRIu32,
value, UINT32_MAX);
value = UINT32_MAX;
}
tcp_clients = (uint32_t)value;
}
isc_quota_max(&server->sctx->tcpquota, tcp_clients);
/*
* Set "blackhole". Only legal at options level; there is
* no default.
+2 -1
View File
@@ -3563,7 +3563,8 @@ system.
:short: Specifies the maximum number of simultaneous client TCP connections accepted by the server.
This is the maximum number of simultaneous client TCP connections that the
server accepts. The default is ``150``.
server accepts, in bytes of percentage of maximum allowed file descriptors.
The default is ``50%``.
.. namedconf:statement:: clients-per-query
:tags: server
+1 -1
View File
@@ -277,7 +277,7 @@ options {
statistics-file <quoted_string>;
synth-from-dnssec <boolean>;
tcp-advertised-timeout <integer>;
tcp-clients <integer>;
tcp-clients ( default | unlimited | <sizeval> | <percentage> );
tcp-idle-timeout <integer>;
tcp-initial-timeout <integer>;
tcp-keepalive-timeout <integer>;
+4
View File
@@ -44,6 +44,10 @@ Feature Changes
those versions do not provide the features required by current BIND 9
releases. :gl:`#4296`
- The ``tcp-clients`` configuration option now also accepts value as percent of
maximum allowed file descriptors. The default has been changed to ``50%``.
:gl:`#3958`
Bug Fixes
~~~~~~~~~
+1 -1
View File
@@ -1313,7 +1313,7 @@ static cfg_clausedef_t options_clauses[] = {
{ "statistics-file", &cfg_type_qstring, 0 },
{ "statistics-interval", NULL, CFG_CLAUSEFLAG_ANCIENT },
{ "tcp-advertised-timeout", &cfg_type_uint32, 0 },
{ "tcp-clients", &cfg_type_uint32, 0 },
{ "tcp-clients", &cfg_type_sizeorpercent, 0 },
{ "tcp-idle-timeout", &cfg_type_uint32, 0 },
{ "tcp-initial-timeout", &cfg_type_uint32, 0 },
{ "tcp-keepalive-timeout", &cfg_type_uint32, 0 },