From: Ondřej Surý Date: Mon, 4 Oct 2021 12:11:57 +0000 (+0200) Subject: Use system ephemeral ports for default portset X-Git-Tag: v9.17.20~46^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6cd548db0ba6cc706a61be30c2041905312adc25;p=thirdparty%2Fbind9.git Use system ephemeral ports for default portset In dispatch, use system ephemeral ports for default portset instead of hardcoded <1024,65535> range. --- diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 3e0daa02f2c..633915cd30d 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -749,14 +750,18 @@ done: /*% * Create a temporary port list to set the initial default set of dispatch - * ports: [1024, 65535]. This is almost meaningless as the application will + * ephemeral ports. This is almost meaningless as the application will * normally set the ports explicitly, but is provided to fill some minor corner * cases. */ static void -create_default_portset(isc_mem_t *mctx, isc_portset_t **portsetp) { +create_default_portset(isc_mem_t *mctx, int family, isc_portset_t **portsetp) { + in_port_t low, high; + + isc_net_getudpportrange(family, &low, &high); + isc_portset_create(mctx, portsetp); - isc_portset_addrange(*portsetp, 1024, 65535); + isc_portset_addrange(*portsetp, low, high); } static isc_result_t @@ -832,8 +837,8 @@ dns_dispatchmgr_create(isc_mem_t *mctx, isc_nm_t *nm, ISC_LIST_INIT(mgr->list); - create_default_portset(mctx, &v4portset); - create_default_portset(mctx, &v6portset); + create_default_portset(mctx, AF_INET, &v4portset); + create_default_portset(mctx, AF_INET6, &v6portset); setavailports(mgr, v4portset, v6portset);