2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 06:25:31 +00:00

Remove some DNS_DISPATCHATTR flags

- DNS_DISPATCHATTR_CANREUSE was never set. the code that implements it
  has been removed.

- DNS_DISPATCHOPT_FIXEDID and DNS_DISPATCHATTR_FIXEDID were both
  defined, but only the DISPATCHOPT was ever set; it appears the
  DISPATCHATTR was added accidentally.

- DNS_DISPATCHATTR_NOLISTEN was set but never used.
This commit is contained in:
Evan Hunt
2020-12-09 13:00:25 -08:00
committed by Ondřej Surý
parent c69f2018a3
commit 57fce0e895
3 changed files with 7 additions and 46 deletions

View File

@@ -299,7 +299,7 @@ dispatch_free(dns_dispatch_t **dispp);
static isc_result_t
get_udpsocket(dns_dispatchmgr_t *mgr, dns_dispatch_t *disp,
isc_socketmgr_t *sockmgr, const isc_sockaddr_t *localaddr,
isc_socket_t **sockp, isc_socket_t *dup_socket, bool duponly);
isc_socket_t **sockp, isc_socket_t *dup_socket);
static isc_result_t
dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
isc_taskmgr_t *taskmgr, const isc_sockaddr_t *localaddr,
@@ -1499,10 +1499,6 @@ startrecv(dns_dispatch_t *disp, dispsocket_t *dispsock) {
return (ISC_R_SUCCESS);
}
if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) != 0) {
return (ISC_R_SUCCESS);
}
if (disp->recv_pending != 0 && dispsock == NULL) {
return (ISC_R_SUCCESS);
}
@@ -2413,7 +2409,7 @@ dns_dispatch_getudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
static isc_result_t
get_udpsocket(dns_dispatchmgr_t *mgr, dns_dispatch_t *disp,
isc_socketmgr_t *sockmgr, const isc_sockaddr_t *localaddr,
isc_socket_t **sockp, isc_socket_t *dup_socket, bool duponly) {
isc_socket_t **sockp, isc_socket_t *dup_socket) {
unsigned int i, j;
isc_socket_t *held[DNS_DISPATCH_HELD];
isc_sockaddr_t localaddr_bound;
@@ -2473,7 +2469,7 @@ get_udpsocket(dns_dispatchmgr_t *mgr, dns_dispatch_t *disp,
/* Allow to reuse address for non-random ports. */
result = open_socket(sockmgr, localaddr,
ISC_SOCKET_REUSEADDRESS, &sock, dup_socket,
duponly);
true);
if (result == ISC_R_SUCCESS) {
*sockp = sock;
@@ -2530,10 +2526,7 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
dns_dispatch_t *disp;
isc_socket_t *sock = NULL;
int i = 0;
bool duponly = ((attributes & DNS_DISPATCHATTR_CANREUSE) == 0);
/* This is an attribute needed only at creation time */
attributes &= ~DNS_DISPATCHATTR_CANREUSE;
/*
* dispatch_allocate() checks mgr for us.
*/
@@ -2547,7 +2540,7 @@ dispatch_createudp(dns_dispatchmgr_t *mgr, isc_socketmgr_t *sockmgr,
if ((attributes & DNS_DISPATCHATTR_EXCLUSIVE) == 0) {
result = get_udpsocket(mgr, disp, sockmgr, localaddr, &sock,
dup_socket, duponly);
dup_socket);
if (result != ISC_R_SUCCESS) {
goto deallocate_dispatch;
}
@@ -2803,8 +2796,9 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options,
}
/*
* Try somewhat hard to find an unique ID unless FIXEDID is set
* in which case we use the id passed in via *idp.
* Try somewhat hard to find a unique ID, unless
* DNS_DISPATCHOPT_FIXEDID is set, in which case we
* use the ID passed in via *idp.
*/
LOCK(&qid->lock);
if ((options & DNS_DISPATCHOPT_FIXEDID) != 0) {
@@ -2820,9 +2814,6 @@ dns_dispatch_addresponse(dns_dispatch_t *disp, unsigned int options,
ok = true;
break;
}
if ((disp->attributes & DNS_DISPATCHATTR_FIXEDID) != 0) {
break;
}
id += qid->qid_increment;
id &= 0x0000ffff;
} while (i++ < 64);
@@ -3191,9 +3182,6 @@ dns_dispatch_changeattributes(dns_dispatch_t *disp, unsigned int attributes,
REQUIRE(VALID_DISPATCH(disp));
/* Exclusive attribute can only be set on creation */
REQUIRE((attributes & DNS_DISPATCHATTR_EXCLUSIVE) == 0);
/* Also, a dispatch with randomport specified cannot start listening */
REQUIRE((disp->attributes & DNS_DISPATCHATTR_EXCLUSIVE) == 0 ||
(attributes & DNS_DISPATCHATTR_NOLISTEN) == 0);
/* XXXMLG
* Should check for valid attributes here!
@@ -3201,24 +3189,6 @@ dns_dispatch_changeattributes(dns_dispatch_t *disp, unsigned int attributes,
LOCK(&disp->lock);
if ((mask & DNS_DISPATCHATTR_NOLISTEN) != 0) {
if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) != 0 &&
(attributes & DNS_DISPATCHATTR_NOLISTEN) == 0)
{
disp->attributes &= ~DNS_DISPATCHATTR_NOLISTEN;
(void)startrecv(disp, NULL);
} else if ((disp->attributes & DNS_DISPATCHATTR_NOLISTEN) ==
0 &&
(attributes & DNS_DISPATCHATTR_NOLISTEN) != 0)
{
disp->attributes |= DNS_DISPATCHATTR_NOLISTEN;
if (disp->recv_pending != 0) {
isc_socket_cancel(disp->socket, disp->task[0],
ISC_SOCKCANCEL_RECV);
}
}
}
disp->attributes &= ~mask;
disp->attributes |= (attributes & mask);
UNLOCK(&disp->lock);

View File

@@ -115,9 +115,6 @@ struct dns_dispatchset {
* _IPV4, _IPV6
* The dispatcher uses an IPv4 or IPv6 socket.
*
* _NOLISTEN
* The dispatcher should not listen on the socket.
*
* _MAKEQUERY
* The dispatcher can be used to issue queries to other servers, and
* accept replies from them.
@@ -130,12 +127,9 @@ struct dns_dispatchset {
#define DNS_DISPATCHATTR_UDP 0x00000004U
#define DNS_DISPATCHATTR_IPV4 0x00000008U
#define DNS_DISPATCHATTR_IPV6 0x00000010U
#define DNS_DISPATCHATTR_NOLISTEN 0x00000020U
#define DNS_DISPATCHATTR_MAKEQUERY 0x00000040U
#define DNS_DISPATCHATTR_CONNECTED 0x00000080U
#define DNS_DISPATCHATTR_FIXEDID 0x00000100U
#define DNS_DISPATCHATTR_EXCLUSIVE 0x00000200U
#define DNS_DISPATCHATTR_CANREUSE 0x00000400U
/*@}*/
/*

View File

@@ -707,9 +707,6 @@ ns_interface_destroy(ns_interface_t *ifp) {
for (int disp = 0; disp < ifp->nudpdispatch; disp++) {
if (ifp->udpdispatch[disp] != NULL) {
dns_dispatch_changeattributes(
ifp->udpdispatch[disp], 0,
DNS_DISPATCHATTR_NOLISTEN);
dns_dispatch_detach(&(ifp->udpdispatch[disp]));
}
}