diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 86db2ef589..080407e0ba 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -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); diff --git a/lib/dns/include/dns/dispatch.h b/lib/dns/include/dns/dispatch.h index 68c6dab91f..e2d910e28f 100644 --- a/lib/dns/include/dns/dispatch.h +++ b/lib/dns/include/dns/dispatch.h @@ -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 /*@}*/ /* diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 649dbc8ef8..6f94d39173 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -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])); } }