mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
Make mdig use the OS-supplied ephemeral port range
mdig was always using the default 1024-65535 range for outgoing messages, instead of using the system's configured ephemeral ports.
This commit is contained in:
3
CHANGES
3
CHANGES
@@ -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]
|
||||
|
@@ -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 {
|
||||
|
Reference in New Issue
Block a user