From 85af93b8c74b5664fc473cf84d59ce6279249216 Mon Sep 17 00:00:00 2001 From: Christopher Faulet Date: Thu, 10 Jun 2021 16:59:53 +0200 Subject: [PATCH] BUG/MINOR: server-state: load SRV resolution only if params match the config When the state of a server is loaded, if there is no hostname defined for this server and if a fqdn and a server record are retrieved from the state file, it means the server should rely on a SRV resolution. But we must be sure the server is configured this way. A SRV resolution must be configured with the same SRV record. This part must be skipped if there is no SRV resolution configured for this server or if the SRV record used is not the same. This patch should be backported as far as 1.8 after some observation period. --- src/server_state.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/server_state.c b/src/server_state.c index 02524dd9a..7a478a2ec 100644 --- a/src/server_state.c +++ b/src/server_state.c @@ -397,16 +397,12 @@ static void srv_state_srv_update(struct server *srv, int version, char **params) char *tmp; /* we can't apply previous state if SRV record has changed */ - if (srv->srvrq && strcmp(srv->srvrq->name, srvrecord) != 0) { - chunk_appendf(msg, ", SRV record mismatch between configuration ('%s') and state file ('%s) for server '%s'. Previous state not applied", srv->srvrq->name, srvrecord, srv->id); + if (!srv->srvrq) { + chunk_appendf(msg, ", no SRV resolution for server '%s'. Previous state not applied", srv->id); goto out; } - - /* create or find a SRV resolution for this srv record */ - if (srv->srvrq == NULL && (srv->srvrq = find_srvrq_by_name(srvrecord, srv->proxy)) == NULL) - srv->srvrq = new_resolv_srvrq(srv, srvrecord); - if (srv->srvrq == NULL) { - chunk_appendf(msg, ", can't create or find SRV resolution '%s' for server '%s'", srvrecord, srv->id); + if (strcmp(srv->srvrq->name, srvrecord) != 0) { + chunk_appendf(msg, ", SRV record mismatch between configuration ('%s') and state file ('%s) for server '%s'. Previous state not applied", srv->srvrq->name, srvrecord, srv->id); goto out; }