Commit 98a7f8c7 authored by Mark Andrews's avatar Mark Andrews

4222. [func] Bias IPv6 servers when selecting the next server to

                        query. [RT #40836]
parent 8d80b493
4222. [func] Bias IPv6 servers when selecting the next server to
query. [RT #40836]
4221. [bug] Resource leak on DNS_R_NXDOMAIN in fctx_create. 4221. [bug] Resource leak on DNS_R_NXDOMAIN in fctx_create.
[RT #40583] [RT #40583]
......
...@@ -184,6 +184,7 @@ options {\n\ ...@@ -184,6 +184,7 @@ options {\n\
allow-new-zones no;\n\ allow-new-zones no;\n\
fetches-per-server 0;\n\ fetches-per-server 0;\n\
require-server-cookie no;\n\ require-server-cookie no;\n\
v6-bias 50;\n\
" "
#ifdef HAVE_GEOIP #ifdef HAVE_GEOIP
"\ "\
......
...@@ -3542,6 +3542,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, ...@@ -3542,6 +3542,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
INSIST(result == ISC_R_SUCCESS); INSIST(result == ISC_R_SUCCESS);
view->requireservercookie = cfg_obj_asboolean(obj); view->requireservercookie = cfg_obj_asboolean(obj);
obj = NULL;
result = ns_config_get(maps, "v6-bias", &obj);
INSIST(result == ISC_R_SUCCESS);
view->v6bias = cfg_obj_asuint32(obj) * 1000;
obj = NULL; obj = NULL;
result = ns_config_get(maps, "max-clients-per-query", &obj); result = ns_config_get(maps, "max-clients-per-query", &obj);
INSIST(result == ISC_R_SUCCESS); INSIST(result == ISC_R_SUCCESS);
......
...@@ -5035,6 +5035,7 @@ badresp:1,adberr:0,findfail:0,valfail:0] ...@@ -5035,6 +5035,7 @@ badresp:1,adberr:0,findfail:0,valfail:0]
<optional> min-ns-dots <replaceable>number</replaceable> </optional> <optional> min-ns-dots <replaceable>number</replaceable> </optional>
<optional> qname-wait-recurse <replaceable>yes_or_no</replaceable> </optional> <optional> qname-wait-recurse <replaceable>yes_or_no</replaceable> </optional>
; </optional> ; </optional>
<optional>v6-bias <replaceable>number</replaceable> ; </optional>
}; };
</programlisting> </programlisting>
...@@ -9590,6 +9591,17 @@ avoid-v6-udp-ports { 40000; range 50000 60000; }; ...@@ -9590,6 +9591,17 @@ avoid-v6-udp-ports { 40000; range 50000 60000; };
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><command>v6-bias</command></term>
<listitem>
<para>
When determining the next nameserver to try
preference IPv6 nameservers by this many milliseconds.
The default is <literal>50</literal> milliseconds.
</para>
</listitem>
</varlistentry>
</variablelist> </variablelist>
</sect3> </sect3>
......
...@@ -314,6 +314,7 @@ options { ...@@ -314,6 +314,7 @@ options {
use-queryport-pool <boolean>; // obsolete use-queryport-pool <boolean>; // obsolete
use-v4-udp-ports { <portrange>; ... }; use-v4-udp-ports { <portrange>; ... };
use-v6-udp-ports { <portrange>; ... }; use-v6-udp-ports { <portrange>; ... };
v6-bias <integer>;
version ( <quoted_string> | none ); version ( <quoted_string> | none );
zero-no-soa-ttl <boolean>; zero-no-soa-ttl <boolean>;
zero-no-soa-ttl-cache <boolean>; zero-no-soa-ttl-cache <boolean>;
...@@ -587,6 +588,7 @@ view <string> [ <class> ] { ...@@ -587,6 +588,7 @@ view <string> [ <class> ] {
update-check-ksk <boolean>; update-check-ksk <boolean>;
use-alt-transfer-source <boolean>; use-alt-transfer-source <boolean>;
use-queryport-pool <boolean>; // obsolete use-queryport-pool <boolean>; // obsolete
v6-bias <integer>;
zero-no-soa-ttl <boolean>; zero-no-soa-ttl <boolean>;
zero-no-soa-ttl-cache <boolean>; zero-no-soa-ttl-cache <boolean>;
zone <string> [ <class> ] { zone <string> [ <class> ] {
......
...@@ -216,6 +216,7 @@ struct dns_view { ...@@ -216,6 +216,7 @@ struct dns_view {
void (*cfg_destroy)(void **); void (*cfg_destroy)(void **);
unsigned char secret[32]; /* Client secret */ unsigned char secret[32]; /* Client secret */
unsigned int v6bias;
}; };
#define DNS_VIEW_MAGIC ISC_MAGIC('V','i','e','w') #define DNS_VIEW_MAGIC ISC_MAGIC('V','i','e','w')
......
...@@ -2933,18 +2933,32 @@ add_bad(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, isc_result_t reason, ...@@ -2933,18 +2933,32 @@ add_bad(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, isc_result_t reason,
* Sort addrinfo list by RTT. * Sort addrinfo list by RTT.
*/ */
static void static void
sort_adbfind(dns_adbfind_t *find) { sort_adbfind(dns_adbfind_t *find, unsigned int bias) {
dns_adbaddrinfo_t *best, *curr; dns_adbaddrinfo_t *best, *curr;
dns_adbaddrinfolist_t sorted; dns_adbaddrinfolist_t sorted;
int family;
/* Lame N^2 bubble sort. */ /* Lame N^2 bubble sort. */
ISC_LIST_INIT(sorted); ISC_LIST_INIT(sorted);
while (!ISC_LIST_EMPTY(find->list)) { while (!ISC_LIST_EMPTY(find->list)) {
best = ISC_LIST_HEAD(find->list); best = ISC_LIST_HEAD(find->list);
family = isc_sockaddr_pf(&best->sockaddr);
curr = ISC_LIST_NEXT(best, publink); curr = ISC_LIST_NEXT(best, publink);
while (curr != NULL) { while (curr != NULL) {
if (curr->srtt < best->srtt) if (isc_sockaddr_pf(&curr->sockaddr) == family) {
best = curr; if (curr->srtt < best->srtt)
best = curr;
} else if (family == AF_INET6) {
if (curr->srtt + bias < best->srtt) {
best = curr;
family = AF_INET;
}
} else {
if (curr->srtt < best->srtt + bias) {
best = curr;
family = AF_INET6;
}
}
curr = ISC_LIST_NEXT(curr, publink); curr = ISC_LIST_NEXT(curr, publink);
} }
ISC_LIST_UNLINK(find->list, best, publink); ISC_LIST_UNLINK(find->list, best, publink);
...@@ -2957,16 +2971,17 @@ sort_adbfind(dns_adbfind_t *find) { ...@@ -2957,16 +2971,17 @@ sort_adbfind(dns_adbfind_t *find) {
* Sort a list of finds by server RTT. * Sort a list of finds by server RTT.
*/ */
static void static void
sort_finds(dns_adbfindlist_t *findlist) { sort_finds(dns_adbfindlist_t *findlist, unsigned int bias) {
dns_adbfind_t *best, *curr; dns_adbfind_t *best, *curr;
dns_adbfindlist_t sorted; dns_adbfindlist_t sorted;
dns_adbaddrinfo_t *addrinfo, *bestaddrinfo; dns_adbaddrinfo_t *addrinfo, *bestaddrinfo;
int family;
/* Sort each find's addrinfo list by SRTT. */ /* Sort each find's addrinfo list by SRTT. */
for (curr = ISC_LIST_HEAD(*findlist); for (curr = ISC_LIST_HEAD(*findlist);
curr != NULL; curr != NULL;
curr = ISC_LIST_NEXT(curr, publink)) curr = ISC_LIST_NEXT(curr, publink))
sort_adbfind(curr); sort_adbfind(curr, bias);
/* Lame N^2 bubble sort. */ /* Lame N^2 bubble sort. */
ISC_LIST_INIT(sorted); ISC_LIST_INIT(sorted);
...@@ -2974,13 +2989,30 @@ sort_finds(dns_adbfindlist_t *findlist) { ...@@ -2974,13 +2989,30 @@ sort_finds(dns_adbfindlist_t *findlist) {
best = ISC_LIST_HEAD(*findlist); best = ISC_LIST_HEAD(*findlist);
bestaddrinfo = ISC_LIST_HEAD(best->list); bestaddrinfo = ISC_LIST_HEAD(best->list);
INSIST(bestaddrinfo != NULL); INSIST(bestaddrinfo != NULL);
family = isc_sockaddr_pf(&bestaddrinfo->sockaddr);
curr = ISC_LIST_NEXT(best, publink); curr = ISC_LIST_NEXT(best, publink);
while (curr != NULL) { while (curr != NULL) {
addrinfo = ISC_LIST_HEAD(curr->list); addrinfo = ISC_LIST_HEAD(curr->list);
INSIST(addrinfo != NULL); INSIST(addrinfo != NULL);
if (addrinfo->srtt < bestaddrinfo->srtt) { if (isc_sockaddr_pf(&addrinfo->sockaddr) == family) {
best = curr; if (addrinfo->srtt < bestaddrinfo->srtt) {
bestaddrinfo = addrinfo; best = curr;
bestaddrinfo = addrinfo;
}
} else if (family == AF_INET6) {
if (addrinfo->srtt + bias <
bestaddrinfo->srtt) {
best = curr;
bestaddrinfo = addrinfo;
family = AF_INET;
}
} else {
if (addrinfo->srtt <
bestaddrinfo->srtt + bias) {
best = curr;
bestaddrinfo = addrinfo;
family = AF_INET6;
}
} }
curr = ISC_LIST_NEXT(curr, publink); curr = ISC_LIST_NEXT(curr, publink);
} }
...@@ -3394,8 +3426,8 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { ...@@ -3394,8 +3426,8 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) {
* We've found some addresses. We might still be looking * We've found some addresses. We might still be looking
* for more addresses. * for more addresses.
*/ */
sort_finds(&fctx->finds); sort_finds(&fctx->finds, res->view->v6bias);
sort_finds(&fctx->altfinds); sort_finds(&fctx->altfinds, 0);
result = ISC_R_SUCCESS; result = ISC_R_SUCCESS;
} }
......
...@@ -240,6 +240,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass, ...@@ -240,6 +240,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
view->cfg_destroy = NULL; view->cfg_destroy = NULL;
view->fail_ttl = 0; view->fail_ttl = 0;
view->failcache = NULL; view->failcache = NULL;
view->v6bias = 0;
dns_badcache_init(view->mctx, DNS_VIEW_FAILCACHESIZE, &view->failcache); dns_badcache_init(view->mctx, DNS_VIEW_FAILCACHESIZE, &view->failcache);
if (isc_bind9) { if (isc_bind9) {
......
...@@ -1578,6 +1578,18 @@ view_clauses[] = { ...@@ -1578,6 +1578,18 @@ view_clauses[] = {
{ "fetch-quota-params", &cfg_type_fetchquota, 0 }, { "fetch-quota-params", &cfg_type_fetchquota, 0 },
{ "fetches-per-server", &cfg_type_fetchesper, 0 }, { "fetches-per-server", &cfg_type_fetchesper, 0 },
{ "fetches-per-zone", &cfg_type_fetchesper, 0 }, { "fetches-per-zone", &cfg_type_fetchesper, 0 },
#ifdef ALLOW_FILTER_AAAA
{ "filter-aaaa", &cfg_type_bracketed_aml, 0 },
{ "filter-aaaa-on-v4", &cfg_type_filter_aaaa, 0 },
{ "filter-aaaa-on-v6", &cfg_type_filter_aaaa, 0 },
#else
{ "filter-aaaa", &cfg_type_bracketed_aml,
CFG_CLAUSEFLAG_NOTCONFIGURED },
{ "filter-aaaa-on-v4", &cfg_type_filter_aaaa,
CFG_CLAUSEFLAG_NOTCONFIGURED },
{ "filter-aaaa-on-v6", &cfg_type_filter_aaaa,
CFG_CLAUSEFLAG_NOTCONFIGURED },
#endif
{ "ixfr-from-differences", &cfg_type_ixfrdifftype, 0 }, { "ixfr-from-differences", &cfg_type_ixfrdifftype, 0 },
{ "lame-ttl", &cfg_type_ttlval, 0 }, { "lame-ttl", &cfg_type_ttlval, 0 },
{ "nocookie-udp-size", &cfg_type_uint32, 0 }, { "nocookie-udp-size", &cfg_type_uint32, 0 },
...@@ -1608,11 +1620,13 @@ view_clauses[] = { ...@@ -1608,11 +1620,13 @@ view_clauses[] = {
{ "queryport-pool-ports", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE }, { "queryport-pool-ports", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
{ "queryport-pool-updateinterval", &cfg_type_uint32, { "queryport-pool-updateinterval", &cfg_type_uint32,
CFG_CLAUSEFLAG_OBSOLETE }, CFG_CLAUSEFLAG_OBSOLETE },
{ "rate-limit", &cfg_type_rrl, 0 },
{ "recursion", &cfg_type_boolean, 0 }, { "recursion", &cfg_type_boolean, 0 },
{ "request-sit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, { "request-sit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
{ "request-nsid", &cfg_type_boolean, 0 }, { "request-nsid", &cfg_type_boolean, 0 },
{ "require-server-cookie", &cfg_type_boolean, 0 }, { "require-server-cookie", &cfg_type_boolean, 0 },
{ "resolver-query-timeout", &cfg_type_uint32, 0 }, { "resolver-query-timeout", &cfg_type_uint32, 0 },
{ "response-policy", &cfg_type_rpz, 0 },
{ "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI }, { "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },
{ "root-delegation-only", &cfg_type_optional_exclude, 0 }, { "root-delegation-only", &cfg_type_optional_exclude, 0 },
{ "rrset-order", &cfg_type_rrsetorder, 0 }, { "rrset-order", &cfg_type_rrsetorder, 0 },
...@@ -1623,21 +1637,8 @@ view_clauses[] = { ...@@ -1623,21 +1637,8 @@ view_clauses[] = {
{ "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP }, { "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP },
{ "transfer-format", &cfg_type_transferformat, 0 }, { "transfer-format", &cfg_type_transferformat, 0 },
{ "use-queryport-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE }, { "use-queryport-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
{ "v6-bias", &cfg_type_uint32, 0 },
{ "zero-no-soa-ttl-cache", &cfg_type_boolean, 0 }, { "zero-no-soa-ttl-cache", &cfg_type_boolean, 0 },
#ifdef ALLOW_FILTER_AAAA
{ "filter-aaaa", &cfg_type_bracketed_aml, 0 },
{ "filter-aaaa-on-v4", &cfg_type_filter_aaaa, 0 },
{ "filter-aaaa-on-v6", &cfg_type_filter_aaaa, 0 },
#else
{ "filter-aaaa", &cfg_type_bracketed_aml,
CFG_CLAUSEFLAG_NOTCONFIGURED },
{ "filter-aaaa-on-v4", &cfg_type_filter_aaaa,
CFG_CLAUSEFLAG_NOTCONFIGURED },
{ "filter-aaaa-on-v6", &cfg_type_filter_aaaa,
CFG_CLAUSEFLAG_NOTCONFIGURED },
#endif
{ "response-policy", &cfg_type_rpz, 0 },
{ "rate-limit", &cfg_type_rrl, 0 },
{ NULL, NULL, 0 } { NULL, NULL, 0 }
}; };
...@@ -1815,8 +1816,11 @@ view_clausesets[] = { ...@@ -1815,8 +1816,11 @@ view_clausesets[] = {
zone_clauses, zone_clauses,
NULL NULL
}; };
static cfg_type_t cfg_type_viewopts = { static cfg_type_t cfg_type_viewopts = {
"view", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map, view_clausesets }; "view", cfg_parse_map, cfg_print_map, cfg_doc_map, &cfg_rep_map,
view_clausesets
};
/*% The "zone" statement syntax. */ /*% The "zone" statement syntax. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment