2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

Merge branch '2374-mdig-ephemeral' into 'main'

Make mdig use the OS-supplied ephemeral port range

Closes #2374

See merge request isc-projects/bind9!5552
This commit is contained in:
Evan Hunt
2021-11-17 22:38:50 +00:00
2 changed files with 47 additions and 0 deletions

View File

@@ -1,3 +1,6 @@
5758. [bug] mdig now honors the operating system's preferred
ephemeral port range. [GL #2374]
5757. [test] Replace sed in nsupdate system test with awk to
construct the nsupdate command. The sed expression
was not reliably changing the ttl. [GL #3003]

View File

@@ -27,6 +27,7 @@
#include <isc/netmgr.h>
#include <isc/nonce.h>
#include <isc/parseint.h>
#include <isc/portset.h>
#include <isc/print.h>
#include <isc/random.h>
#include <isc/result.h>
@@ -2054,6 +2055,47 @@ parse_args(bool is_batchfile, int argc, char **argv) {
}
}
/*
* Try honoring the operating system's preferred ephemeral port range.
*/
static void
set_source_ports(dns_dispatchmgr_t *manager) {
isc_portset_t *v4portset = NULL, *v6portset = NULL;
in_port_t udpport_low, udpport_high;
isc_result_t result;
result = isc_portset_create(mctx, &v4portset);
if (result != ISC_R_SUCCESS) {
fatal("isc_portset_create (v4) failed");
}
result = isc_net_getudpportrange(AF_INET, &udpport_low, &udpport_high);
if (result != ISC_R_SUCCESS) {
fatal("isc_net_getudpportrange (v4) failed");
}
isc_portset_addrange(v4portset, udpport_low, udpport_high);
result = isc_portset_create(mctx, &v6portset);
if (result != ISC_R_SUCCESS) {
fatal("isc_portset_create (v6) failed");
}
result = isc_net_getudpportrange(AF_INET6, &udpport_low, &udpport_high);
if (result != ISC_R_SUCCESS) {
fatal("isc_net_getudpportrange (v6) failed");
}
isc_portset_addrange(v6portset, udpport_low, udpport_high);
result = dns_dispatchmgr_setavailports(manager, v4portset, v6portset);
if (result != ISC_R_SUCCESS) {
fatal("dns_dispatchmgr_setavailports failed");
}
isc_portset_destroy(mctx, &v4portset);
isc_portset_destroy(mctx, &v6portset);
}
/*% Main processing routine for mdig */
int
main(int argc, char *argv[]) {
@@ -2119,6 +2161,8 @@ main(int argc, char *argv[]) {
RUNCHECK(isc_task_create(taskmgr, 0, &task));
RUNCHECK(dns_dispatchmgr_create(mctx, netmgr, &dispatchmgr));
set_source_ports(dispatchmgr);
if (have_ipv4) {
isc_sockaddr_any(&bind_any);
} else {