mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-22 01:59:26 +00:00
4222. [func] Bias IPv6 servers when selecting the next server to
query. [RT #40836]
This commit is contained in:
parent
8d80b4939d
commit
98a7f8c7ae
3
CHANGES
3
CHANGES
@ -1,3 +1,6 @@
|
||||
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.
|
||||
[RT #40583]
|
||||
|
||||
|
@ -184,6 +184,7 @@ options {\n\
|
||||
allow-new-zones no;\n\
|
||||
fetches-per-server 0;\n\
|
||||
require-server-cookie no;\n\
|
||||
v6-bias 50;\n\
|
||||
"
|
||||
#ifdef HAVE_GEOIP
|
||||
"\
|
||||
|
@ -3542,6 +3542,11 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist,
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
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;
|
||||
result = ns_config_get(maps, "max-clients-per-query", &obj);
|
||||
INSIST(result == ISC_R_SUCCESS);
|
||||
|
@ -5035,6 +5035,7 @@ badresp:1,adberr:0,findfail:0,valfail:0]
|
||||
<optional> min-ns-dots <replaceable>number</replaceable> </optional>
|
||||
<optional> qname-wait-recurse <replaceable>yes_or_no</replaceable> </optional>
|
||||
; </optional>
|
||||
<optional>v6-bias <replaceable>number</replaceable> ; </optional>
|
||||
};
|
||||
</programlisting>
|
||||
|
||||
@ -9590,6 +9591,17 @@ avoid-v6-udp-ports { 40000; range 50000 60000; };
|
||||
</para>
|
||||
</listitem>
|
||||
</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>
|
||||
|
||||
</sect3>
|
||||
|
@ -314,6 +314,7 @@ options {
|
||||
use-queryport-pool <boolean>; // obsolete
|
||||
use-v4-udp-ports { <portrange>; ... };
|
||||
use-v6-udp-ports { <portrange>; ... };
|
||||
v6-bias <integer>;
|
||||
version ( <quoted_string> | none );
|
||||
zero-no-soa-ttl <boolean>;
|
||||
zero-no-soa-ttl-cache <boolean>;
|
||||
@ -587,6 +588,7 @@ view <string> [ <class> ] {
|
||||
update-check-ksk <boolean>;
|
||||
use-alt-transfer-source <boolean>;
|
||||
use-queryport-pool <boolean>; // obsolete
|
||||
v6-bias <integer>;
|
||||
zero-no-soa-ttl <boolean>;
|
||||
zero-no-soa-ttl-cache <boolean>;
|
||||
zone <string> [ <class> ] {
|
||||
|
@ -216,6 +216,7 @@ struct dns_view {
|
||||
void (*cfg_destroy)(void **);
|
||||
|
||||
unsigned char secret[32]; /* Client secret */
|
||||
unsigned int v6bias;
|
||||
};
|
||||
|
||||
#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,
|
||||
* Sort addrinfo list by RTT.
|
||||
*/
|
||||
static void
|
||||
sort_adbfind(dns_adbfind_t *find) {
|
||||
sort_adbfind(dns_adbfind_t *find, unsigned int bias) {
|
||||
dns_adbaddrinfo_t *best, *curr;
|
||||
dns_adbaddrinfolist_t sorted;
|
||||
int family;
|
||||
|
||||
/* Lame N^2 bubble sort. */
|
||||
ISC_LIST_INIT(sorted);
|
||||
while (!ISC_LIST_EMPTY(find->list)) {
|
||||
best = ISC_LIST_HEAD(find->list);
|
||||
family = isc_sockaddr_pf(&best->sockaddr);
|
||||
curr = ISC_LIST_NEXT(best, publink);
|
||||
while (curr != NULL) {
|
||||
if (curr->srtt < best->srtt)
|
||||
best = curr;
|
||||
if (isc_sockaddr_pf(&curr->sockaddr) == family) {
|
||||
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);
|
||||
}
|
||||
ISC_LIST_UNLINK(find->list, best, publink);
|
||||
@ -2957,16 +2971,17 @@ sort_adbfind(dns_adbfind_t *find) {
|
||||
* Sort a list of finds by server RTT.
|
||||
*/
|
||||
static void
|
||||
sort_finds(dns_adbfindlist_t *findlist) {
|
||||
sort_finds(dns_adbfindlist_t *findlist, unsigned int bias) {
|
||||
dns_adbfind_t *best, *curr;
|
||||
dns_adbfindlist_t sorted;
|
||||
dns_adbaddrinfo_t *addrinfo, *bestaddrinfo;
|
||||
int family;
|
||||
|
||||
/* Sort each find's addrinfo list by SRTT. */
|
||||
for (curr = ISC_LIST_HEAD(*findlist);
|
||||
curr != NULL;
|
||||
curr = ISC_LIST_NEXT(curr, publink))
|
||||
sort_adbfind(curr);
|
||||
sort_adbfind(curr, bias);
|
||||
|
||||
/* Lame N^2 bubble sort. */
|
||||
ISC_LIST_INIT(sorted);
|
||||
@ -2974,13 +2989,30 @@ sort_finds(dns_adbfindlist_t *findlist) {
|
||||
best = ISC_LIST_HEAD(*findlist);
|
||||
bestaddrinfo = ISC_LIST_HEAD(best->list);
|
||||
INSIST(bestaddrinfo != NULL);
|
||||
family = isc_sockaddr_pf(&bestaddrinfo->sockaddr);
|
||||
curr = ISC_LIST_NEXT(best, publink);
|
||||
while (curr != NULL) {
|
||||
addrinfo = ISC_LIST_HEAD(curr->list);
|
||||
INSIST(addrinfo != NULL);
|
||||
if (addrinfo->srtt < bestaddrinfo->srtt) {
|
||||
best = curr;
|
||||
bestaddrinfo = addrinfo;
|
||||
if (isc_sockaddr_pf(&addrinfo->sockaddr) == family) {
|
||||
if (addrinfo->srtt < bestaddrinfo->srtt) {
|
||||
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);
|
||||
}
|
||||
@ -3394,8 +3426,8 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) {
|
||||
* We've found some addresses. We might still be looking
|
||||
* for more addresses.
|
||||
*/
|
||||
sort_finds(&fctx->finds);
|
||||
sort_finds(&fctx->altfinds);
|
||||
sort_finds(&fctx->finds, res->view->v6bias);
|
||||
sort_finds(&fctx->altfinds, 0);
|
||||
result = ISC_R_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -240,6 +240,7 @@ dns_view_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
|
||||
view->cfg_destroy = NULL;
|
||||
view->fail_ttl = 0;
|
||||
view->failcache = NULL;
|
||||
view->v6bias = 0;
|
||||
dns_badcache_init(view->mctx, DNS_VIEW_FAILCACHESIZE, &view->failcache);
|
||||
|
||||
if (isc_bind9) {
|
||||
|
@ -1578,6 +1578,18 @@ view_clauses[] = {
|
||||
{ "fetch-quota-params", &cfg_type_fetchquota, 0 },
|
||||
{ "fetches-per-server", &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 },
|
||||
{ "lame-ttl", &cfg_type_ttlval, 0 },
|
||||
{ "nocookie-udp-size", &cfg_type_uint32, 0 },
|
||||
@ -1608,11 +1620,13 @@ view_clauses[] = {
|
||||
{ "queryport-pool-ports", &cfg_type_uint32, CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "queryport-pool-updateinterval", &cfg_type_uint32,
|
||||
CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "rate-limit", &cfg_type_rrl, 0 },
|
||||
{ "recursion", &cfg_type_boolean, 0 },
|
||||
{ "request-sit", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "request-nsid", &cfg_type_boolean, 0 },
|
||||
{ "require-server-cookie", &cfg_type_boolean, 0 },
|
||||
{ "resolver-query-timeout", &cfg_type_uint32, 0 },
|
||||
{ "response-policy", &cfg_type_rpz, 0 },
|
||||
{ "rfc2308-type1", &cfg_type_boolean, CFG_CLAUSEFLAG_NYI },
|
||||
{ "root-delegation-only", &cfg_type_optional_exclude, 0 },
|
||||
{ "rrset-order", &cfg_type_rrsetorder, 0 },
|
||||
@ -1623,21 +1637,8 @@ view_clauses[] = {
|
||||
{ "topology", &cfg_type_bracketed_aml, CFG_CLAUSEFLAG_NOTIMP },
|
||||
{ "transfer-format", &cfg_type_transferformat, 0 },
|
||||
{ "use-queryport-pool", &cfg_type_boolean, CFG_CLAUSEFLAG_OBSOLETE },
|
||||
{ "v6-bias", &cfg_type_uint32, 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 }
|
||||
};
|
||||
|
||||
@ -1815,8 +1816,11 @@ view_clausesets[] = {
|
||||
zone_clauses,
|
||||
NULL
|
||||
};
|
||||
|
||||
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. */
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user