From: Evan Hunt Date: Thu, 5 Jun 2025 18:41:17 +0000 (-0700) Subject: Use ipv6 queries in delv +ns X-Git-Tag: v9.21.10~56^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=70ce3136bd533b2c3caa8e2f81dd631c85e2eab9;p=thirdparty%2Fbind9.git 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`. --- diff --git a/bin/delv/delv.c b/bin/delv/delv.c index d8c7966c33d..262f83cdb20 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -101,7 +101,8 @@ static isc_mem_t *mctx = 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; @@ -1927,8 +1928,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); @@ -2128,7 +2132,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); @@ -2139,8 +2143,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)); @@ -2164,7 +2179,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);