]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Add isc_nm_socket_type()
authorArtem Boldariev <artem@boldariev.com>
Mon, 15 Nov 2021 15:42:15 +0000 (17:42 +0200)
committerArtem Boldariev <artem@boldariev.com>
Tue, 30 Nov 2021 10:20:22 +0000 (12:20 +0200)
This commit adds an isc_nm_socket_type() function which can be used to
obtain a handle's socket type.

This change obsoletes isc_nm_is_tlsdns_handle() and
isc_nm_is_http_handle(). However, it was decided to keep the latter as
we eventually might end up supporting multiple HTTP versions.

bin/dig/dighost.c
lib/isc/include/isc/netmgr.h
lib/isc/include/isc/types.h
lib/isc/netmgr/netmgr-int.h
lib/isc/netmgr/netmgr.c
lib/ns/query.c

index 62fc949b39dc729ed951595ca6a3dd05c473edce..38f8021ad7d807c42b7f8cbf62984d56f0e0a244 100644 (file)
@@ -3149,7 +3149,7 @@ launch_next_query(dig_query_t *query) {
 
        xfr = query->lookup->rdtype == dns_rdatatype_ixfr ||
              query->lookup->rdtype == dns_rdatatype_axfr;
-       if (xfr && isc_nm_is_tlsdns_handle(query->handle) &&
+       if (xfr && isc_nm_socket_type(query->handle) == isc_nm_tlsdnssocket &&
            !isc_nm_xfr_allowed(query->handle))
        {
                dighost_error("zone transfers over the "
index f662421a55f908e1e8dc81a93ef8dd000f8f7f77..4b17006d2827d3b974b0309c0fbc375ba1894cde 100644 (file)
@@ -500,8 +500,6 @@ isc_nm_tlsdnsconnect(isc_nm_t *mgr, isc_sockaddr_t *local, isc_sockaddr_t *peer,
  * 'cb'.
  */
 
-bool
-isc_nm_is_tlsdns_handle(isc_nmhandle_t *handle);
 /*%<
  * Returns 'true' iff 'handle' is associated with a socket of type
  * 'isc_nm_tlsdnssocket'.
@@ -647,6 +645,15 @@ isc_nm_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl);
  * connection.
  */
 
+isc_nmsocket_type
+isc_nm_socket_type(const isc_nmhandle_t *handle);
+/*%<
+ * Returns the handle's underlying socket type.
+ *
+ * Requires:
+ *  \li 'handle' is a valid netmgr handle object.
+ */
+
 void
 isc_nm_task_enqueue(isc_nm_t *mgr, isc_task_t *task, int threadid);
 /*%<
index b68365cd93cf6f164175f2832ae48c33501f36d8..eb39ed8204545ae1c17907278603bedd70237e1b 100644 (file)
@@ -122,3 +122,23 @@ typedef enum {
        isc_statsformat_xml,
        isc_statsformat_json
 } isc_statsformat_t;
+
+typedef enum isc_nmsocket_type {
+       isc_nm_nonesocket = 0,
+       isc_nm_udpsocket = 1 << 1,
+       isc_nm_tcpsocket = 1 << 2,
+       isc_nm_tcpdnssocket = 1 << 3,
+       isc_nm_tlssocket = 1 << 4,
+       isc_nm_tlsdnssocket = 1 << 5,
+       isc_nm_httpsocket = 1 << 6,
+       isc_nm_maxsocket,
+
+       isc_nm_udplistener, /* Aggregate of nm_udpsocks */
+       isc_nm_tcplistener,
+       isc_nm_tlslistener,
+       isc_nm_tcpdnslistener,
+       isc_nm_tlsdnslistener,
+       isc_nm_httplistener
+} isc_nmsocket_type;
+
+typedef isc_nmsocket_type isc_nmsocket_type_t;
index a281fbde769f3b29dde677846597ed6d1e073ae5..649017e522c17f108e16323d9ea2a88e50adfd6b 100644 (file)
@@ -709,21 +709,6 @@ struct isc_nm {
 #endif
 };
 
-typedef enum isc_nmsocket_type {
-       isc_nm_udpsocket,
-       isc_nm_udplistener, /* Aggregate of nm_udpsocks */
-       isc_nm_tcpsocket,
-       isc_nm_tcplistener,
-       isc_nm_tcpdnslistener,
-       isc_nm_tcpdnssocket,
-       isc_nm_tlslistener,
-       isc_nm_tlssocket,
-       isc_nm_tlsdnslistener,
-       isc_nm_tlsdnssocket,
-       isc_nm_httplistener,
-       isc_nm_httpsocket
-} isc_nmsocket_type;
-
 /*%
  * A universal structure for either a single socket or a group of
  * dup'd/SO_REUSE_PORT-using sockets listening on the same interface.
index e2d57f0ac11ac5cd4cfb80cdfc6d7e3e922d202c..97b9f5bb25f8cecb149dc4ca9e4dd2009b39a764 100644 (file)
@@ -3448,14 +3448,6 @@ isc_nm_xfr_allowed(isc_nmhandle_t *handle) {
        return (false);
 }
 
-bool
-isc_nm_is_tlsdns_handle(isc_nmhandle_t *handle) {
-       REQUIRE(VALID_NMHANDLE(handle));
-       REQUIRE(VALID_NMSOCK(handle->sock));
-
-       return (handle->sock->type == isc_nm_tlsdnssocket);
-}
-
 bool
 isc_nm_is_http_handle(isc_nmhandle_t *handle) {
        REQUIRE(VALID_NMHANDLE(handle));
@@ -3500,6 +3492,14 @@ isc_nm_set_maxage(isc_nmhandle_t *handle, const uint32_t ttl) {
        }
 }
 
+isc_nmsocket_type
+isc_nm_socket_type(const isc_nmhandle_t *handle) {
+       REQUIRE(VALID_NMHANDLE(handle));
+       REQUIRE(VALID_NMSOCK(handle->sock));
+
+       return (handle->sock->type);
+}
+
 #ifdef NETMGR_TRACE
 /*
  * Dump all active sockets in netmgr. We output to stderr
index bf95b49f5a7cc4b473c7f7dd5410088114aeb0fc..71a65d489463649b71692d834fc622c2bdbc7875 100644 (file)
@@ -12064,8 +12064,9 @@ ns_query_start(ns_client_t *client, isc_nmhandle_t *handle) {
                                query_error(client, DNS_R_NOTIMP, __LINE__);
                                return;
                        }
-                       if (isc_nm_is_tlsdns_handle(handle) &&
-                           !isc_nm_xfr_allowed(handle)) {
+                       if (isc_nm_socket_type(handle) == isc_nm_tlsdnssocket &&
+                           !isc_nm_xfr_allowed(handle))
+                       {
                                /*
                                 * Currently this code is here for DoT, which
                                 * has more complex requirements for zone