mirror of
https://github.com/isc-projects/bind9.git
synced 2026-06-09 01:12:07 -04:00
use configured source ports for UDP requests
the optional 'port' option, when used with notify-source, transfer-source, etc, is used to set up UDP dispatches with a particular source port, but when the actual UDP connection was established the port would be overridden with a random one. this has been fixed. (configuring source ports is deprecated in 9.20 and slated for removal in 9.22, but should still work correctly until then.)
This commit is contained in:
parent
e46d5d84fc
commit
4d50c912ba
1 changed files with 12 additions and 7 deletions
|
|
@ -385,7 +385,7 @@ setup_socket(dns_dispatch_t *disp, dns_dispentry_t *resp,
|
|||
dns_dispatchmgr_t *mgr = disp->mgr;
|
||||
unsigned int nports;
|
||||
in_port_t *ports = NULL;
|
||||
in_port_t port;
|
||||
in_port_t port = *portp;
|
||||
|
||||
if (resp->retries++ > 5) {
|
||||
return (ISC_R_FAILURE);
|
||||
|
|
@ -405,12 +405,13 @@ setup_socket(dns_dispatch_t *disp, dns_dispentry_t *resp,
|
|||
resp->local = disp->local;
|
||||
resp->peer = *dest;
|
||||
|
||||
port = ports[isc_random_uniform(nports)];
|
||||
isc_sockaddr_setport(&resp->local, port);
|
||||
if (port == 0) {
|
||||
port = ports[isc_random_uniform(nports)];
|
||||
isc_sockaddr_setport(&resp->local, port);
|
||||
*portp = port;
|
||||
}
|
||||
resp->port = port;
|
||||
|
||||
*portp = port;
|
||||
|
||||
return (ISC_R_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -1449,7 +1450,7 @@ dns_dispatch_add(dns_dispatch_t *disp, unsigned int options,
|
|||
dns_dispentry_t **respp) {
|
||||
dns_dispentry_t *resp = NULL;
|
||||
dns_qid_t *qid = NULL;
|
||||
in_port_t localport = 0;
|
||||
in_port_t dispport, localport = 0;
|
||||
dns_messageid_t id;
|
||||
unsigned int bucket;
|
||||
bool ok = false;
|
||||
|
|
@ -1474,8 +1475,12 @@ dns_dispatch_add(dns_dispatch_t *disp, unsigned int options,
|
|||
|
||||
qid = disp->mgr->qid;
|
||||
|
||||
resp = isc_mem_get(disp->mgr->mctx, sizeof(*resp));
|
||||
dispport = isc_sockaddr_getport(&disp->local);
|
||||
if (dispport != 0) {
|
||||
localport = dispport;
|
||||
}
|
||||
|
||||
resp = isc_mem_get(disp->mgr->mctx, sizeof(*resp));
|
||||
*resp = (dns_dispentry_t){
|
||||
.port = localport,
|
||||
.timeout = timeout,
|
||||
|
|
|
|||
Loading…
Reference in a new issue