summaryrefslogtreecommitdiffstats
path: root/src/providers
diff options
context:
space:
mode:
authorJakub Hrozek <jhrozek@redhat.com>2014-12-12 17:10:40 +0100
committerJakub Hrozek <jhrozek@redhat.com>2015-03-03 16:15:37 +0100
commit8df69bbc58c2f4d3f0b34be9756d9ddf24b1db6d (patch)
tree643138d18dd31a9ea0e5691daf19baea0dc0e396 /src/providers
parenteafbc66c2ff6365478e62a8df3fd005bf80e5c7b (diff)
downloadsssd-8df69bbc58c2f4d3f0b34be9756d9ddf24b1db6d.tar.gz
sssd-8df69bbc58c2f4d3f0b34be9756d9ddf24b1db6d.tar.xz
sssd-8df69bbc58c2f4d3f0b34be9756d9ddf24b1db6d.zip
FO: Use SRV TTL in fail over code
Resolves: https://fedorahosted.org/sssd/ticket/1884 Removes the hardcoded SRV TTL timeout and uses TTL from the DNS instead. Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Diffstat (limited to 'src/providers')
-rw-r--r--src/providers/ad/ad_srv.c8
-rw-r--r--src/providers/ad/ad_srv.h1
-rw-r--r--src/providers/data_provider_fo.c1
-rw-r--r--src/providers/fail_over.c8
-rw-r--r--src/providers/fail_over.h1
-rw-r--r--src/providers/fail_over_srv.c27
-rw-r--r--src/providers/fail_over_srv.h4
-rw-r--r--src/providers/ipa/ipa_srv.c6
-rw-r--r--src/providers/ipa/ipa_srv.h1
9 files changed, 48 insertions, 9 deletions
diff --git a/src/providers/ad/ad_srv.c b/src/providers/ad/ad_srv.c
index ac9dfa187..910f82dd0 100644
--- a/src/providers/ad/ad_srv.c
+++ b/src/providers/ad/ad_srv.c
@@ -176,7 +176,7 @@ static void ad_get_dc_servers_done(struct tevent_req *subreq)
req = tevent_req_callback_data(subreq, struct tevent_req);
state = tevent_req_data(req, struct ad_get_dc_servers_state);
- ret = fo_discover_srv_recv(state, subreq, &domain,
+ ret = fo_discover_srv_recv(state, subreq, &domain, NULL,
&state->servers, &state->num_servers);
talloc_zfree(subreq);
if (ret != EOK) {
@@ -616,6 +616,7 @@ struct ad_srv_plugin_state {
const char *site;
char *dns_domain;
+ uint32_t ttl;
char *forest;
struct fo_server_info *primary_servers;
size_t num_primary_servers;
@@ -837,6 +838,7 @@ static void ad_srv_plugin_servers_done(struct tevent_req *subreq)
state = tevent_req_data(req, struct ad_srv_plugin_state);
ret = fo_discover_servers_recv(state, subreq, &state->dns_domain,
+ &state->ttl,
&state->primary_servers,
&state->num_primary_servers,
&state->backup_servers,
@@ -874,6 +876,7 @@ static void ad_srv_plugin_servers_done(struct tevent_req *subreq)
errno_t ad_srv_plugin_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -904,6 +907,9 @@ errno_t ad_srv_plugin_recv(TALLOC_CTX *mem_ctx,
*_dns_domain = talloc_steal(mem_ctx, state->dns_domain);
}
+ if (_ttl) {
+ *_ttl = state->ttl;
+ }
return EOK;
}
diff --git a/src/providers/ad/ad_srv.h b/src/providers/ad/ad_srv.h
index be3ac2826..ae5efe447 100644
--- a/src/providers/ad/ad_srv.h
+++ b/src/providers/ad/ad_srv.h
@@ -42,6 +42,7 @@ struct tevent_req *ad_srv_plugin_send(TALLOC_CTX *mem_ctx,
errno_t ad_srv_plugin_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
diff --git a/src/providers/data_provider_fo.c b/src/providers/data_provider_fo.c
index ef1f0b2ed..dab796d46 100644
--- a/src/providers/data_provider_fo.c
+++ b/src/providers/data_provider_fo.c
@@ -70,7 +70,6 @@ static int be_fo_get_options(struct be_ctx *ctx,
opts->service_resolv_timeout = dp_opt_get_int(ctx->be_res->opts,
DP_RES_OPT_RESOLVER_TIMEOUT);
opts->retry_timeout = 30;
- opts->srv_retry_timeout = 14400;
opts->srv_retry_neg_timeout = 15;
opts->family_order = ctx->be_res->family_order;
diff --git a/src/providers/fail_over.c b/src/providers/fail_over.c
index c16c70ddb..814208152 100644
--- a/src/providers/fail_over.c
+++ b/src/providers/fail_over.c
@@ -117,6 +117,7 @@ struct srv_data {
struct fo_server *meta;
int srv_lookup_status;
+ int ttl;
struct timeval last_status_change;
};
@@ -149,7 +150,6 @@ fo_context_init(TALLOC_CTX *mem_ctx, struct fo_options *opts)
return NULL;
}
- ctx->opts->srv_retry_timeout = opts->srv_retry_timeout;
ctx->opts->srv_retry_neg_timeout = opts->srv_retry_neg_timeout;
ctx->opts->retry_timeout = opts->retry_timeout;
ctx->opts->family_order = opts->family_order;
@@ -272,7 +272,7 @@ get_srv_data_status(struct srv_data *data)
if (data->srv_lookup_status == SRV_RESOLVE_ERROR) {
timeout = data->meta->service->ctx->opts->srv_retry_neg_timeout;
} else {
- timeout = data->meta->service->ctx->opts->srv_retry_timeout;
+ timeout = data->ttl;
}
if (timeout && STATUS_DIFF(data, tv) > timeout) {
@@ -1285,8 +1285,9 @@ resolve_srv_done(struct tevent_req *subreq)
size_t num_backup_servers = 0;
char *dns_domain = NULL;
int ret;
+ uint32_t ttl;
- ret = state->fo_ctx->srv_recv_fn(state, subreq, &dns_domain,
+ ret = state->fo_ctx->srv_recv_fn(state, subreq, &dns_domain, &ttl,
&primary_servers, &num_primary_servers,
&backup_servers, &num_backup_servers);
talloc_free(subreq);
@@ -1300,6 +1301,7 @@ resolve_srv_done(struct tevent_req *subreq)
goto done;
}
+ state->meta->srv_data->ttl = ttl;
talloc_zfree(state->meta->srv_data->dns_domain);
state->meta->srv_data->dns_domain = talloc_steal(state->meta->srv_data,
dns_domain);
diff --git a/src/providers/fail_over.h b/src/providers/fail_over.h
index b1ec6a23c..d44ad2ff1 100644
--- a/src/providers/fail_over.h
+++ b/src/providers/fail_over.h
@@ -78,7 +78,6 @@ struct fo_server;
* try when looking up the service.
*/
struct fo_options {
- time_t srv_retry_timeout;
time_t srv_retry_neg_timeout;
time_t retry_timeout;
int service_resolv_timeout;
diff --git a/src/providers/fail_over_srv.c b/src/providers/fail_over_srv.c
index 5c06d2876..5f474eaee 100644
--- a/src/providers/fail_over_srv.c
+++ b/src/providers/fail_over_srv.c
@@ -30,6 +30,7 @@ struct fo_discover_srv_state {
char *dns_domain;
struct fo_server_info *servers;
size_t num_servers;
+ uint32_t ttl;
};
static void fo_discover_srv_done(struct tevent_req *subreq);
@@ -83,7 +84,7 @@ static void fo_discover_srv_done(struct tevent_req *subreq)
state = tevent_req_data(req, struct fo_discover_srv_state);
ret = resolv_discover_srv_recv(state, subreq,
- &reply_list, NULL, &state->dns_domain);
+ &reply_list, &state->ttl, &state->dns_domain);
talloc_zfree(subreq);
if (ret == ENOENT) {
ret = ERR_SRV_NOT_FOUND;
@@ -143,6 +144,7 @@ done:
errno_t fo_discover_srv_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_servers,
size_t *_num_servers)
{
@@ -159,6 +161,10 @@ errno_t fo_discover_srv_recv(TALLOC_CTX *mem_ctx,
*_servers = talloc_steal(mem_ctx, state->servers);
}
+ if (_ttl != NULL) {
+ *_ttl = state->ttl;
+ }
+
if (_num_servers != NULL) {
*_num_servers = state->num_servers;
}
@@ -175,6 +181,7 @@ struct fo_discover_servers_state {
const char *backup_domain;
char *dns_domain;
+ uint32_t ttl;
struct fo_server_info *primary_servers;
size_t num_primary_servers;
struct fo_server_info *backup_servers;
@@ -212,6 +219,7 @@ struct tevent_req *fo_discover_servers_send(TALLOC_CTX *mem_ctx,
state->backup_servers = NULL;
state->num_backup_servers = 0;
state->dns_domain = NULL;
+ state->ttl = 0;
ret = EOK;
goto immediately;
@@ -289,6 +297,7 @@ static void fo_discover_servers_primary_done(struct tevent_req *subreq)
ret = fo_discover_srv_recv(state, subreq,
&state->dns_domain,
+ &state->ttl,
&state->primary_servers,
&state->num_primary_servers);
talloc_zfree(subreq);
@@ -361,7 +370,7 @@ static void fo_discover_servers_backup_done(struct tevent_req *subreq)
state = tevent_req_data(req, struct fo_discover_servers_state);
ret = fo_discover_srv_recv(state, subreq, NULL,
- &state->backup_servers,
+ NULL, &state->backup_servers,
&state->num_backup_servers);
talloc_zfree(subreq);
if (ret != EOK) {
@@ -385,6 +394,7 @@ static void fo_discover_servers_backup_done(struct tevent_req *subreq)
errno_t fo_discover_servers_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -415,6 +425,10 @@ errno_t fo_discover_servers_recv(TALLOC_CTX *mem_ctx,
*_dns_domain = talloc_steal(mem_ctx, state->dns_domain);
}
+ if (_ttl) {
+ *_ttl = state->ttl;
+ }
+
return EOK;
}
@@ -436,6 +450,7 @@ struct fo_resolve_srv_dns_state {
const char *discovery_domain;
char *dns_domain;
+ uint32_t ttl;
struct fo_server_info *servers;
size_t num_servers;
};
@@ -644,7 +659,8 @@ static void fo_resolve_srv_dns_done(struct tevent_req *subreq)
req = tevent_req_callback_data(subreq, struct tevent_req);
state = tevent_req_data(req, struct fo_resolve_srv_dns_state);
- ret = fo_discover_srv_recv(state, subreq, &state->dns_domain,
+ ret = fo_discover_srv_recv(state, subreq,
+ &state->dns_domain, &state->ttl,
&state->servers, &state->num_servers);
talloc_zfree(subreq);
if (ret != EOK) {
@@ -663,6 +679,7 @@ done:
errno_t fo_resolve_srv_dns_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -694,5 +711,9 @@ errno_t fo_resolve_srv_dns_recv(TALLOC_CTX *mem_ctx,
*_dns_domain = talloc_steal(mem_ctx, state->dns_domain);
}
+ if (_ttl) {
+ *_ttl = state->ttl;
+ }
+
return EOK;
}
diff --git a/src/providers/fail_over_srv.h b/src/providers/fail_over_srv.h
index c4b50ba33..fe4088e02 100644
--- a/src/providers/fail_over_srv.h
+++ b/src/providers/fail_over_srv.h
@@ -65,6 +65,7 @@ typedef errno_t
(*fo_srv_lookup_plugin_recv_t)(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -80,6 +81,7 @@ struct tevent_req *fo_discover_srv_send(TALLOC_CTX *mem_ctx,
errno_t fo_discover_srv_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_servers,
size_t *_num_servers);
@@ -94,6 +96,7 @@ struct tevent_req *fo_discover_servers_send(TALLOC_CTX *mem_ctx,
errno_t fo_discover_servers_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -121,6 +124,7 @@ struct tevent_req *fo_resolve_srv_dns_send(TALLOC_CTX *mem_ctx,
errno_t fo_resolve_srv_dns_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
diff --git a/src/providers/ipa/ipa_srv.c b/src/providers/ipa/ipa_srv.c
index 4be5f3317..747771134 100644
--- a/src/providers/ipa/ipa_srv.c
+++ b/src/providers/ipa/ipa_srv.c
@@ -69,6 +69,7 @@ fail:
struct ipa_srv_plugin_state {
char *dns_domain;
+ uint32_t ttl;
struct fo_server_info *primary_servers;
size_t num_primary_servers;
struct fo_server_info *backup_servers;
@@ -164,6 +165,7 @@ static void ipa_srv_plugin_done(struct tevent_req *subreq)
state = tevent_req_data(req, struct ipa_srv_plugin_state);
ret = fo_discover_servers_recv(state, subreq, &state->dns_domain,
+ &state->ttl,
&state->primary_servers,
&state->num_primary_servers,
&state->backup_servers,
@@ -183,6 +185,7 @@ static void ipa_srv_plugin_done(struct tevent_req *subreq)
errno_t ipa_srv_plugin_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,
@@ -213,6 +216,9 @@ errno_t ipa_srv_plugin_recv(TALLOC_CTX *mem_ctx,
*_dns_domain = talloc_steal(mem_ctx, state->dns_domain);
}
+ if (_ttl) {
+ *_ttl = state->ttl;
+ }
return EOK;
}
diff --git a/src/providers/ipa/ipa_srv.h b/src/providers/ipa/ipa_srv.h
index 1bfd2eeae..d089c9f64 100644
--- a/src/providers/ipa/ipa_srv.h
+++ b/src/providers/ipa/ipa_srv.h
@@ -39,6 +39,7 @@ struct tevent_req *ipa_srv_plugin_send(TALLOC_CTX *mem_ctx,
errno_t ipa_srv_plugin_recv(TALLOC_CTX *mem_ctx,
struct tevent_req *req,
char **_dns_domain,
+ uint32_t *_ttl,
struct fo_server_info **_primary_servers,
size_t *_num_primary_servers,
struct fo_server_info **_backup_servers,