REORG: dns: dns_option structure, storage of hostname_dn
authorBaptiste Assmann <bedis9@gmail.com>
Wed, 3 May 2017 10:12:02 +0000 (12:12 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 2 Jun 2017 09:26:48 +0000 (11:26 +0200)
commit42746373eb1fc6e57e89982c653caccaa7500ea0
treeb94deabda4598e61baede1da8c9854d023ef3bb5
parent4f91f7ea59786a9a7bd592aad26dc25b28d3c9b0
REORG: dns: dns_option structure, storage of hostname_dn

This patch introduces a some re-organisation around the DNS code in
HAProxy.

1. make the dns_* functions less dependent on 'struct server' and 'struct resolution'.

With this in mind, the following changes were performed:
- 'struct dns_options' has been removed from 'struct resolution' (well,
  we might need it back at some point later, we'll see)
  ==> we'll use the 'struct dns_options' from the owner of the resolution
- dns_get_ip_from_response(): takes a 'struct dns_options' instead of
  'struct resolution'
  ==> so the caller can pass its own dns options to get the most
      appropriate IP from the response
- dns_process_resolve(): struct dns_option is deduced from new
  resolution->requester_type parameter

2. add hostname_dn and hostname_dn_len into struct server

In order to avoid recomputing a server's hostname into its domain name
format (and use a trash buffer to store the result), it is safer to
compute it once at configuration parsing and to store it into the struct
server.
In the mean time, the struct resolution linked to the server doesn't
need anymore to store the hostname in domain name format. A simple
pointer to the server one will make the trick.

The function srv_alloc_dns_resolution() properly manages everything for
us: memory allocation, pointer updates, etc...

3. move resolvers pointer into struct server

This patch makes the pointer to struct dns_resolvers from struct
dns_resolution obsolete.
Purpose is to make the resolution as "neutral" as possible and since the
requester is already linked to the resolvers, then we don't need this
information anymore in the resolution itself.
include/proto/dns.h
include/types/dns.h
include/types/server.h
src/cfgparse.c
src/checks.c
src/dns.c
src/server.c