mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 14:35:26 +00:00
[9.20] fix: usr: Use IPv6 queries in delv +ns
`delv +ns` invokes the same code to perform name resolution as `named`, but it neglected to set up an IPv6 dispatch object first. Consequently, it was behaving more like `named -4`. It now sets up dispatch objects for both address families, and performs resolver queries to both v4 and v6 addresses, except when one of the address families has been suppressed by using `delv -4` or `delv -6`. Closes #5352 Backport of MR !10563 Merge branch 'backport-5352-delv-ipv6-9.20' into 'bind-9.20' See merge request isc-projects/bind9!10573
This commit is contained in:
@@ -99,7 +99,8 @@ static isc_log_t *lctx = NULL;
|
||||
static dns_view_t *view = NULL;
|
||||
static ns_server_t *sctx = NULL;
|
||||
static ns_interface_t *ifp = NULL;
|
||||
static dns_dispatch_t *dispatch = NULL;
|
||||
static dns_dispatch_t *dispatch4 = NULL;
|
||||
static dns_dispatch_t *dispatch6 = NULL;
|
||||
static dns_db_t *roothints = NULL;
|
||||
static isc_stats_t *resstats = NULL;
|
||||
static dns_stats_t *resquerystats = NULL;
|
||||
@@ -1998,8 +1999,11 @@ shutdown_server(void) {
|
||||
ns_interfacemgr_shutdown(interfacemgr);
|
||||
ns_interfacemgr_detach(&interfacemgr);
|
||||
}
|
||||
if (dispatch != NULL) {
|
||||
dns_dispatch_detach(&dispatch);
|
||||
if (dispatch4 != NULL) {
|
||||
dns_dispatch_detach(&dispatch4);
|
||||
}
|
||||
if (dispatch6 != NULL) {
|
||||
dns_dispatch_detach(&dispatch6);
|
||||
}
|
||||
if (dispatchmgr != NULL) {
|
||||
dns_dispatchmgr_detach(&dispatchmgr);
|
||||
@@ -2204,7 +2208,7 @@ static void
|
||||
run_server(void *arg) {
|
||||
isc_result_t result;
|
||||
dns_cache_t *cache = NULL;
|
||||
isc_sockaddr_t addr, any;
|
||||
isc_sockaddr_t addr, any, any6;
|
||||
struct in_addr in;
|
||||
|
||||
UNUSED(arg);
|
||||
@@ -2215,8 +2219,19 @@ run_server(void *arg) {
|
||||
ns_server_create(mctx, matchview, &sctx);
|
||||
|
||||
CHECK(dns_dispatchmgr_create(mctx, loopmgr, netmgr, &dispatchmgr));
|
||||
isc_sockaddr_any(&any);
|
||||
CHECK(dns_dispatch_createudp(dispatchmgr, &any, &dispatch));
|
||||
|
||||
if (use_ipv4) {
|
||||
isc_sockaddr_any(&any);
|
||||
isc_sockaddr_t *a = (srcaddr4 == NULL) ? &any : srcaddr4;
|
||||
CHECK(dns_dispatch_createudp(dispatchmgr, a, &dispatch4));
|
||||
}
|
||||
|
||||
if (use_ipv6) {
|
||||
isc_sockaddr_any6(&any6);
|
||||
isc_sockaddr_t *a = (srcaddr6 == NULL) ? &any6 : srcaddr6;
|
||||
CHECK(dns_dispatch_createudp(dispatchmgr, a, &dispatch6));
|
||||
}
|
||||
|
||||
CHECK(ns_interfacemgr_create(mctx, sctx, loopmgr, netmgr, dispatchmgr,
|
||||
NULL, &interfacemgr));
|
||||
|
||||
@@ -2240,7 +2255,7 @@ run_server(void *arg) {
|
||||
CHECK(setup_dnsseckeys(NULL, view));
|
||||
|
||||
CHECK(dns_view_createresolver(view, netmgr, 0, tlsctx_client_cache,
|
||||
dispatch, NULL));
|
||||
dispatch4, dispatch6));
|
||||
dns_resolver_setmaxqueries(view->resolver, maxqueries);
|
||||
|
||||
isc_stats_create(mctx, &resstats, dns_resstatscounter_max);
|
||||
|
15
bin/tests/system/digdelv/root.hint
Normal file
15
bin/tests/system/digdelv/root.hint
Normal file
@@ -0,0 +1,15 @@
|
||||
; Copyright (C) Internet Systems Consortium, Inc. ("ISC")
|
||||
;
|
||||
; SPDX-License-Identifier: MPL-2.0
|
||||
;
|
||||
; This Source Code Form is subject to the terms of the Mozilla Public
|
||||
; License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
; file, you can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
;
|
||||
; See the COPYRIGHT file distributed with this work for additional
|
||||
; information regarding copyright ownership.
|
||||
|
||||
$TTL 999999
|
||||
. IN NS a.root-servers.nil.
|
||||
a.root-servers.nil. IN A 10.53.0.1
|
||||
a.root-servers.nil. AAAA fd92:7065:b8e:ffff::1
|
@@ -1697,7 +1697,8 @@ if [ -x "$DELV" ]; then
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "check NS output from delv +ns ($n)"
|
||||
delv_with_opts -i +ns +nortrace +nostrace +nomtrace +novtrace +hint=../_common/root.hint ns example >delv.out.test$n || ret=1
|
||||
ret=0
|
||||
delv_with_opts -i +ns +nortrace +nostrace +nomtrace +novtrace +hint=root.hint ns example >delv.out.test$n || ret=1
|
||||
lines=$(awk '$1 == "example." && $4 == "NS" {print}' delv.out.test$n | wc -l)
|
||||
[ $lines -eq 2 ] || ret=1
|
||||
status=$((status + ret))
|
||||
@@ -1705,7 +1706,7 @@ if [ -x "$DELV" ]; then
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv +ns (no validation) ($n)"
|
||||
ret=0
|
||||
delv_with_opts -i +ns +hint=../_common/root.hint a a.example >delv.out.test$n || ret=1
|
||||
delv_with_opts -i +ns +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -q '; authoritative' delv.out.test$n || ret=1
|
||||
grep -q '_.example' delv.out.test$n && ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
@@ -1714,7 +1715,7 @@ if [ -x "$DELV" ]; then
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv +ns +qmin (no validation) ($n)"
|
||||
ret=0
|
||||
delv_with_opts -i +ns +qmin +hint=../_common/root.hint a a.example >delv.out.test$n || ret=1
|
||||
delv_with_opts -i +ns +qmin +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -q '; authoritative' delv.out.test$n || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
@@ -1722,7 +1723,7 @@ if [ -x "$DELV" ]; then
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv +ns (with validation) ($n)"
|
||||
ret=0
|
||||
delv_with_opts -a ns1/anchor.dnskey +root +ns +hint=../_common/root.hint a a.example >delv.out.test$n || ret=1
|
||||
delv_with_opts -a ns1/anchor.dnskey +root +ns +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -q '; fully validated' delv.out.test$n || ret=1
|
||||
grep -q '_.example' delv.out.test$n && ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
@@ -1731,11 +1732,40 @@ if [ -x "$DELV" ]; then
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv +ns +qmin (with validation) ($n)"
|
||||
ret=0
|
||||
delv_with_opts -a ns1/anchor.dnskey +root +ns +qmin +hint=../_common/root.hint a a.example >delv.out.test$n || ret=1
|
||||
delv_with_opts -a ns1/anchor.dnskey +root +ns +qmin +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -q '; fully validated' delv.out.test$n || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
|
||||
if testsock6 fd92:7065:b8e:ffff::2 2>/dev/null; then
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv +ns uses both address families ($n)"
|
||||
ret=0
|
||||
delv_with_opts -a ns1/anchor.dnskey +root +ns +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -qF 'sending packet to 10.53' delv.out.test$n >/dev/null || ret=1
|
||||
grep -qF 'sending packet to fd92:7065' delv.out.test$n >/dev/null || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv -4 +ns uses only IPv4 ($n)"
|
||||
ret=0
|
||||
delv_with_opts -a ns1/anchor.dnskey +root -4 +ns +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -qF 'sending packet to 10.53' delv.out.test$n >/dev/null || ret=1
|
||||
grep -qF 'sending packet to fd92:7065' delv.out.test$n >/dev/null && ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
|
||||
n=$((n + 1))
|
||||
echo_i "checking delv -6 +ns uses only IPv6 ($n)"
|
||||
ret=0
|
||||
delv_with_opts -a ns1/anchor.dnskey +root -6 +ns +hint=root.hint a a.example >delv.out.test$n || ret=1
|
||||
grep -qF 'sending packet to 10.53' delv.out.test$n >/dev/null && ret=1
|
||||
grep -qF 'sending packet to fd92:7065' delv.out.test$n >/dev/null || ret=1
|
||||
if [ $ret -ne 0 ]; then echo_i "failed"; fi
|
||||
status=$((status + ret))
|
||||
fi
|
||||
|
||||
else
|
||||
echo_i "$DELV is needed, so skipping these delv tests"
|
||||
fi
|
||||
|
Reference in New Issue
Block a user