]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Remove some DNS_DISPATCHATTR flags
authorEvan Hunt <each@isc.org>
Wed, 9 Dec 2020 21:00:25 +0000 (13:00 -0800)
committerOndřej Surý <ondrej@sury.org>
Sat, 2 Oct 2021 08:21:25 +0000 (10:21 +0200)
- 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.

lib/dns/dispatch.c
lib/dns/include/dns/dispatch.h
lib/ns/interfacemgr.c

index 86db2ef589c4762d33018729bb00ee799a591151..080407e0babc69f6e6126f064ab77ef0cf6a69de 100644 (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);
index 68c6dab91fdf823b99d70f38b7f8a81b86e78194..e2d910e28f0e5bc3033a8abe4847eb8ecfb8de85 100644 (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
 /*@}*/
 
 /*
index 649dbc8ef85e9c58b305b2a1c7f941bf173628ca..6f94d3917399a723dc15b947cc782bd7c7abd145 100644 (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]));
                }
        }