MINOR: resolvers: renames some resolvers specific types to not use dns prefix

This patch applies those changes on names:

-struct dns_resolution {
+struct resolv_resolution {

-struct dns_requester {
+struct resolv_requester {

-struct dns_srvrq {
+struct resolv_srvrq {

@@ -185,12 +185,12 @@ struct stream {

        struct {
-               struct dns_requester *dns_requester;
+               struct resolv_requester *requester;
...
-       } dns_ctx;
+       } resolv_ctx;
This commit is contained in:
Emeric Brun 2020-12-23 17:41:43 +01:00 committed by Willy Tarreau
parent 750fe79cd0
commit 08622d3c0a
12 changed files with 147 additions and 147 deletions

View File

@ -27,8 +27,8 @@
#include <haproxy/list.h> #include <haproxy/list.h>
#include <haproxy/sample.h> #include <haproxy/sample.h>
int act_resolution_cb(struct dns_requester *requester, struct dns_counters *counters); int act_resolution_cb(struct resolv_requester *requester, struct dns_counters *counters);
int act_resolution_error_cb(struct dns_requester *requester, int error_code); int act_resolution_error_cb(struct resolv_requester *requester, int error_code);
static inline struct action_kw *action_lookup(struct list *keywords, const char *kw) static inline struct action_kw *action_lookup(struct list *keywords, const char *kw)
{ {

View File

@ -31,7 +31,7 @@
#include <haproxy/task-t.h> #include <haproxy/task-t.h>
#include <haproxy/thread.h> #include <haproxy/thread.h>
extern struct pool_head *dns_requester_pool; extern struct pool_head *resolv_requester_pool;
/*DNS maximum values */ /*DNS maximum values */
/* /*
@ -260,7 +260,7 @@ struct dns_options {
* The only link between the resolution and a nameserver is through the * The only link between the resolution and a nameserver is through the
* query_id. * query_id.
*/ */
struct dns_resolution { struct resolv_resolution {
struct resolvers *resolvers; /* pointer to the resolvers structure owning the resolution */ struct resolvers *resolvers; /* pointer to the resolvers structure owning the resolution */
struct list requesters; /* list of requesters using this resolution */ struct list requesters; /* list of requesters using this resolution */
int uuid; /* unique id (used for debugging purpose) */ int uuid; /* unique id (used for debugging purpose) */
@ -286,12 +286,12 @@ struct dns_resolution {
}; };
/* Structure used to describe the owner of a DNS resolution. */ /* Structure used to describe the owner of a DNS resolution. */
struct dns_requester { struct resolv_requester {
enum obj_type *owner; /* pointer to the owner (server or dns_srvrq) */ enum obj_type *owner; /* pointer to the owner (server or dns_srvrq) */
struct dns_resolution *resolution; /* pointer to the owned DNS resolution */ struct resolv_resolution *resolution; /* pointer to the owned DNS resolution */
int (*requester_cb)(struct dns_requester *, struct dns_counters *); /* requester callback for valid response */ int (*requester_cb)(struct resolv_requester *, struct dns_counters *); /* requester callback for valid response */
int (*requester_error_cb)(struct dns_requester *, int); /* requester callback, for error management */ int (*requester_error_cb)(struct resolv_requester *, int); /* requester callback, for error management */
struct list list; /* requester list */ struct list list; /* requester list */
}; };
@ -348,14 +348,14 @@ enum {
}; };
struct proxy; struct proxy;
struct dns_srvrq { struct resolv_srvrq {
enum obj_type obj_type; /* object type == OBJ_TYPE_SRVRQ */ enum obj_type obj_type; /* object type == OBJ_TYPE_SRVRQ */
struct resolvers *resolvers; /* pointer to the resolvers structure used for this server template */ struct resolvers *resolvers; /* pointer to the resolvers structure used for this server template */
struct proxy *proxy; /* associated proxy */ struct proxy *proxy; /* associated proxy */
char *name; char *name;
char *hostname_dn; /* server hostname in Domain Name format */ char *hostname_dn; /* server hostname in Domain Name format */
int hostname_dn_len; /* string length of the server hostname in Domain Name format */ int hostname_dn_len; /* string length of the server hostname in Domain Name format */
struct dns_requester *dns_requester; /* used to link to its DNS resolution */ struct resolv_requester *requester; /* used to link to its DNS resolution */
struct list list; /* Next SRV RQ for the same proxy */ struct list list; /* Next SRV RQ for the same proxy */
}; };

View File

@ -29,8 +29,8 @@ extern struct list sec_resolvers;
extern unsigned int dns_failed_resolutions; extern unsigned int dns_failed_resolutions;
struct resolvers *find_resolvers_by_id(const char *id); struct resolvers *find_resolvers_by_id(const char *id);
struct dns_srvrq *find_srvrq_by_name(const char *name, struct proxy *px); struct resolv_srvrq *find_srvrq_by_name(const char *name, struct proxy *px);
struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn); struct resolv_srvrq *new_resolv_srvrq(struct server *srv, char *fqdn);
int dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len); int dns_str_to_dn_label(const char *str, int str_len, char *dn, int dn_len);
int dns_dn_label_to_str(const char *dn, int dn_len, char *str, int str_len); int dns_dn_label_to_str(const char *dn, int dn_len, char *str, int str_len);
@ -43,8 +43,8 @@ int dns_get_ip_from_response(struct resolv_response *r_res,
void *owner); void *owner);
int dns_link_resolution(void *requester, int requester_type, int requester_locked); int dns_link_resolution(void *requester, int requester_type, int requester_locked);
void dns_unlink_resolution(struct dns_requester *requester); void dns_unlink_resolution(struct resolv_requester *requester);
void dns_trigger_resolution(struct dns_requester *requester); void dns_trigger_resolution(struct resolv_requester *requester);
enum act_parse_ret dns_parse_do_resolve(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err); enum act_parse_ret dns_parse_do_resolve(const char **args, int *orig_arg, struct proxy *px, struct act_rule *rule, char **err);
int check_action_do_resolve(struct act_rule *rule, struct proxy *px, char **err); int check_action_do_resolve(struct act_rule *rule, struct proxy *px, char **err);

View File

@ -150,16 +150,16 @@ static inline struct connection *objt_conn(enum obj_type *t)
return __objt_conn(t); return __objt_conn(t);
} }
static inline struct dns_srvrq *__objt_dns_srvrq(enum obj_type *t) static inline struct resolv_srvrq *__objt_resolv_srvrq(enum obj_type *t)
{ {
return container_of(t, struct dns_srvrq, obj_type); return container_of(t, struct resolv_srvrq, obj_type);
} }
static inline struct dns_srvrq *objt_dns_srvrq(enum obj_type *t) static inline struct resolv_srvrq *objt_resolv_srvrq(enum obj_type *t)
{ {
if (!t || *t != OBJ_TYPE_SRVRQ) if (!t || *t != OBJ_TYPE_SRVRQ)
return NULL; return NULL;
return __objt_dns_srvrq(t); return __objt_resolv_srvrq(t);
} }
static inline struct stream *__objt_stream(enum obj_type *t) static inline struct stream *__objt_stream(enum obj_type *t)
@ -196,7 +196,7 @@ static inline void *obj_base_ptr(enum obj_type *t)
case OBJ_TYPE_APPLET: return __objt_applet(t); case OBJ_TYPE_APPLET: return __objt_applet(t);
case OBJ_TYPE_APPCTX: return __objt_appctx(t); case OBJ_TYPE_APPCTX: return __objt_appctx(t);
case OBJ_TYPE_CONN: return __objt_conn(t); case OBJ_TYPE_CONN: return __objt_conn(t);
case OBJ_TYPE_SRVRQ: return __objt_dns_srvrq(t); case OBJ_TYPE_SRVRQ: return __objt_resolv_srvrq(t);
case OBJ_TYPE_CS: return __objt_cs(t); case OBJ_TYPE_CS: return __objt_cs(t);
case OBJ_TYPE_STREAM: return __objt_stream(t); case OBJ_TYPE_STREAM: return __objt_stream(t);
case OBJ_TYPE_CHECK: return __objt_check(t); case OBJ_TYPE_CHECK: return __objt_check(t);

View File

@ -292,7 +292,7 @@ struct server {
struct check check; /* health-check specific configuration */ struct check check; /* health-check specific configuration */
struct check agent; /* agent specific configuration */ struct check agent; /* agent specific configuration */
struct dns_requester *dns_requester; /* used to link a server to its DNS resolution */ struct resolv_requester *resolv_requester; /* used to link a server to its DNS resolution */
char *resolvers_id; /* resolvers section used by this server */ char *resolvers_id; /* resolvers section used by this server */
struct resolvers *resolvers; /* pointer to the resolvers structure used by this server */ struct resolvers *resolvers; /* pointer to the resolvers structure used by this server */
char *lastaddr; /* the address string provided by the server-state file */ char *lastaddr; /* the address string provided by the server-state file */
@ -342,7 +342,7 @@ struct server {
struct eb_root cids; /* QUIC connections IDs. */ struct eb_root cids; /* QUIC connections IDs. */
#endif #endif
#endif #endif
struct dns_srvrq *srvrq; /* Pointer representing the DNS SRV requeest, if any */ struct resolv_srvrq *srvrq; /* Pointer representing the DNS SRV requeest, if any */
struct { struct {
const char *file; /* file where the section appears */ const char *file; /* file where the section appears */
struct eb32_node id; /* place in the tree of used IDs */ struct eb32_node id; /* place in the tree of used IDs */

View File

@ -60,8 +60,8 @@ struct server *new_server(struct proxy *proxy);
/* functions related to server name resolution */ /* functions related to server name resolution */
int snr_update_srv_status(struct server *s, int has_no_ip); int snr_update_srv_status(struct server *s, int has_no_ip);
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int dns_locked); const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int dns_locked);
int snr_resolution_cb(struct dns_requester *requester, struct dns_counters *counters); int snr_resolution_cb(struct resolv_requester *requester, struct dns_counters *counters);
int snr_resolution_error_cb(struct dns_requester *requester, int error_code); int snr_resolution_error_cb(struct resolv_requester *requester, int error_code);
struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char *ip_family); struct server *snr_check_ip_callback(struct server *srv, void *ip, unsigned char *ip_family);
struct task *srv_cleanup_idle_connections(struct task *task, void *ctx, unsigned short state); struct task *srv_cleanup_idle_connections(struct task *task, void *ctx, unsigned short state);
struct task *srv_cleanup_toremove_connections(struct task *task, void *context, unsigned short state); struct task *srv_cleanup_toremove_connections(struct task *task, void *context, unsigned short state);

View File

@ -185,12 +185,12 @@ struct stream {
/* Context */ /* Context */
struct { struct {
struct dns_requester *dns_requester; /* owner of the resolution */ struct resolv_requester *requester; /* owner of the resolution */
char *hostname_dn; /* hostname being resolve, in domain name format */ char *hostname_dn; /* hostname being resolve, in domain name format */
int hostname_dn_len; /* size of hostname_dn */ int hostname_dn_len; /* size of hostname_dn */
/* 4 unused bytes here */ /* 4 unused bytes here */
struct act_rule *parent; /* rule which requested this resolution */ struct act_rule *parent; /* rule which requested this resolution */
} dns_ctx; /* context information for DNS resolution */ } resolv_ctx; /* context information for DNS resolution */
int tunnel_timeout; int tunnel_timeout;
}; };

View File

@ -117,7 +117,7 @@ int check_capture(struct act_rule *rule, struct proxy *px, char **err)
return 1; return 1;
} }
int act_resolution_cb(struct dns_requester *requester, struct dns_counters *counters) int act_resolution_cb(struct resolv_requester *requester, struct dns_counters *counters)
{ {
struct stream *stream; struct stream *stream;
@ -133,7 +133,7 @@ int act_resolution_cb(struct dns_requester *requester, struct dns_counters *coun
return 0; return 0;
} }
int act_resolution_error_cb(struct dns_requester *requester, int error_code) int act_resolution_error_cb(struct resolv_requester *requester, int error_code)
{ {
struct stream *stream; struct stream *stream;

View File

@ -680,7 +680,7 @@ void chk_report_conn_err(struct check *check, int errno_bck, int expired)
* Let's trigger a DNS resolution if none are currently running. * Let's trigger a DNS resolution if none are currently running.
*/ */
if (check->server) if (check->server)
dns_trigger_resolution(check->server->dns_requester); dns_trigger_resolution(check->server->resolv_requester);
} }
else if (conn->flags & CO_FL_WAIT_L6_CONN) { else if (conn->flags & CO_FL_WAIT_L6_CONN) {

180
src/dns.c
View File

@ -46,13 +46,13 @@
struct list sec_resolvers = LIST_HEAD_INIT(sec_resolvers); struct list sec_resolvers = LIST_HEAD_INIT(sec_resolvers);
struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list); struct list resolv_srvrq_list = LIST_HEAD_INIT(resolv_srvrq_list);
static THREAD_LOCAL uint64_t dns_query_id_seed = 0; /* random seed */ static THREAD_LOCAL uint64_t dns_query_id_seed = 0; /* random seed */
DECLARE_STATIC_POOL(resolv_answer_item_pool, "resolv_answer_item", sizeof(struct resolv_answer_item)); DECLARE_STATIC_POOL(resolv_answer_item_pool, "resolv_answer_item", sizeof(struct resolv_answer_item));
DECLARE_STATIC_POOL(dns_resolution_pool, "dns_resolution", sizeof(struct dns_resolution)); DECLARE_STATIC_POOL(resolv_resolution_pool, "resolv_resolution", sizeof(struct resolv_resolution));
DECLARE_POOL(dns_requester_pool, "dns_requester", sizeof(struct dns_requester)); DECLARE_POOL(resolv_requester_pool, "resolv_requester", sizeof(struct resolv_requester));
static unsigned int resolution_uuid = 1; static unsigned int resolution_uuid = 1;
unsigned int dns_failed_resolutions = 0; unsigned int dns_failed_resolutions = 0;
@ -165,11 +165,11 @@ static __inline int dns_hostname_cmp(const char *name1, const char *name2, int l
/* Returns a pointer on the SRV request matching the name <name> for the proxy /* Returns a pointer on the SRV request matching the name <name> for the proxy
* <px>. NULL is returned if no match is found. * <px>. NULL is returned if no match is found.
*/ */
struct dns_srvrq *find_srvrq_by_name(const char *name, struct proxy *px) struct resolv_srvrq *find_srvrq_by_name(const char *name, struct proxy *px)
{ {
struct dns_srvrq *srvrq; struct resolv_srvrq *srvrq;
list_for_each_entry(srvrq, &dns_srvrq_list, list) { list_for_each_entry(srvrq, &resolv_srvrq_list, list) {
if (srvrq->proxy == px && strcmp(srvrq->name, name) == 0) if (srvrq->proxy == px && strcmp(srvrq->name, name) == 0)
return srvrq; return srvrq;
} }
@ -178,10 +178,10 @@ struct dns_srvrq *find_srvrq_by_name(const char *name, struct proxy *px)
/* Allocates a new SRVRQ for the given server with the name <fqdn>. It returns /* Allocates a new SRVRQ for the given server with the name <fqdn>. It returns
* NULL if an error occurred. */ * NULL if an error occurred. */
struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn) struct resolv_srvrq *new_resolv_srvrq(struct server *srv, char *fqdn)
{ {
struct proxy *px = srv->proxy; struct proxy *px = srv->proxy;
struct dns_srvrq *srvrq = NULL; struct resolv_srvrq *srvrq = NULL;
int fqdn_len, hostname_dn_len; int fqdn_len, hostname_dn_len;
fqdn_len = strlen(fqdn); fqdn_len = strlen(fqdn);
@ -208,7 +208,7 @@ struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn)
proxy_type_str(px), px->id, srv->id); proxy_type_str(px), px->id, srv->id);
goto err; goto err;
} }
LIST_ADDQ(&dns_srvrq_list, &srvrq->list); LIST_ADDQ(&resolv_srvrq_list, &srvrq->list);
return srvrq; return srvrq;
err: err:
@ -233,7 +233,7 @@ static inline uint16_t dns_rnd16(void)
} }
static inline int dns_resolution_timeout(struct dns_resolution *res) static inline int dns_resolution_timeout(struct resolv_resolution *res)
{ {
return res->resolvers->timeout.resolve; return res->resolvers->timeout.resolve;
} }
@ -241,12 +241,12 @@ static inline int dns_resolution_timeout(struct dns_resolution *res)
/* Updates a resolvers' task timeout for next wake up and queue it */ /* Updates a resolvers' task timeout for next wake up and queue it */
static void dns_update_resolvers_timeout(struct resolvers *resolvers) static void dns_update_resolvers_timeout(struct resolvers *resolvers)
{ {
struct dns_resolution *res; struct resolv_resolution *res;
int next; int next;
next = tick_add(now_ms, resolvers->timeout.resolve); next = tick_add(now_ms, resolvers->timeout.resolve);
if (!LIST_ISEMPTY(&resolvers->resolutions.curr)) { if (!LIST_ISEMPTY(&resolvers->resolutions.curr)) {
res = LIST_NEXT(&resolvers->resolutions.curr, struct dns_resolution *, list); res = LIST_NEXT(&resolvers->resolutions.curr, struct resolv_resolution *, list);
next = MIN(next, tick_add(res->last_query, resolvers->timeout.retry)); next = MIN(next, tick_add(res->last_query, resolvers->timeout.retry));
} }
@ -353,7 +353,7 @@ static int dns_build_query(int query_id, int query_type, unsigned int accepted_p
/* Sends a DNS query to resolvers associated to a resolution. It returns 0 on /* Sends a DNS query to resolvers associated to a resolution. It returns 0 on
* success, -1 otherwise. * success, -1 otherwise.
*/ */
static int dns_send_query(struct dns_resolution *resolution) static int dns_send_query(struct resolv_resolution *resolution)
{ {
struct resolvers *resolvers = resolution->resolvers; struct resolvers *resolvers = resolution->resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
@ -411,7 +411,7 @@ static int dns_send_query(struct dns_resolution *resolution)
* skipped and -1 if an error occurred. * skipped and -1 if an error occurred.
*/ */
static int static int
dns_run_resolution(struct dns_resolution *resolution) dns_run_resolution(struct resolv_resolution *resolution)
{ {
struct resolvers *resolvers = resolution->resolvers; struct resolvers *resolvers = resolution->resolvers;
int query_id, i; int query_id, i;
@ -457,10 +457,10 @@ dns_run_resolution(struct dns_resolution *resolution)
} }
/* Performs a name resolution for the requester <req> */ /* Performs a name resolution for the requester <req> */
void dns_trigger_resolution(struct dns_requester *req) void dns_trigger_resolution(struct resolv_requester *req)
{ {
struct resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct resolv_resolution *res;
int exp; int exp;
if (!req || !req->resolution) if (!req || !req->resolution)
@ -480,7 +480,7 @@ void dns_trigger_resolution(struct dns_requester *req)
/* Resets some resolution parameters to initial values and also delete the query /* Resets some resolution parameters to initial values and also delete the query
* ID from the resolver's tree. * ID from the resolver's tree.
*/ */
static void dns_reset_resolution(struct dns_resolution *resolution) static void dns_reset_resolution(struct resolv_resolution *resolution)
{ {
/* update resolution status */ /* update resolution status */
resolution->step = RSLV_STEP_NONE; resolution->step = RSLV_STEP_NONE;
@ -593,13 +593,13 @@ int dns_read_name(unsigned char *buffer, unsigned char *bufend,
/* Checks for any obsolete record, also identify any SRV request, and try to /* Checks for any obsolete record, also identify any SRV request, and try to
* find a corresponding server. * find a corresponding server.
*/ */
static void dns_check_dns_response(struct dns_resolution *res) static void dns_check_dns_response(struct resolv_resolution *res)
{ {
struct resolvers *resolvers = res->resolvers; struct resolvers *resolvers = res->resolvers;
struct dns_requester *req, *reqback; struct resolv_requester *req, *reqback;
struct resolv_answer_item *item, *itemback; struct resolv_answer_item *item, *itemback;
struct server *srv; struct server *srv;
struct dns_srvrq *srvrq; struct resolv_srvrq *srvrq;
list_for_each_entry_safe(item, itemback, &res->response.answer_list, list) { list_for_each_entry_safe(item, itemback, &res->response.answer_list, list) {
struct resolv_answer_item *ar_item = item->ar_item; struct resolv_answer_item *ar_item = item->ar_item;
@ -616,7 +616,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
goto rm_obselete_item; goto rm_obselete_item;
list_for_each_entry_safe(req, reqback, &res->requesters, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) {
if ((srvrq = objt_dns_srvrq(req->owner)) == NULL) if ((srvrq = objt_resolv_srvrq(req->owner)) == NULL)
continue; continue;
/* Remove any associated server */ /* Remove any associated server */
@ -631,7 +631,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
srv->hostname = NULL; srv->hostname = NULL;
srv->hostname_dn = NULL; srv->hostname_dn = NULL;
srv->hostname_dn_len = 0; srv->hostname_dn_len = 0;
dns_unlink_resolution(srv->dns_requester); dns_unlink_resolution(srv->resolv_requester);
} }
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
} }
@ -652,7 +652,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
/* Now process SRV records */ /* Now process SRV records */
list_for_each_entry_safe(req, reqback, &res->requesters, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) {
if ((srvrq = objt_dns_srvrq(req->owner)) == NULL) if ((srvrq = objt_resolv_srvrq(req->owner)) == NULL)
continue; continue;
/* Check if a server already uses that hostname */ /* Check if a server already uses that hostname */
@ -749,7 +749,7 @@ static void dns_check_dns_response(struct dns_resolution *res)
* error found. * error found.
*/ */
static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend, static int dns_validate_dns_response(unsigned char *resp, unsigned char *bufend,
struct dns_resolution *resolution, int max_answer_records) struct resolv_resolution *resolution, int max_answer_records)
{ {
unsigned char *reader; unsigned char *reader;
char *previous_dname, tmpname[DNS_MAX_NAME_SIZE]; char *previous_dname, tmpname[DNS_MAX_NAME_SIZE];
@ -1623,11 +1623,11 @@ int dns_hostname_validation(const char *string, char **err)
* *
* Returns an available resolution, NULL if none found. * Returns an available resolution, NULL if none found.
*/ */
static struct dns_resolution *dns_pick_resolution(struct resolvers *resolvers, static struct resolv_resolution *dns_pick_resolution(struct resolvers *resolvers,
char **hostname_dn, int hostname_dn_len, char **hostname_dn, int hostname_dn_len,
int query_type) int query_type)
{ {
struct dns_resolution *res; struct resolv_resolution *res;
if (!*hostname_dn) if (!*hostname_dn)
goto from_pool; goto from_pool;
@ -1654,7 +1654,7 @@ static struct dns_resolution *dns_pick_resolution(struct resolvers *resolvers,
from_pool: from_pool:
/* No resolution could be found, so let's allocate a new one */ /* No resolution could be found, so let's allocate a new one */
res = pool_alloc(dns_resolution_pool); res = pool_alloc(resolv_resolution_pool);
if (res) { if (res) {
memset(res, 0, sizeof(*res)); memset(res, 0, sizeof(*res));
res->resolvers = resolvers; res->resolvers = resolvers;
@ -1680,9 +1680,9 @@ static struct dns_resolution *dns_pick_resolution(struct resolvers *resolvers,
} }
/* Releases a resolution from its requester(s) and move it back to the pool */ /* Releases a resolution from its requester(s) and move it back to the pool */
static void dns_free_resolution(struct dns_resolution *resolution) static void dns_free_resolution(struct resolv_resolution *resolution)
{ {
struct dns_requester *req, *reqback; struct resolv_requester *req, *reqback;
struct resolv_answer_item *item, *itemback; struct resolv_answer_item *item, *itemback;
/* clean up configuration */ /* clean up configuration */
@ -1705,19 +1705,19 @@ static void dns_free_resolution(struct dns_resolution *resolution)
} }
LIST_DEL(&resolution->list); LIST_DEL(&resolution->list);
pool_free(dns_resolution_pool, resolution); pool_free(resolv_resolution_pool, resolution);
} }
/* Links a requester (a server or a dns_srvrq) with a resolution. It returns 0 /* Links a requester (a server or a resolv_srvrq) with a resolution. It returns 0
* on success, -1 otherwise. * on success, -1 otherwise.
*/ */
int dns_link_resolution(void *requester, int requester_type, int requester_locked) int dns_link_resolution(void *requester, int requester_type, int requester_locked)
{ {
struct dns_resolution *res = NULL; struct resolv_resolution *res = NULL;
struct dns_requester *req; struct resolv_requester *req;
struct resolvers *resolvers; struct resolvers *resolvers;
struct server *srv = NULL; struct server *srv = NULL;
struct dns_srvrq *srvrq = NULL; struct resolv_srvrq *srvrq = NULL;
struct stream *stream = NULL; struct stream *stream = NULL;
char **hostname_dn; char **hostname_dn;
int hostname_dn_len, query_type; int hostname_dn_len, query_type;
@ -1734,7 +1734,7 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
break; break;
case OBJ_TYPE_SRVRQ: case OBJ_TYPE_SRVRQ:
srvrq = (struct dns_srvrq *)requester; srvrq = (struct resolv_srvrq *)requester;
hostname_dn = &srvrq->hostname_dn; hostname_dn = &srvrq->hostname_dn;
hostname_dn_len = srvrq->hostname_dn_len; hostname_dn_len = srvrq->hostname_dn_len;
resolvers = srvrq->resolvers; resolvers = srvrq->resolvers;
@ -1743,10 +1743,10 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
case OBJ_TYPE_STREAM: case OBJ_TYPE_STREAM:
stream = (struct stream *)requester; stream = (struct stream *)requester;
hostname_dn = &stream->dns_ctx.hostname_dn; hostname_dn = &stream->resolv_ctx.hostname_dn;
hostname_dn_len = stream->dns_ctx.hostname_dn_len; hostname_dn_len = stream->resolv_ctx.hostname_dn_len;
resolvers = stream->dns_ctx.parent->arg.dns.resolvers; resolvers = stream->resolv_ctx.parent->arg.dns.resolvers;
query_type = ((stream->dns_ctx.parent->arg.dns.dns_opts->family_prio == AF_INET) query_type = ((stream->resolv_ctx.parent->arg.dns.dns_opts->family_prio == AF_INET)
? DNS_RTYPE_A ? DNS_RTYPE_A
: DNS_RTYPE_AAAA); : DNS_RTYPE_AAAA);
break; break;
@ -1761,17 +1761,17 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
if (srv) { if (srv) {
if (!requester_locked) if (!requester_locked)
HA_SPIN_LOCK(SERVER_LOCK, &srv->lock); HA_SPIN_LOCK(SERVER_LOCK, &srv->lock);
if (srv->dns_requester == NULL) { if (srv->resolv_requester == NULL) {
if ((req = pool_alloc(dns_requester_pool)) == NULL) { if ((req = pool_alloc(resolv_requester_pool)) == NULL) {
if (!requester_locked) if (!requester_locked)
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
goto err; goto err;
} }
req->owner = &srv->obj_type; req->owner = &srv->obj_type;
srv->dns_requester = req; srv->resolv_requester = req;
} }
else else
req = srv->dns_requester; req = srv->resolv_requester;
if (!requester_locked) if (!requester_locked)
HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock); HA_SPIN_UNLOCK(SERVER_LOCK, &srv->lock);
@ -1779,27 +1779,27 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
req->requester_error_cb = snr_resolution_error_cb; req->requester_error_cb = snr_resolution_error_cb;
} }
else if (srvrq) { else if (srvrq) {
if (srvrq->dns_requester == NULL) { if (srvrq->requester == NULL) {
if ((req = pool_alloc(dns_requester_pool)) == NULL) if ((req = pool_alloc(resolv_requester_pool)) == NULL)
goto err; goto err;
req->owner = &srvrq->obj_type; req->owner = &srvrq->obj_type;
srvrq->dns_requester = req; srvrq->requester = req;
} }
else else
req = srvrq->dns_requester; req = srvrq->requester;
req->requester_cb = snr_resolution_cb; req->requester_cb = snr_resolution_cb;
req->requester_error_cb = snr_resolution_error_cb; req->requester_error_cb = snr_resolution_error_cb;
} }
else if (stream) { else if (stream) {
if (stream->dns_ctx.dns_requester == NULL) { if (stream->resolv_ctx.requester == NULL) {
if ((req = pool_alloc(dns_requester_pool)) == NULL) if ((req = pool_alloc(resolv_requester_pool)) == NULL)
goto err; goto err;
req->owner = &stream->obj_type; req->owner = &stream->obj_type;
stream->dns_ctx.dns_requester = req; stream->resolv_ctx.requester = req;
} }
else else
req = stream->dns_ctx.dns_requester; req = stream->resolv_ctx.requester;
req->requester_cb = act_resolution_cb; req->requester_cb = act_resolution_cb;
req->requester_error_cb = act_resolution_error_cb; req->requester_error_cb = act_resolution_error_cb;
@ -1821,10 +1821,10 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
/* Removes a requester from a DNS resolution. It takes takes care of all the /* Removes a requester from a DNS resolution. It takes takes care of all the
* consequences. It also cleans up some parameters from the requester. * consequences. It also cleans up some parameters from the requester.
*/ */
void dns_unlink_resolution(struct dns_requester *requester) void dns_unlink_resolution(struct resolv_requester *requester)
{ {
struct dns_resolution *res; struct resolv_resolution *res;
struct dns_requester *req; struct resolv_requester *req;
/* Nothing to do */ /* Nothing to do */
if (!requester || !requester->resolution) if (!requester || !requester->resolution)
@ -1837,7 +1837,7 @@ void dns_unlink_resolution(struct dns_requester *requester)
/* We need to find another requester linked on this resolution */ /* We need to find another requester linked on this resolution */
if (!LIST_ISEMPTY(&res->requesters)) if (!LIST_ISEMPTY(&res->requesters))
req = LIST_NEXT(&res->requesters, struct dns_requester *, list); req = LIST_NEXT(&res->requesters, struct resolv_requester *, list);
else { else {
dns_free_resolution(res); dns_free_resolution(res);
return; return;
@ -1850,12 +1850,12 @@ void dns_unlink_resolution(struct dns_requester *requester)
res->hostname_dn_len = __objt_server(req->owner)->hostname_dn_len; res->hostname_dn_len = __objt_server(req->owner)->hostname_dn_len;
break; break;
case OBJ_TYPE_SRVRQ: case OBJ_TYPE_SRVRQ:
res->hostname_dn = __objt_dns_srvrq(req->owner)->hostname_dn; res->hostname_dn = __objt_resolv_srvrq(req->owner)->hostname_dn;
res->hostname_dn_len = __objt_dns_srvrq(req->owner)->hostname_dn_len; res->hostname_dn_len = __objt_resolv_srvrq(req->owner)->hostname_dn_len;
break; break;
case OBJ_TYPE_STREAM: case OBJ_TYPE_STREAM:
res->hostname_dn = __objt_stream(req->owner)->dns_ctx.hostname_dn; res->hostname_dn = __objt_stream(req->owner)->resolv_ctx.hostname_dn;
res->hostname_dn_len = __objt_stream(req->owner)->dns_ctx.hostname_dn_len; res->hostname_dn_len = __objt_stream(req->owner)->resolv_ctx.hostname_dn_len;
break; break;
default: default:
res->hostname_dn = NULL; res->hostname_dn = NULL;
@ -1876,7 +1876,7 @@ static void dns_resolve_recv(struct dgram_conn *dgram)
struct dns_nameserver *ns; struct dns_nameserver *ns;
struct dns_counters *tmpcounters; struct dns_counters *tmpcounters;
struct resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct resolv_resolution *res;
struct resolv_query_item *query; struct resolv_query_item *query;
unsigned char buf[DNS_MAX_UDP_MESSAGE + 1]; unsigned char buf[DNS_MAX_UDP_MESSAGE + 1];
unsigned char *bufend; unsigned char *bufend;
@ -1884,7 +1884,7 @@ static void dns_resolve_recv(struct dgram_conn *dgram)
int max_answer_records; int max_answer_records;
unsigned short query_id; unsigned short query_id;
struct eb32_node *eb; struct eb32_node *eb;
struct dns_requester *req; struct resolv_requester *req;
fd = dgram->t.sock.fd; fd = dgram->t.sock.fd;
@ -1941,7 +1941,7 @@ static void dns_resolve_recv(struct dgram_conn *dgram)
} }
/* known query id means a resolution in progress */ /* known query id means a resolution in progress */
res = eb32_entry(eb, struct dns_resolution, qid); res = eb32_entry(eb, struct resolv_resolution, qid);
/* number of responses received */ /* number of responses received */
res->nb_responses++; res->nb_responses++;
@ -2074,7 +2074,7 @@ static void dns_resolve_send(struct dgram_conn *dgram)
{ {
struct resolvers *resolvers; struct resolvers *resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
struct dns_resolution *res; struct resolv_resolution *res;
int fd; int fd;
fd = dgram->t.sock.fd; fd = dgram->t.sock.fd;
@ -2135,7 +2135,7 @@ static void dns_resolve_send(struct dgram_conn *dgram)
static struct task *dns_process_resolvers(struct task *t, void *context, unsigned short state) static struct task *dns_process_resolvers(struct task *t, void *context, unsigned short state)
{ {
struct resolvers *resolvers = context; struct resolvers *resolvers = context;
struct dns_resolution *res, *resback; struct resolv_resolution *res, *resback;
int exp; int exp;
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
@ -2152,7 +2152,7 @@ static struct task *dns_process_resolvers(struct task *t, void *context, unsigne
* finishes in timeout we update its status and remove it from * finishes in timeout we update its status and remove it from
* the list */ * the list */
if (!res->try) { if (!res->try) {
struct dns_requester *req; struct resolv_requester *req;
/* Notify the result to the requesters */ /* Notify the result to the requesters */
if (!res->nb_responses) if (!res->nb_responses)
@ -2217,9 +2217,9 @@ static void dns_deinit(void)
{ {
struct resolvers *resolvers, *resolversback; struct resolvers *resolvers, *resolversback;
struct dns_nameserver *ns, *nsback; struct dns_nameserver *ns, *nsback;
struct dns_resolution *res, *resback; struct resolv_resolution *res, *resback;
struct dns_requester *req, *reqback; struct resolv_requester *req, *reqback;
struct dns_srvrq *srvrq, *srvrqback; struct resolv_srvrq *srvrq, *srvrqback;
list_for_each_entry_safe(resolvers, resolversback, &sec_resolvers, list) { list_for_each_entry_safe(resolvers, resolversback, &sec_resolvers, list) {
list_for_each_entry_safe(ns, nsback, &resolvers->nameservers, list) { list_for_each_entry_safe(ns, nsback, &resolvers->nameservers, list) {
@ -2236,7 +2236,7 @@ static void dns_deinit(void)
list_for_each_entry_safe(res, resback, &resolvers->resolutions.curr, list) { list_for_each_entry_safe(res, resback, &resolvers->resolutions.curr, list) {
list_for_each_entry_safe(req, reqback, &res->requesters, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) {
LIST_DEL(&req->list); LIST_DEL(&req->list);
pool_free(dns_requester_pool, req); pool_free(resolv_requester_pool, req);
} }
dns_free_resolution(res); dns_free_resolution(res);
} }
@ -2244,7 +2244,7 @@ static void dns_deinit(void)
list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) { list_for_each_entry_safe(res, resback, &resolvers->resolutions.wait, list) {
list_for_each_entry_safe(req, reqback, &res->requesters, list) { list_for_each_entry_safe(req, reqback, &res->requesters, list) {
LIST_DEL(&req->list); LIST_DEL(&req->list);
pool_free(dns_requester_pool, req); pool_free(resolv_requester_pool, req);
} }
dns_free_resolution(res); dns_free_resolution(res);
} }
@ -2256,7 +2256,7 @@ static void dns_deinit(void)
free(resolvers); free(resolvers);
} }
list_for_each_entry_safe(srvrq, srvrqback, &dns_srvrq_list, list) { list_for_each_entry_safe(srvrq, srvrqback, &resolv_srvrq_list, list) {
free(srvrq->name); free(srvrq->name);
free(srvrq->hostname_dn); free(srvrq->hostname_dn);
LIST_DEL(&srvrq->list); LIST_DEL(&srvrq->list);
@ -2639,15 +2639,15 @@ static int action_prepare_for_resolution(struct stream *stream, const char *host
goto err; goto err;
stream->dns_ctx.hostname_dn = strdup(hostname_dn); stream->resolv_ctx.hostname_dn = strdup(hostname_dn);
stream->dns_ctx.hostname_dn_len = hostname_dn_len; stream->resolv_ctx.hostname_dn_len = hostname_dn_len;
if (!stream->dns_ctx.hostname_dn) if (!stream->resolv_ctx.hostname_dn)
goto err; goto err;
return 0; return 0;
err: err:
free(stream->dns_ctx.hostname_dn); stream->dns_ctx.hostname_dn = NULL; free(stream->resolv_ctx.hostname_dn); stream->resolv_ctx.hostname_dn = NULL;
dns_failed_resolutions += 1; dns_failed_resolutions += 1;
return -1; return -1;
} }
@ -2659,12 +2659,12 @@ static int action_prepare_for_resolution(struct stream *stream, const char *host
enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px, enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
struct session *sess, struct stream *s, int flags) struct session *sess, struct stream *s, int flags)
{ {
struct dns_resolution *resolution; struct resolv_resolution *resolution;
struct sample *smp; struct sample *smp;
char *fqdn; char *fqdn;
struct dns_requester *req; struct resolv_requester *req;
struct resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct resolv_resolution *res;
int exp, locked = 0; int exp, locked = 0;
enum act_return ret = ACT_RET_CONT; enum act_return ret = ACT_RET_CONT;
@ -2672,8 +2672,8 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
/* we have a response to our DNS resolution */ /* we have a response to our DNS resolution */
use_cache: use_cache:
if (s->dns_ctx.dns_requester && s->dns_ctx.dns_requester->resolution != NULL) { if (s->resolv_ctx.requester && s->resolv_ctx.requester->resolution != NULL) {
resolution = s->dns_ctx.dns_requester->resolution; resolution = s->resolv_ctx.requester->resolution;
if (!locked) { if (!locked) {
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
locked = 1; locked = 1;
@ -2726,7 +2726,7 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
if (action_prepare_for_resolution(s, fqdn) == -1) if (action_prepare_for_resolution(s, fqdn) == -1)
goto end; /* on error, ignore the action */ goto end; /* on error, ignore the action */
s->dns_ctx.parent = rule; s->resolv_ctx.parent = rule;
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
locked = 1; locked = 1;
@ -2734,7 +2734,7 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
dns_link_resolution(s, OBJ_TYPE_STREAM, 0); dns_link_resolution(s, OBJ_TYPE_STREAM, 0);
/* Check if there is a fresh enough response in the cache of our associated resolution */ /* Check if there is a fresh enough response in the cache of our associated resolution */
req = s->dns_ctx.dns_requester; req = s->resolv_ctx.requester;
if (!req || !req->resolution) if (!req || !req->resolution)
goto release_requester; /* on error, ignore the action */ goto release_requester; /* on error, ignore the action */
res = req->resolution; res = req->resolution;
@ -2745,7 +2745,7 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
goto use_cache; goto use_cache;
} }
dns_trigger_resolution(s->dns_ctx.dns_requester); dns_trigger_resolution(s->resolv_ctx.requester);
yield: yield:
if (flags & ACT_OPT_FINAL) if (flags & ACT_OPT_FINAL)
@ -2758,13 +2758,13 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
return ret; return ret;
release_requester: release_requester:
free(s->dns_ctx.hostname_dn); free(s->resolv_ctx.hostname_dn);
s->dns_ctx.hostname_dn = NULL; s->resolv_ctx.hostname_dn = NULL;
s->dns_ctx.hostname_dn_len = 0; s->resolv_ctx.hostname_dn_len = 0;
if (s->dns_ctx.dns_requester) { if (s->resolv_ctx.requester) {
dns_unlink_resolution(s->dns_ctx.dns_requester); dns_unlink_resolution(s->resolv_ctx.requester);
pool_free(dns_requester_pool, s->dns_ctx.dns_requester); pool_free(resolv_requester_pool, s->resolv_ctx.requester);
s->dns_ctx.dns_requester = NULL; s->resolv_ctx.requester = NULL;
} }
goto end; goto end;
} }

View File

@ -50,7 +50,7 @@
static void srv_update_status(struct server *s); static void srv_update_status(struct server *s);
static void srv_update_state(struct server *srv, int version, char **params); static void srv_update_state(struct server *srv, int version, char **params);
static int srv_apply_lastaddr(struct server *srv, int *err_code); static int srv_apply_lastaddr(struct server *srv, int *err_code);
static int srv_set_fqdn(struct server *srv, const char *fqdn, int dns_locked); static int srv_set_fqdn(struct server *srv, const char *fqdn, int resolv_locked);
static void srv_state_parse_line(char *buf, const int version, char **params, char **srv_params); static void srv_state_parse_line(char *buf, const int version, char **params, char **srv_params);
static int srv_state_get_version(FILE *f); static int srv_state_get_version(FILE *f);
static void srv_cleanup_connections(struct server *srv); static void srv_cleanup_connections(struct server *srv);
@ -2076,7 +2076,7 @@ int parse_server(const char *file, int linenum, char **args, struct proxy *curpr
if (fqdn[0] == '_') { /* SRV record */ if (fqdn[0] == '_') { /* SRV record */
/* Check if a SRV request already exists, and if not, create it */ /* Check if a SRV request already exists, and if not, create it */
if ((newsrv->srvrq = find_srvrq_by_name(fqdn, curproxy)) == NULL) if ((newsrv->srvrq = find_srvrq_by_name(fqdn, curproxy)) == NULL)
newsrv->srvrq = new_dns_srvrq(newsrv, fqdn); newsrv->srvrq = new_resolv_srvrq(newsrv, fqdn);
if (newsrv->srvrq == NULL) { if (newsrv->srvrq == NULL) {
err_code |= ERR_ALERT | ERR_FATAL; err_code |= ERR_ALERT | ERR_FATAL;
goto out; goto out;
@ -2961,7 +2961,7 @@ static void srv_update_state(struct server *srv, int version, char **params)
/* create or find a SRV resolution for this srv record */ /* create or find a SRV resolution for this srv record */
if (srv->srvrq == NULL && (srv->srvrq = find_srvrq_by_name(srvrecord, srv->proxy)) == NULL) if (srv->srvrq == NULL && (srv->srvrq = find_srvrq_by_name(srvrecord, srv->proxy)) == NULL)
srv->srvrq = new_dns_srvrq(srv, srvrecord); srv->srvrq = new_resolv_srvrq(srv, srvrecord);
if (srv->srvrq == NULL) { if (srv->srvrq == NULL) {
chunk_appendf(msg, ", can't create or find SRV resolution '%s' for server '%s'", srvrecord, srv->id); chunk_appendf(msg, ", can't create or find SRV resolution '%s' for server '%s'", srvrecord, srv->id);
goto out; goto out;
@ -3864,7 +3864,7 @@ out:
int snr_update_srv_status(struct server *s, int has_no_ip) int snr_update_srv_status(struct server *s, int has_no_ip)
{ {
struct resolvers *resolvers = s->resolvers; struct resolvers *resolvers = s->resolvers;
struct dns_resolution *resolution = s->dns_requester->resolution; struct resolv_resolution *resolution = s->resolv_requester->resolution;
int exp; int exp;
/* If resolution is NULL we're dealing with SRV records Additional records */ /* If resolution is NULL we're dealing with SRV records Additional records */
@ -3974,10 +3974,10 @@ int snr_update_srv_status(struct server *s, int has_no_ip)
* *
* Must be called with server lock held * Must be called with server lock held
*/ */
int snr_resolution_cb(struct dns_requester *requester, struct dns_counters *counters) int snr_resolution_cb(struct resolv_requester *requester, struct dns_counters *counters)
{ {
struct server *s = NULL; struct server *s = NULL;
struct dns_resolution *resolution = NULL; struct resolv_resolution *resolution = NULL;
void *serverip, *firstip; void *serverip, *firstip;
short server_sin_family, firstip_sin_family; short server_sin_family, firstip_sin_family;
int ret; int ret;
@ -3988,7 +3988,7 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_counters *coun
if (!s) if (!s)
return 1; return 1;
resolution = s->dns_requester->resolution; resolution = s->resolv_requester->resolution;
/* initializing variables */ /* initializing variables */
firstip = NULL; /* pointer to the first valid response found */ firstip = NULL; /* pointer to the first valid response found */
@ -4073,7 +4073,7 @@ int snr_resolution_cb(struct dns_requester *requester, struct dns_counters *coun
* *
* Grabs the server's lock. * Grabs the server's lock.
*/ */
int snr_resolution_error_cb(struct dns_requester *requester, int error_code) int snr_resolution_error_cb(struct resolv_requester *requester, int error_code)
{ {
struct server *s; struct server *s;
@ -4168,9 +4168,9 @@ int srv_set_addr_via_libc(struct server *srv, int *err_code)
* *
* Must be called with the server lock held. * Must be called with the server lock held.
*/ */
int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked) int srv_set_fqdn(struct server *srv, const char *hostname, int resolv_locked)
{ {
struct dns_resolution *resolution; struct resolv_resolution *resolution;
char *hostname_dn; char *hostname_dn;
int hostname_len, hostname_dn_len; int hostname_len, hostname_dn_len;
@ -4178,12 +4178,12 @@ int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked)
if (!srv->resolvers) if (!srv->resolvers)
return -1; return -1;
if (!dns_locked) if (!resolv_locked)
HA_SPIN_LOCK(DNS_LOCK, &srv->resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &srv->resolvers->lock);
/* run time DNS resolution was not active for this server /* run time DNS resolution was not active for this server
* and we can't enable it at run time for now. * and we can't enable it at run time for now.
*/ */
if (!srv->dns_requester) if (!srv->resolv_requester)
goto err; goto err;
chunk_reset(&trash); chunk_reset(&trash);
@ -4194,13 +4194,13 @@ int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked)
if (hostname_dn_len == -1) if (hostname_dn_len == -1)
goto err; goto err;
resolution = srv->dns_requester->resolution; resolution = srv->resolv_requester->resolution;
if (resolution && if (resolution &&
resolution->hostname_dn && resolution->hostname_dn &&
strcmp(resolution->hostname_dn, hostname_dn) == 0) strcmp(resolution->hostname_dn, hostname_dn) == 0)
goto end; goto end;
dns_unlink_resolution(srv->dns_requester); dns_unlink_resolution(srv->resolv_requester);
free(srv->hostname); free(srv->hostname);
free(srv->hostname_dn); free(srv->hostname_dn);
@ -4217,12 +4217,12 @@ int srv_set_fqdn(struct server *srv, const char *hostname, int dns_locked)
goto err; goto err;
end: end:
if (!dns_locked) if (!resolv_locked)
HA_SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock); HA_SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
return 0; return 0;
err: err:
if (!dns_locked) if (!resolv_locked)
HA_SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock); HA_SPIN_UNLOCK(DNS_LOCK, &srv->resolvers->lock);
return -1; return -1;
} }
@ -4364,7 +4364,7 @@ int srv_init_addr(void)
/* /*
* Must be called with the server lock held. * Must be called with the server lock held.
*/ */
const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int dns_locked) const char *update_server_fqdn(struct server *server, const char *fqdn, const char *updater, int resolv_locked)
{ {
struct buffer *msg; struct buffer *msg;
@ -4385,7 +4385,7 @@ const char *update_server_fqdn(struct server *server, const char *fqdn, const ch
chunk_appendf(msg, "%s/%s changed its FQDN from %s to %s", chunk_appendf(msg, "%s/%s changed its FQDN from %s to %s",
server->proxy->id, server->id, server->hostname, fqdn); server->proxy->id, server->id, server->hostname, fqdn);
if (srv_set_fqdn(server, fqdn, dns_locked) < 0) { if (srv_set_fqdn(server, fqdn, resolv_locked) < 0) {
chunk_reset(msg); chunk_reset(msg);
chunk_appendf(msg, "could not update %s/%s FQDN", chunk_appendf(msg, "could not update %s/%s FQDN",
server->proxy->id, server->id); server->proxy->id, server->id);

View File

@ -532,10 +532,10 @@ struct stream *stream_new(struct session *sess, enum obj_type *origin, struct bu
s->txn = NULL; s->txn = NULL;
s->hlua = NULL; s->hlua = NULL;
s->dns_ctx.dns_requester = NULL; s->resolv_ctx.requester = NULL;
s->dns_ctx.hostname_dn = NULL; s->resolv_ctx.hostname_dn = NULL;
s->dns_ctx.hostname_dn_len = 0; s->resolv_ctx.hostname_dn_len = 0;
s->dns_ctx.parent = NULL; s->resolv_ctx.parent = NULL;
s->tunnel_timeout = TICK_ETERNITY; s->tunnel_timeout = TICK_ETERNITY;
@ -667,17 +667,17 @@ static void stream_free(struct stream *s)
s->txn = NULL; s->txn = NULL;
} }
if (s->dns_ctx.dns_requester) { if (s->resolv_ctx.requester) {
__decl_thread(struct resolvers *resolvers = s->dns_ctx.parent->arg.dns.resolvers); __decl_thread(struct resolvers *resolvers = s->resolv_ctx.parent->arg.dns.resolvers);
HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_LOCK(DNS_LOCK, &resolvers->lock);
free(s->dns_ctx.hostname_dn); s->dns_ctx.hostname_dn = NULL; free(s->resolv_ctx.hostname_dn); s->resolv_ctx.hostname_dn = NULL;
s->dns_ctx.hostname_dn_len = 0; s->resolv_ctx.hostname_dn_len = 0;
dns_unlink_resolution(s->dns_ctx.dns_requester); dns_unlink_resolution(s->resolv_ctx.requester);
HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock); HA_SPIN_UNLOCK(DNS_LOCK, &resolvers->lock);
pool_free(dns_requester_pool, s->dns_ctx.dns_requester); pool_free(resolv_requester_pool, s->resolv_ctx.requester);
s->dns_ctx.dns_requester = NULL; s->resolv_ctx.requester = NULL;
} }
flt_stream_stop(s); flt_stream_stop(s);