|
|
32a074 |
From 2c7c69485883ab0f408cf2f8cdcc4617462d68ec Mon Sep 17 00:00:00 2001
|
|
|
32a074 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
32a074 |
Date: Tue, 11 Jun 2019 13:37:23 +0200
|
|
|
32a074 |
Subject: [PATCH 57/57] failover: add dns_resolver_server_timeout option
|
|
|
32a074 |
|
|
|
32a074 |
Resolves:
|
|
|
32a074 |
https://pagure.io/SSSD/sssd/issue/3217
|
|
|
32a074 |
|
|
|
32a074 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
32a074 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
32a074 |
(cherry picked with fixes from commit 99e2a107f01c625cb59cb88589db87294176d6c6)
|
|
|
32a074 |
---
|
|
|
32a074 |
src/config/SSSDConfig/__init__.py.in | 1 +
|
|
|
32a074 |
src/config/SSSDConfigTest.py | 2 ++
|
|
|
32a074 |
src/config/cfg_rules.ini | 1 +
|
|
|
32a074 |
src/config/etc/sssd.api.conf | 1 +
|
|
|
32a074 |
src/man/include/failover.xml | 17 ++++++++++++++++-
|
|
|
32a074 |
src/providers/data_provider.h | 1 +
|
|
|
32a074 |
src/providers/data_provider_fo.c | 3 +++
|
|
|
32a074 |
src/resolv/async_resolv.c | 10 ++++++----
|
|
|
32a074 |
src/resolv/async_resolv.h | 2 +-
|
|
|
32a074 |
src/tests/cmocka/test_fo_srv.c | 4 ++--
|
|
|
32a074 |
src/tests/cmocka/test_resolv_fake.c | 2 +-
|
|
|
32a074 |
src/tests/fail_over-tests.c | 2 +-
|
|
|
32a074 |
src/tests/resolv-tests.c | 2 +-
|
|
|
32a074 |
13 files changed, 37 insertions(+), 11 deletions(-)
|
|
|
32a074 |
|
|
|
32a074 |
diff --git a/src/config/SSSDConfig/__init__.py.in b/src/config/SSSDConfig/__init__.py.in
|
|
|
32a074 |
index f3c6cfebf..1aa93f8cf 100644
|
|
|
32a074 |
--- a/src/config/SSSDConfig/__init__.py.in
|
|
|
32a074 |
+++ b/src/config/SSSDConfig/__init__.py.in
|
|
|
32a074 |
@@ -170,6 +170,7 @@ option_strings = {
|
|
|
32a074 |
'entry_cache_timeout' : _('Entry cache timeout length (seconds)'),
|
|
|
32a074 |
'lookup_family_order' : _('Restrict or prefer a specific address family when performing DNS lookups'),
|
|
|
32a074 |
'account_cache_expiration' : _('How long to keep cached entries after last successful login (days)'),
|
|
|
32a074 |
+ 'dns_resolver_server_timeout' : _('How long should SSSD talk to single DNS server before trying next server (miliseconds)'),
|
|
|
32a074 |
'dns_resolver_op_timeout' : _('How long should keep trying to resolve single DNS query (seconds)'),
|
|
|
32a074 |
'dns_resolver_timeout' : _('How long to wait for replies from DNS when resolving servers (seconds)'),
|
|
|
32a074 |
'dns_discovery_domain' : _('The domain part of service discovery DNS query'),
|
|
|
32a074 |
diff --git a/src/config/SSSDConfigTest.py b/src/config/SSSDConfigTest.py
|
|
|
32a074 |
index 979b1806f..d484e527e 100755
|
|
|
32a074 |
--- a/src/config/SSSDConfigTest.py
|
|
|
32a074 |
+++ b/src/config/SSSDConfigTest.py
|
|
|
32a074 |
@@ -608,6 +608,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
|
|
|
32a074 |
'refresh_expired_interval',
|
|
|
32a074 |
'lookup_family_order',
|
|
|
32a074 |
'account_cache_expiration',
|
|
|
32a074 |
+ 'dns_resolver_server_timeout',
|
|
|
32a074 |
'dns_resolver_op_timeout',
|
|
|
32a074 |
'dns_resolver_timeout',
|
|
|
32a074 |
'dns_discovery_domain',
|
|
|
32a074 |
@@ -980,6 +981,7 @@ class SSSDConfigTestSSSDDomain(unittest.TestCase):
|
|
|
32a074 |
'refresh_expired_interval',
|
|
|
32a074 |
'account_cache_expiration',
|
|
|
32a074 |
'lookup_family_order',
|
|
|
32a074 |
+ 'dns_resolver_server_timeout',
|
|
|
32a074 |
'dns_resolver_op_timeout',
|
|
|
32a074 |
'dns_resolver_timeout',
|
|
|
32a074 |
'dns_discovery_domain',
|
|
|
32a074 |
diff --git a/src/config/cfg_rules.ini b/src/config/cfg_rules.ini
|
|
|
32a074 |
index 79e366875..e8ea13081 100644
|
|
|
32a074 |
--- a/src/config/cfg_rules.ini
|
|
|
32a074 |
+++ b/src/config/cfg_rules.ini
|
|
|
32a074 |
@@ -367,6 +367,7 @@ option = account_cache_expiration
|
|
|
32a074 |
option = pwd_expiration_warning
|
|
|
32a074 |
option = filter_users
|
|
|
32a074 |
option = filter_groups
|
|
|
32a074 |
+option = dns_resolver_server_timeout
|
|
|
32a074 |
option = dns_resolver_op_timeout
|
|
|
32a074 |
option = dns_resolver_timeout
|
|
|
32a074 |
option = dns_discovery_domain
|
|
|
32a074 |
diff --git a/src/config/etc/sssd.api.conf b/src/config/etc/sssd.api.conf
|
|
|
32a074 |
index 355c1fc9b..a771a1148 100644
|
|
|
32a074 |
--- a/src/config/etc/sssd.api.conf
|
|
|
32a074 |
+++ b/src/config/etc/sssd.api.conf
|
|
|
32a074 |
@@ -170,6 +170,7 @@ account_cache_expiration = int, None, false
|
|
|
32a074 |
pwd_expiration_warning = int, None, false
|
|
|
32a074 |
filter_users = list, str, false
|
|
|
32a074 |
filter_groups = list, str, false
|
|
|
32a074 |
+dns_resolver_server_timeout = int, None, false
|
|
|
32a074 |
dns_resolver_op_timeout = int, None, false
|
|
|
32a074 |
dns_resolver_timeout = int, None, false
|
|
|
32a074 |
dns_discovery_domain = str, None, false
|
|
|
32a074 |
diff --git a/src/man/include/failover.xml b/src/man/include/failover.xml
|
|
|
32a074 |
index 7b451d831..f2a01b933 100644
|
|
|
32a074 |
--- a/src/man/include/failover.xml
|
|
|
32a074 |
+++ b/src/man/include/failover.xml
|
|
|
32a074 |
@@ -71,6 +71,20 @@
|
|
|
32a074 |
</citerefentry>,
|
|
|
32a074 |
manual page.
|
|
|
32a074 |
<variablelist>
|
|
|
32a074 |
+ <varlistentry>
|
|
|
32a074 |
+ <term>
|
|
|
32a074 |
+ dns_resolver_server_timeout
|
|
|
32a074 |
+ </term>
|
|
|
32a074 |
+ <listitem>
|
|
|
32a074 |
+ <para>
|
|
|
32a074 |
+ Time in milliseconds that sets how long would SSSD
|
|
|
32a074 |
+ talk to a single DNS server before trying next one.
|
|
|
32a074 |
+ </para>
|
|
|
32a074 |
+ <para>
|
|
|
32a074 |
+ Default: 2000
|
|
|
32a074 |
+ </para>
|
|
|
32a074 |
+ </listitem>
|
|
|
32a074 |
+ </varlistentry>
|
|
|
32a074 |
<varlistentry>
|
|
|
32a074 |
<term>
|
|
|
32a074 |
dns_resolver_op_timeout
|
|
|
32a074 |
@@ -111,7 +125,8 @@
|
|
|
32a074 |
<quote>ldap_opt_timeout></quote> timeout should be set to
|
|
|
32a074 |
a larger value than <quote>dns_resolver_timeout</quote>
|
|
|
32a074 |
which in turn should be set to a larger value than
|
|
|
32a074 |
- <quote>dns_resolver_op_timeout</quote>.
|
|
|
32a074 |
+ <quote>dns_resolver_op_timeout</quote> which should be larger
|
|
|
32a074 |
+ than <quote>dns_resolver_server_timeout</quote>.
|
|
|
32a074 |
</para>
|
|
|
32a074 |
</refsect2>
|
|
|
32a074 |
</refsect1>
|
|
|
32a074 |
diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h
|
|
|
32a074 |
index d30d81bda..e8568993a 100644
|
|
|
32a074 |
--- a/src/providers/data_provider.h
|
|
|
32a074 |
+++ b/src/providers/data_provider.h
|
|
|
32a074 |
@@ -328,6 +328,7 @@ enum dp_res_opts {
|
|
|
32a074 |
DP_RES_OPT_FAMILY_ORDER,
|
|
|
32a074 |
DP_RES_OPT_RESOLVER_TIMEOUT,
|
|
|
32a074 |
DP_RES_OPT_RESOLVER_OP_TIMEOUT,
|
|
|
32a074 |
+ DP_RES_OPT_RESOLVER_SERVER_TIMEOUT,
|
|
|
32a074 |
DP_RES_OPT_DNS_DOMAIN,
|
|
|
32a074 |
|
|
|
32a074 |
DP_RES_OPTS /* attrs counter */
|
|
|
32a074 |
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
|
|
|
32a074 |
index 6e375147d..0cdb97323 100644
|
|
|
32a074 |
--- a/src/providers/data_provider_fo.c
|
|
|
32a074 |
+++ b/src/providers/data_provider_fo.c
|
|
|
32a074 |
@@ -835,6 +835,7 @@ static struct dp_option dp_res_default_opts[] = {
|
|
|
32a074 |
{ "lookup_family_order", DP_OPT_STRING, { "ipv4_first" }, NULL_STRING },
|
|
|
32a074 |
{ "dns_resolver_timeout", DP_OPT_NUMBER, { .number = 6 }, NULL_NUMBER },
|
|
|
32a074 |
{ "dns_resolver_op_timeout", DP_OPT_NUMBER, { .number = 6 }, NULL_NUMBER },
|
|
|
32a074 |
+ { "dns_resolver_server_timeout", DP_OPT_NUMBER, { .number = 2000 }, NULL_NUMBER },
|
|
|
32a074 |
{ "dns_discovery_domain", DP_OPT_STRING, NULL_STRING, NULL_STRING },
|
|
|
32a074 |
DP_OPTION_TERMINATOR
|
|
|
32a074 |
};
|
|
|
32a074 |
@@ -896,6 +897,8 @@ errno_t be_res_init(struct be_ctx *ctx)
|
|
|
32a074 |
ret = resolv_init(ctx, ctx->ev,
|
|
|
32a074 |
dp_opt_get_int(ctx->be_res->opts,
|
|
|
32a074 |
DP_RES_OPT_RESOLVER_OP_TIMEOUT),
|
|
|
32a074 |
+ dp_opt_get_int(ctx->be_res->opts,
|
|
|
32a074 |
+ DP_RES_OPT_RESOLVER_SERVER_TIMEOUT),
|
|
|
32a074 |
&ctx->be_res->resolv);
|
|
|
32a074 |
if (ret != EOK) {
|
|
|
32a074 |
talloc_zfree(ctx->be_res);
|
|
|
32a074 |
diff --git a/src/resolv/async_resolv.c b/src/resolv/async_resolv.c
|
|
|
32a074 |
index bb2701154..b833d7211 100644
|
|
|
32a074 |
--- a/src/resolv/async_resolv.c
|
|
|
32a074 |
+++ b/src/resolv/async_resolv.c
|
|
|
32a074 |
@@ -60,8 +60,6 @@
|
|
|
32a074 |
#define DNS_RR_LEN(r) DNS__16BIT((r) + 8)
|
|
|
32a074 |
#define DNS_RR_TTL(r) DNS__32BIT((r) + 4)
|
|
|
32a074 |
|
|
|
32a074 |
-#define RESOLV_TIMEOUTMS 2000
|
|
|
32a074 |
-
|
|
|
32a074 |
enum host_database default_host_dbs[] = { DB_FILES, DB_DNS, DB_SENTINEL };
|
|
|
32a074 |
|
|
|
32a074 |
struct fd_watch {
|
|
|
32a074 |
@@ -83,6 +81,9 @@ struct resolv_ctx {
|
|
|
32a074 |
/* Time in milliseconds before canceling a DNS request */
|
|
|
32a074 |
int timeout;
|
|
|
32a074 |
|
|
|
32a074 |
+ /* Time in milliseconds for communication with single DNS server. */
|
|
|
32a074 |
+ int ares_timeout;
|
|
|
32a074 |
+
|
|
|
32a074 |
/* The timeout watcher periodically calls ares_process_fd() to check
|
|
|
32a074 |
* if our pending requests didn't timeout. */
|
|
|
32a074 |
int pending_requests;
|
|
|
32a074 |
@@ -423,7 +424,7 @@ recreate_ares_channel(struct resolv_ctx *ctx)
|
|
|
32a074 |
*/
|
|
|
32a074 |
options.sock_state_cb = fd_event;
|
|
|
32a074 |
options.sock_state_cb_data = ctx;
|
|
|
32a074 |
- options.timeout = RESOLV_TIMEOUTMS;
|
|
|
32a074 |
+ options.timeout = ctx->ares_timeout;
|
|
|
32a074 |
/* Only affects ares_gethostbyname */
|
|
|
32a074 |
options.lookups = discard_const("f");
|
|
|
32a074 |
options.tries = 1;
|
|
|
32a074 |
@@ -450,7 +451,7 @@ recreate_ares_channel(struct resolv_ctx *ctx)
|
|
|
32a074 |
|
|
|
32a074 |
int
|
|
|
32a074 |
resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
|
|
|
32a074 |
- int timeout, struct resolv_ctx **ctxp)
|
|
|
32a074 |
+ int timeout, int ares_timeout, struct resolv_ctx **ctxp)
|
|
|
32a074 |
{
|
|
|
32a074 |
int ret;
|
|
|
32a074 |
struct resolv_ctx *ctx;
|
|
|
32a074 |
@@ -467,6 +468,7 @@ resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
|
|
|
32a074 |
|
|
|
32a074 |
ctx->ev_ctx = ev_ctx;
|
|
|
32a074 |
ctx->timeout = timeout;
|
|
|
32a074 |
+ ctx->ares_timeout = ares_timeout;
|
|
|
32a074 |
|
|
|
32a074 |
ret = recreate_ares_channel(ctx);
|
|
|
32a074 |
if (ret != EOK) {
|
|
|
32a074 |
diff --git a/src/resolv/async_resolv.h b/src/resolv/async_resolv.h
|
|
|
32a074 |
index 90ed03707..d83a7be44 100644
|
|
|
32a074 |
--- a/src/resolv/async_resolv.h
|
|
|
32a074 |
+++ b/src/resolv/async_resolv.h
|
|
|
32a074 |
@@ -52,7 +52,7 @@
|
|
|
32a074 |
struct resolv_ctx;
|
|
|
32a074 |
|
|
|
32a074 |
int resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
|
|
|
32a074 |
- int timeout, struct resolv_ctx **ctxp);
|
|
|
32a074 |
+ int timeout, int ares_timeout, struct resolv_ctx **ctxp);
|
|
|
32a074 |
|
|
|
32a074 |
void resolv_reread_configuration(struct resolv_ctx *ctx);
|
|
|
32a074 |
|
|
|
32a074 |
diff --git a/src/tests/cmocka/test_fo_srv.c b/src/tests/cmocka/test_fo_srv.c
|
|
|
32a074 |
index a11ebbb54..c13cf3a69 100644
|
|
|
32a074 |
--- a/src/tests/cmocka/test_fo_srv.c
|
|
|
32a074 |
+++ b/src/tests/cmocka/test_fo_srv.c
|
|
|
32a074 |
@@ -49,7 +49,7 @@ struct resolv_ctx {
|
|
|
32a074 |
|
|
|
32a074 |
/* mock resolver interface. The resolver test is separate */
|
|
|
32a074 |
int resolv_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev_ctx,
|
|
|
32a074 |
- int timeout, struct resolv_ctx **ctxp)
|
|
|
32a074 |
+ int timeout, int ares_timeout, struct resolv_ctx **ctxp)
|
|
|
32a074 |
{
|
|
|
32a074 |
*ctxp = talloc(mem_ctx, struct resolv_ctx);
|
|
|
32a074 |
return EOK;
|
|
|
32a074 |
@@ -230,7 +230,7 @@ static int test_fo_setup(void **state)
|
|
|
32a074 |
assert_non_null(test_ctx->ctx);
|
|
|
32a074 |
|
|
|
32a074 |
ret = resolv_init(test_ctx, test_ctx->ctx->ev,
|
|
|
32a074 |
- TEST_RESOLV_TIMEOUT, &test_ctx->resolv);
|
|
|
32a074 |
+ TEST_RESOLV_TIMEOUT, 2000, &test_ctx->resolv);
|
|
|
32a074 |
assert_non_null(test_ctx->resolv);
|
|
|
32a074 |
|
|
|
32a074 |
memset(&fopts, 0, sizeof(fopts));
|
|
|
32a074 |
diff --git a/src/tests/cmocka/test_resolv_fake.c b/src/tests/cmocka/test_resolv_fake.c
|
|
|
32a074 |
index 4cb3d4027..0f4011a39 100644
|
|
|
32a074 |
--- a/src/tests/cmocka/test_resolv_fake.c
|
|
|
32a074 |
+++ b/src/tests/cmocka/test_resolv_fake.c
|
|
|
32a074 |
@@ -240,7 +240,7 @@ static int test_resolv_fake_setup(void **state)
|
|
|
32a074 |
assert_non_null(test_ctx->ctx);
|
|
|
32a074 |
|
|
|
32a074 |
ret = resolv_init(test_ctx, test_ctx->ctx->ev,
|
|
|
32a074 |
- TEST_DEFAULT_TIMEOUT, &test_ctx->resolv);
|
|
|
32a074 |
+ TEST_DEFAULT_TIMEOUT, 2000, &test_ctx->resolv);
|
|
|
32a074 |
assert_int_equal(ret, EOK);
|
|
|
32a074 |
|
|
|
32a074 |
*state = test_ctx;
|
|
|
32a074 |
diff --git a/src/tests/fail_over-tests.c b/src/tests/fail_over-tests.c
|
|
|
32a074 |
index 5312b2772..b2269ef3b 100644
|
|
|
32a074 |
--- a/src/tests/fail_over-tests.c
|
|
|
32a074 |
+++ b/src/tests/fail_over-tests.c
|
|
|
32a074 |
@@ -73,7 +73,7 @@ setup_test(void)
|
|
|
32a074 |
fail("Could not init tevent context");
|
|
|
32a074 |
}
|
|
|
32a074 |
|
|
|
32a074 |
- ret = resolv_init(ctx, ctx->ev, 5, &ctx->resolv);
|
|
|
32a074 |
+ ret = resolv_init(ctx, ctx->ev, 5, 2000, &ctx->resolv);
|
|
|
32a074 |
if (ret != EOK) {
|
|
|
32a074 |
talloc_free(ctx);
|
|
|
32a074 |
fail("Could not init resolv context");
|
|
|
32a074 |
diff --git a/src/tests/resolv-tests.c b/src/tests/resolv-tests.c
|
|
|
32a074 |
index 4a2b3b904..bc4cd7cc1 100644
|
|
|
32a074 |
--- a/src/tests/resolv-tests.c
|
|
|
32a074 |
+++ b/src/tests/resolv-tests.c
|
|
|
32a074 |
@@ -76,7 +76,7 @@ static int setup_resolv_test(int timeout, struct resolv_test_ctx **ctx)
|
|
|
32a074 |
return EFAULT;
|
|
|
32a074 |
}
|
|
|
32a074 |
|
|
|
32a074 |
- ret = resolv_init(test_ctx, test_ctx->ev, timeout, &test_ctx->resolv);
|
|
|
32a074 |
+ ret = resolv_init(test_ctx, test_ctx->ev, timeout, 2000, &test_ctx->resolv);
|
|
|
32a074 |
if (ret != EOK) {
|
|
|
32a074 |
fail("Could not init resolv context");
|
|
|
32a074 |
talloc_free(test_ctx);
|
|
|
32a074 |
--
|
|
|
32a074 |
2.21.3
|
|
|
32a074 |
|