MINOR: resolvers: renames type dns_resolvers to resolvers.

It also renames 'dns_resolvers' head list to sec_resolvers
to avoid conflicts with local variables 'resolvers'.
This commit is contained in:
Emeric Brun 2020-12-23 16:51:12 +01:00 committed by Willy Tarreau
parent 85914e9d9b
commit 750fe79cd0
8 changed files with 48 additions and 48 deletions

View File

@ -118,7 +118,7 @@ struct act_rule {
struct sample_expr *expr; struct sample_expr *expr;
char *varname; char *varname;
char *resolvers_id; char *resolvers_id;
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_options *dns_opts; struct dns_options *dns_opts;
} dns; /* dns resolution */ } dns; /* dns resolution */
struct { struct {

View File

@ -162,7 +162,7 @@ struct resolv_response {
* servers points to it. * servers points to it.
* current resolution are stored in a FIFO list. * current resolution are stored in a FIFO list.
*/ */
struct dns_resolvers { struct resolvers {
__decl_thread(HA_SPINLOCK_T lock); __decl_thread(HA_SPINLOCK_T lock);
unsigned int accepted_payload_size; /* maximum payload size we accept for responses */ unsigned int accepted_payload_size; /* maximum payload size we accept for responses */
int nb_nameservers; /* total number of active nameservers in a resolvers section */ int nb_nameservers; /* total number of active nameservers in a resolvers section */
@ -206,7 +206,7 @@ struct dns_nameserver {
int line; /* line where the section appears */ int line; /* line where the section appears */
} conf; /* config information */ } conf; /* config information */
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dgram_conn *dgram; /* transport layer */ struct dgram_conn *dgram; /* transport layer */
struct sockaddr_storage addr; /* IP address */ struct sockaddr_storage addr; /* IP address */
@ -261,7 +261,7 @@ struct dns_options {
* query_id. * query_id.
*/ */
struct dns_resolution { struct dns_resolution {
struct dns_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) */
char *hostname_dn; /* server hostname in domain name label format */ char *hostname_dn; /* server hostname in domain name label format */
@ -350,7 +350,7 @@ enum {
struct proxy; struct proxy;
struct dns_srvrq { struct dns_srvrq {
enum obj_type obj_type; /* object type == OBJ_TYPE_SRVRQ */ enum obj_type obj_type; /* object type == OBJ_TYPE_SRVRQ */
struct dns_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 */

View File

@ -25,10 +25,10 @@
#include <haproxy/action-t.h> #include <haproxy/action-t.h>
#include <haproxy/dns-t.h> #include <haproxy/dns-t.h>
extern struct list dns_resolvers; extern struct list sec_resolvers;
extern unsigned int dns_failed_resolutions; extern unsigned int dns_failed_resolutions;
struct dns_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 dns_srvrq *find_srvrq_by_name(const char *name, struct proxy *px);
struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn); struct dns_srvrq *new_dns_srvrq(struct server *srv, char *fqdn);

View File

@ -294,7 +294,7 @@ struct server {
struct dns_requester *dns_requester; /* used to link a server to its DNS resolution */ struct dns_requester *dns_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 dns_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 */
struct dns_options dns_opts; struct dns_options dns_opts;
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 */

View File

@ -920,7 +920,7 @@ out:
*/ */
int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm) int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
{ {
static struct dns_resolvers *curr_resolvers = NULL; static struct resolvers *curr_resolvers = NULL;
const char *err; const char *err;
int err_code = 0; int err_code = 0;
char *errmsg = NULL; char *errmsg = NULL;
@ -940,7 +940,7 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
goto out; goto out;
} }
list_for_each_entry(curr_resolvers, &dns_resolvers, list) { list_for_each_entry(curr_resolvers, &sec_resolvers, list) {
/* Error if two resolvers owns the same name */ /* Error if two resolvers owns the same name */
if (strcmp(curr_resolvers->id, args[1]) == 0) { if (strcmp(curr_resolvers->id, args[1]) == 0) {
ha_alert("Parsing [%s:%d]: resolvers '%s' has same name as another resolvers (declared at %s:%d).\n", ha_alert("Parsing [%s:%d]: resolvers '%s' has same name as another resolvers (declared at %s:%d).\n",
@ -956,7 +956,7 @@ int cfg_parse_resolvers(const char *file, int linenum, char **args, int kwm)
} }
/* default values */ /* default values */
LIST_ADDQ(&dns_resolvers, &curr_resolvers->list); LIST_ADDQ(&sec_resolvers, &curr_resolvers->list);
curr_resolvers->conf.file = strdup(file); curr_resolvers->conf.file = strdup(file);
curr_resolvers->conf.line = linenum; curr_resolvers->conf.line = linenum;
curr_resolvers->id = strdup(args[1]); curr_resolvers->id = strdup(args[1]);
@ -2284,7 +2284,7 @@ int check_config_validity()
struct bind_conf *bind_conf; struct bind_conf *bind_conf;
char *err; char *err;
struct cfg_postparser *postparser; struct cfg_postparser *postparser;
struct dns_resolvers *curr_resolvers = NULL; struct resolvers *curr_resolvers = NULL;
bind_conf = NULL; bind_conf = NULL;
/* /*
@ -4101,7 +4101,7 @@ out_uri_auth_compat:
curproxy->server_state_file_name = strdup(curproxy->id); curproxy->server_state_file_name = strdup(curproxy->id);
} }
list_for_each_entry(curr_resolvers, &dns_resolvers, list) { list_for_each_entry(curr_resolvers, &sec_resolvers, list) {
if (LIST_ISEMPTY(&curr_resolvers->nameservers)) { if (LIST_ISEMPTY(&curr_resolvers->nameservers)) {
ha_warning("config : resolvers '%s' [%s:%d] has no nameservers configured!\n", ha_warning("config : resolvers '%s' [%s:%d] has no nameservers configured!\n",
curr_resolvers->id, curr_resolvers->conf.file, curr_resolvers->id, curr_resolvers->conf.file,

View File

@ -45,7 +45,7 @@
#include <haproxy/vars.h> #include <haproxy/vars.h>
struct list dns_resolvers = LIST_HEAD_INIT(dns_resolvers); struct list sec_resolvers = LIST_HEAD_INIT(sec_resolvers);
struct list dns_srvrq_list = LIST_HEAD_INIT(dns_srvrq_list); struct list dns_srvrq_list = LIST_HEAD_INIT(dns_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 */
@ -138,11 +138,11 @@ INITCALL1(STG_REGISTER, stats_register_module, &dns_stats_module);
/* Returns a pointer to the resolvers matching the id <id>. NULL is returned if /* Returns a pointer to the resolvers matching the id <id>. NULL is returned if
* no match is found. * no match is found.
*/ */
struct dns_resolvers *find_resolvers_by_id(const char *id) struct resolvers *find_resolvers_by_id(const char *id)
{ {
struct dns_resolvers *res; struct resolvers *res;
list_for_each_entry(res, &dns_resolvers, list) { list_for_each_entry(res, &sec_resolvers, list) {
if (strcmp(res->id, id) == 0) if (strcmp(res->id, id) == 0)
return res; return res;
} }
@ -239,7 +239,7 @@ 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 dns_resolvers *resolvers) static void dns_update_resolvers_timeout(struct resolvers *resolvers)
{ {
struct dns_resolution *res; struct dns_resolution *res;
int next; int next;
@ -355,7 +355,7 @@ static int dns_build_query(int query_id, int query_type, unsigned int accepted_p
*/ */
static int dns_send_query(struct dns_resolution *resolution) static int dns_send_query(struct dns_resolution *resolution)
{ {
struct dns_resolvers *resolvers = resolution->resolvers; struct resolvers *resolvers = resolution->resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
int len; int len;
@ -413,7 +413,7 @@ static int dns_send_query(struct dns_resolution *resolution)
static int static int
dns_run_resolution(struct dns_resolution *resolution) dns_run_resolution(struct dns_resolution *resolution)
{ {
struct dns_resolvers *resolvers = resolution->resolvers; struct resolvers *resolvers = resolution->resolvers;
int query_id, i; int query_id, i;
/* Avoid sending requests for resolutions that don't yet have an /* Avoid sending requests for resolutions that don't yet have an
@ -459,7 +459,7 @@ 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 dns_requester *req)
{ {
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct dns_resolution *res;
int exp; int exp;
@ -595,7 +595,7 @@ int dns_read_name(unsigned char *buffer, unsigned char *bufend,
*/ */
static void dns_check_dns_response(struct dns_resolution *res) static void dns_check_dns_response(struct dns_resolution *res)
{ {
struct dns_resolvers *resolvers = res->resolvers; struct resolvers *resolvers = res->resolvers;
struct dns_requester *req, *reqback; struct dns_requester *req, *reqback;
struct resolv_answer_item *item, *itemback; struct resolv_answer_item *item, *itemback;
struct server *srv; struct server *srv;
@ -1623,7 +1623,7 @@ 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 dns_resolvers *resolvers, static struct dns_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)
{ {
@ -1715,7 +1715,7 @@ int dns_link_resolution(void *requester, int requester_type, int requester_locke
{ {
struct dns_resolution *res = NULL; struct dns_resolution *res = NULL;
struct dns_requester *req; struct dns_requester *req;
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct server *srv = NULL; struct server *srv = NULL;
struct dns_srvrq *srvrq = NULL; struct dns_srvrq *srvrq = NULL;
struct stream *stream = NULL; struct stream *stream = NULL;
@ -1875,7 +1875,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 dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct dns_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];
@ -2072,7 +2072,7 @@ static void dns_resolve_recv(struct dgram_conn *dgram)
/* Called when a resolvers network socket is ready to send data */ /* Called when a resolvers network socket is ready to send data */
static void dns_resolve_send(struct dgram_conn *dgram) static void dns_resolve_send(struct dgram_conn *dgram)
{ {
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
struct dns_resolution *res; struct dns_resolution *res;
int fd; int fd;
@ -2134,7 +2134,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 dns_resolvers *resolvers = context; struct resolvers *resolvers = context;
struct dns_resolution *res, *resback; struct dns_resolution *res, *resback;
int exp; int exp;
@ -2215,13 +2215,13 @@ struct dgram_data_cb resolve_dgram_cb = {
/* Release memory allocated by DNS */ /* Release memory allocated by DNS */
static void dns_deinit(void) static void dns_deinit(void)
{ {
struct dns_resolvers *resolvers, *resolversback; struct resolvers *resolvers, *resolversback;
struct dns_nameserver *ns, *nsback; struct dns_nameserver *ns, *nsback;
struct dns_resolution *res, *resback; struct dns_resolution *res, *resback;
struct dns_requester *req, *reqback; struct dns_requester *req, *reqback;
struct dns_srvrq *srvrq, *srvrqback; struct dns_srvrq *srvrq, *srvrqback;
list_for_each_entry_safe(resolvers, resolversback, &dns_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) {
free(ns->id); free(ns->id);
free((char *)ns->conf.file); free((char *)ns->conf.file);
@ -2270,12 +2270,12 @@ static void dns_deinit(void)
*/ */
static int dns_finalize_config(void) static int dns_finalize_config(void)
{ {
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct proxy *px; struct proxy *px;
int err_code = 0; int err_code = 0;
/* allocate pool of resolution per resolvers */ /* allocate pool of resolution per resolvers */
list_for_each_entry(resolvers, &dns_resolvers, list) { list_for_each_entry(resolvers, &sec_resolvers, list) {
struct dns_nameserver *ns; struct dns_nameserver *ns;
struct task *t; struct task *t;
@ -2342,7 +2342,7 @@ static int dns_finalize_config(void)
struct server *srv; struct server *srv;
for (srv = px->srv; srv; srv = srv->next) { for (srv = px->srv; srv; srv = srv->next) {
struct dns_resolvers *resolvers; struct resolvers *resolvers;
if (!srv->resolvers_id) if (!srv->resolvers_id)
continue; continue;
@ -2424,14 +2424,14 @@ int stats_dump_dns(struct stream_interface *si,
{ {
struct appctx *appctx = __objt_appctx(si->end); struct appctx *appctx = __objt_appctx(si->end);
struct channel *rep = si_ic(si); struct channel *rep = si_ic(si);
struct dns_resolvers *resolver = appctx->ctx.stats.obj1; struct resolvers *resolver = appctx->ctx.stats.obj1;
struct dns_nameserver *ns = appctx->ctx.stats.obj2; struct dns_nameserver *ns = appctx->ctx.stats.obj2;
if (!resolver) if (!resolver)
resolver = LIST_NEXT(&dns_resolvers, struct dns_resolvers *, list); resolver = LIST_NEXT(&sec_resolvers, struct resolvers *, list);
/* dump resolvers */ /* dump resolvers */
list_for_each_entry_from(resolver, &dns_resolvers, list) { list_for_each_entry_from(resolver, &sec_resolvers, list) {
appctx->ctx.stats.obj1 = resolver; appctx->ctx.stats.obj1 = resolver;
ns = appctx->ctx.stats.obj2 ? ns = appctx->ctx.stats.obj2 ?
@ -2463,7 +2463,7 @@ int stats_dump_dns(struct stream_interface *si,
void dns_stats_clear_counters(int clrall, struct list *stat_modules) void dns_stats_clear_counters(int clrall, struct list *stat_modules)
{ {
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
struct stats_module *mod; struct stats_module *mod;
void *counters; void *counters;
@ -2472,7 +2472,7 @@ void dns_stats_clear_counters(int clrall, struct list *stat_modules)
if (!mod->clearable && !clrall) if (!mod->clearable && !clrall)
continue; continue;
list_for_each_entry(resolvers, &dns_resolvers, list) { list_for_each_entry(resolvers, &sec_resolvers, list) {
list_for_each_entry(ns, &resolvers->nameservers, list) { list_for_each_entry(ns, &resolvers->nameservers, list) {
counters = EXTRA_COUNTERS_GET(ns->extra_counters, mod); counters = EXTRA_COUNTERS_GET(ns->extra_counters, mod);
memcpy(counters, mod->counters, mod->counters_size); memcpy(counters, mod->counters, mod->counters_size);
@ -2485,10 +2485,10 @@ void dns_stats_clear_counters(int clrall, struct list *stat_modules)
int dns_allocate_counters(struct list *stat_modules) int dns_allocate_counters(struct list *stat_modules)
{ {
struct stats_module *mod; struct stats_module *mod;
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
list_for_each_entry(resolvers, &dns_resolvers, list) { list_for_each_entry(resolvers, &sec_resolvers, list) {
list_for_each_entry(ns, &resolvers->nameservers, list) { list_for_each_entry(ns, &resolvers->nameservers, list) {
EXTRA_COUNTERS_REGISTER(&ns->extra_counters, COUNTERS_DNS, EXTRA_COUNTERS_REGISTER(&ns->extra_counters, COUNTERS_DNS,
alloc_failed); alloc_failed);
@ -2525,10 +2525,10 @@ alloc_failed:
/* if an arg is found, it sets the resolvers section pointer into cli.p0 */ /* if an arg is found, it sets the resolvers section pointer into cli.p0 */
static int cli_parse_stat_resolvers(char **args, char *payload, struct appctx *appctx, void *private) static int cli_parse_stat_resolvers(char **args, char *payload, struct appctx *appctx, void *private)
{ {
struct dns_resolvers *presolvers; struct resolvers *presolvers;
if (*args[2]) { if (*args[2]) {
list_for_each_entry(presolvers, &dns_resolvers, list) { list_for_each_entry(presolvers, &sec_resolvers, list) {
if (strcmp(presolvers->id, args[2]) == 0) { if (strcmp(presolvers->id, args[2]) == 0) {
appctx->ctx.cli.p0 = presolvers; appctx->ctx.cli.p0 = presolvers;
break; break;
@ -2548,7 +2548,7 @@ static int cli_parse_stat_resolvers(char **args, char *payload, struct appctx *a
static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx) static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
{ {
struct stream_interface *si = appctx->owner; struct stream_interface *si = appctx->owner;
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_nameserver *ns; struct dns_nameserver *ns;
chunk_reset(&trash); chunk_reset(&trash);
@ -2559,11 +2559,11 @@ static int cli_io_handler_dump_resolvers_to_buffer(struct appctx *appctx)
/* fall through */ /* fall through */
case STAT_ST_LIST: case STAT_ST_LIST:
if (LIST_ISEMPTY(&dns_resolvers)) { if (LIST_ISEMPTY(&sec_resolvers)) {
chunk_appendf(&trash, "No resolvers found\n"); chunk_appendf(&trash, "No resolvers found\n");
} }
else { else {
list_for_each_entry(resolvers, &dns_resolvers, list) { list_for_each_entry(resolvers, &sec_resolvers, list) {
if (appctx->ctx.cli.p0 != NULL && appctx->ctx.cli.p0 != resolvers) if (appctx->ctx.cli.p0 != NULL && appctx->ctx.cli.p0 != resolvers)
continue; continue;
@ -2663,7 +2663,7 @@ enum act_return dns_action_do_resolve(struct act_rule *rule, struct proxy *px,
struct sample *smp; struct sample *smp;
char *fqdn; char *fqdn;
struct dns_requester *req; struct dns_requester *req;
struct dns_resolvers *resolvers; struct resolvers *resolvers;
struct dns_resolution *res; struct dns_resolution *res;
int exp, locked = 0; int exp, locked = 0;
enum act_return ret = ACT_RET_CONT; enum act_return ret = ACT_RET_CONT;
@ -2916,7 +2916,7 @@ INITCALL1(STG_REGISTER, tcp_req_cont_keywords_register, &tcp_req_cont_actions);
*/ */
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)
{ {
struct dns_resolvers *resolvers = NULL; struct resolvers *resolvers = NULL;
if (rule->arg.dns.resolvers_id == NULL) { if (rule->arg.dns.resolvers_id == NULL) {
memprintf(err,"Proxy '%s': %s", px->id, "do-resolve action without resolvers"); memprintf(err,"Proxy '%s': %s", px->id, "do-resolve action without resolvers");

View File

@ -3863,7 +3863,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 dns_resolvers *resolvers = s->resolvers; struct resolvers *resolvers = s->resolvers;
struct dns_resolution *resolution = s->dns_requester->resolution; struct dns_resolution *resolution = s->dns_requester->resolution;
int exp; int exp;

View File

@ -668,7 +668,7 @@ static void stream_free(struct stream *s)
} }
if (s->dns_ctx.dns_requester) { if (s->dns_ctx.dns_requester) {
__decl_thread(struct dns_resolvers *resolvers = s->dns_ctx.parent->arg.dns.resolvers); __decl_thread(struct resolvers *resolvers = s->dns_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->dns_ctx.hostname_dn); s->dns_ctx.hostname_dn = NULL;