]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Drop unused portlist code
authorMichal Nowak <mnowak@isc.org>
Mon, 12 Oct 2020 17:21:37 +0000 (19:21 +0200)
committerMichal Nowak <mnowak@isc.org>
Thu, 22 Oct 2020 11:11:16 +0000 (13:11 +0200)
bin/named/server.c
lib/dns/Makefile.am
lib/dns/dispatch.c
lib/dns/include/dns/dispatch.h
lib/dns/include/dns/portlist.h [deleted file]
lib/dns/include/dns/types.h
lib/dns/portlist.c [deleted file]
lib/dns/win32/libdns.def.in
lib/dns/win32/libdns.vcxproj.filters.in
lib/dns/win32/libdns.vcxproj.in
util/copyrights

index b25d258befec3010a33e8fda468d0f5206c2c8b4..db84a2c164ca9f14278e04c311fc9e7cb0d22eb2 100644 (file)
@@ -76,7 +76,6 @@
 #include <dns/nta.h>
 #include <dns/order.h>
 #include <dns/peer.h>
-#include <dns/portlist.h>
 #include <dns/private.h>
 #include <dns/rbt.h>
 #include <dns/rdataclass.h>
index f53debaccf92d836431e5630b546b83b4c35d2b1..78bd453f90005f3c06cecc2ae4d6cf9c5a4889e0 100644 (file)
@@ -105,7 +105,6 @@ libdns_la_HEADERS =                 \
        include/dns/opcode.h            \
        include/dns/order.h             \
        include/dns/peer.h              \
-       include/dns/portlist.h          \
        include/dns/private.h           \
        include/dns/rbt.h               \
        include/dns/rcode.h             \
@@ -211,7 +210,6 @@ libdns_la_SOURCES =                 \
        order.c                         \
        peer.c                          \
        private.c                       \
-       portlist.c                      \
        rbt.c                           \
        rbtdb.h                         \
        rbtdb.c                         \
index 91a392b4a16de07da4a7b2c2404e09e939e5af77..c4265aa5c9282e8537aacb9a89982889b6856a78 100644 (file)
@@ -34,7 +34,6 @@
 #include <dns/events.h>
 #include <dns/log.h>
 #include <dns/message.h>
-#include <dns/portlist.h>
 #include <dns/stats.h>
 #include <dns/tcpmsg.h>
 #include <dns/types.h>
@@ -61,7 +60,6 @@ struct dns_dispatchmgr {
        unsigned int magic;
        isc_mem_t *mctx;
        dns_acl_t *blackhole;
-       dns_portlist_t *portlist;
        isc_stats_t *stats;
 
        /* Locked by "lock". */
@@ -1901,22 +1899,6 @@ dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr) {
        return (mgr->blackhole);
 }
 
-void
-dns_dispatchmgr_setblackportlist(dns_dispatchmgr_t *mgr,
-                                dns_portlist_t *portlist) {
-       REQUIRE(VALID_DISPATCHMGR(mgr));
-       UNUSED(portlist);
-
-       /* This function is deprecated: use dns_dispatchmgr_setavailports(). */
-       return;
-}
-
-dns_portlist_t *
-dns_dispatchmgr_getblackportlist(dns_dispatchmgr_t *mgr) {
-       REQUIRE(VALID_DISPATCHMGR(mgr));
-       return (NULL); /* this function is deprecated */
-}
-
 isc_result_t
 dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
                              isc_portset_t *v6portset) {
index 5e3cc85f02526e636c80cf48e52da30b265e6839..c82b6c6ce4785f0fd420e71d9564c9e2b666a622 100644 (file)
@@ -196,25 +196,6 @@ dns_dispatchmgr_getblackhole(dns_dispatchmgr_t *mgr);
  *\li  A pointer to the current blackhole list, or NULL.
  */
 
-void
-dns_dispatchmgr_setblackportlist(dns_dispatchmgr_t *mgr,
-                                dns_portlist_t *   portlist);
-/*%<
- * This function is deprecated.  Use dns_dispatchmgr_setavailports() instead.
- *
- * Requires:
- *\li  mgr is a valid dispatchmgr
- */
-
-dns_portlist_t *
-dns_dispatchmgr_getblackportlist(dns_dispatchmgr_t *mgr);
-/*%<
- * This function is deprecated and always returns NULL.
- *
- * Requires:
- *\li  mgr is a valid dispatchmgr
- */
-
 isc_result_t
 dns_dispatchmgr_setavailports(dns_dispatchmgr_t *mgr, isc_portset_t *v4portset,
                              isc_portset_t *v6portset);
diff --git a/lib/dns/include/dns/portlist.h b/lib/dns/include/dns/portlist.h
deleted file mode 100644 (file)
index 30705ac..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file dns/portlist.h */
-
-#include <stdbool.h>
-
-#include <isc/lang.h>
-#include <isc/net.h>
-#include <isc/types.h>
-
-#include <dns/types.h>
-
-#ifndef DNS_PORTLIST_H
-#define DNS_PORTLIST_H 1
-
-ISC_LANG_BEGINDECLS
-
-isc_result_t
-dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp);
-/*%<
- * Create a port list.
- *
- * Requires:
- *\li  'mctx' to be valid.
- *\li  'portlistp' to be non NULL and '*portlistp' to be NULL;
- *
- * Returns:
- *\li  #ISC_R_SUCCESS
- *\li  #ISC_R_NOMEMORY
- *\li  #ISC_R_UNEXPECTED
- */
-
-isc_result_t
-dns_portlist_add(dns_portlist_t *portlist, int af, in_port_t port);
-/*%<
- * Add the given <port,af> tuple to the portlist.
- *
- * Requires:
- *\li  'portlist' to be valid.
- *\li  'af' to be AF_INET or AF_INET6
- *
- * Returns:
- *\li  #ISC_R_SUCCESS
- *\li  #ISC_R_NOMEMORY
- */
-
-void
-dns_portlist_remove(dns_portlist_t *portlist, int af, in_port_t port);
-/*%<
- * Remove the given <port,af> tuple to the portlist.
- *
- * Requires:
- *\li  'portlist' to be valid.
- *\li  'af' to be AF_INET or AF_INET6
- */
-
-bool
-dns_portlist_match(dns_portlist_t *portlist, int af, in_port_t port);
-/*%<
- * Find the given <port,af> tuple to the portlist.
- *
- * Requires:
- *\li  'portlist' to be valid.
- *\li  'af' to be AF_INET or AF_INET6
- *
- * Returns
- * \li #true if the tuple is found, false otherwise.
- */
-
-void
-dns_portlist_attach(dns_portlist_t *portlist, dns_portlist_t **portlistp);
-/*%<
- * Attach to a port list.
- *
- * Requires:
- *\li  'portlist' to be valid.
- *\li  'portlistp' to be non NULL and '*portlistp' to be NULL;
- */
-
-void
-dns_portlist_detach(dns_portlist_t **portlistp);
-/*%<
- * Detach from a port list.
- *
- * Requires:
- *\li  '*portlistp' to be valid.
- */
-
-ISC_LANG_ENDDECLS
-
-#endif /* DNS_PORTLIST_H */
index 2a08c31b5f4690cd7d984a4a4f303b869ca26cbb..49e92108bbd76dd526028eec69deb3c363ff3fee 100644 (file)
@@ -116,7 +116,6 @@ typedef unsigned char                 dns_offsets_t[128];
 typedef struct dns_order         dns_order_t;
 typedef struct dns_peer                  dns_peer_t;
 typedef struct dns_peerlist      dns_peerlist_t;
-typedef struct dns_portlist      dns_portlist_t;
 typedef struct dns_rbt           dns_rbt_t;
 typedef uint16_t                 dns_rcode_t;
 typedef struct dns_rdata         dns_rdata_t;
diff --git a/lib/dns/portlist.c b/lib/dns/portlist.c
deleted file mode 100644 (file)
index 5f25be2..0000000
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * Copyright (C) Internet Systems Consortium, Inc. ("ISC")
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, you can obtain one at https://mozilla.org/MPL/2.0/.
- *
- * See the COPYRIGHT file distributed with this work for additional
- * information regarding copyright ownership.
- */
-
-/*! \file */
-
-#include <inttypes.h>
-#include <stdbool.h>
-#include <stdlib.h>
-
-#include <isc/magic.h>
-#include <isc/mem.h>
-#include <isc/mutex.h>
-#include <isc/net.h>
-#include <isc/refcount.h>
-#include <isc/result.h>
-#include <isc/string.h>
-#include <isc/types.h>
-#include <isc/util.h>
-
-#include <dns/portlist.h>
-#include <dns/types.h>
-
-#define DNS_PORTLIST_MAGIC    ISC_MAGIC('P', 'L', 'S', 'T')
-#define DNS_VALID_PORTLIST(p) ISC_MAGIC_VALID(p, DNS_PORTLIST_MAGIC)
-
-typedef struct dns_element {
-       in_port_t port;
-       uint16_t flags;
-} dns_element_t;
-
-struct dns_portlist {
-       unsigned int magic;
-       isc_mem_t *mctx;
-       isc_refcount_t refcount;
-       isc_mutex_t lock;
-       dns_element_t *list;
-       unsigned int allocated;
-       unsigned int active;
-};
-
-#define DNS_PL_INET    0x0001
-#define DNS_PL_INET6   0x0002
-#define DNS_PL_ALLOCATE 16
-
-static int
-compare(const void *arg1, const void *arg2) {
-       const dns_element_t *e1 = (const dns_element_t *)arg1;
-       const dns_element_t *e2 = (const dns_element_t *)arg2;
-
-       if (e1->port < e2->port) {
-               return (-1);
-       }
-       if (e1->port > e2->port) {
-               return (1);
-       }
-       return (0);
-}
-
-isc_result_t
-dns_portlist_create(isc_mem_t *mctx, dns_portlist_t **portlistp) {
-       dns_portlist_t *portlist;
-
-       REQUIRE(portlistp != NULL && *portlistp == NULL);
-
-       portlist = isc_mem_get(mctx, sizeof(*portlist));
-       isc_mutex_init(&portlist->lock);
-       isc_refcount_init(&portlist->refcount, 1);
-       portlist->list = NULL;
-       portlist->allocated = 0;
-       portlist->active = 0;
-       portlist->mctx = NULL;
-       isc_mem_attach(mctx, &portlist->mctx);
-       portlist->magic = DNS_PORTLIST_MAGIC;
-       *portlistp = portlist;
-       return (ISC_R_SUCCESS);
-}
-
-static dns_element_t *
-find_port(dns_element_t *list, unsigned int len, in_port_t port) {
-       unsigned int xtry = len / 2;
-       unsigned int min = 0;
-       unsigned int max = len - 1;
-       unsigned int last = len;
-
-       for (;;) {
-               if (list[xtry].port == port) {
-                       return (&list[xtry]);
-               }
-               if (port > list[xtry].port) {
-                       if (xtry == max) {
-                               break;
-                       }
-                       min = xtry;
-                       xtry = xtry + (max - xtry + 1) / 2;
-                       INSIST(xtry <= max);
-                       if (xtry == last) {
-                               break;
-                       }
-                       last = min;
-               } else {
-                       if (xtry == min) {
-                               break;
-                       }
-                       max = xtry;
-                       xtry = xtry - (xtry - min + 1) / 2;
-                       INSIST(xtry >= min);
-                       if (xtry == last) {
-                               break;
-                       }
-                       last = max;
-               }
-       }
-       return (NULL);
-}
-
-isc_result_t
-dns_portlist_add(dns_portlist_t *portlist, int af, in_port_t port) {
-       dns_element_t *el;
-       isc_result_t result;
-
-       REQUIRE(DNS_VALID_PORTLIST(portlist));
-       REQUIRE(af == AF_INET || af == AF_INET6);
-
-       LOCK(&portlist->lock);
-       if (portlist->active != 0) {
-               el = find_port(portlist->list, portlist->active, port);
-               if (el != NULL) {
-                       if (af == AF_INET) {
-                               el->flags |= DNS_PL_INET;
-                       } else {
-                               el->flags |= DNS_PL_INET6;
-                       }
-                       result = ISC_R_SUCCESS;
-                       goto unlock;
-               }
-       }
-
-       if (portlist->allocated <= portlist->active) {
-               unsigned int allocated;
-               allocated = portlist->allocated + DNS_PL_ALLOCATE;
-               el = isc_mem_get(portlist->mctx, sizeof(*el) * allocated);
-               if (portlist->list != NULL) {
-                       memmove(el, portlist->list,
-                               portlist->allocated * sizeof(*el));
-                       isc_mem_put(portlist->mctx, portlist->list,
-                                   portlist->allocated * sizeof(*el));
-               }
-               portlist->list = el;
-               portlist->allocated = allocated;
-       }
-       portlist->list[portlist->active].port = port;
-       if (af == AF_INET) {
-               portlist->list[portlist->active].flags = DNS_PL_INET;
-       } else {
-               portlist->list[portlist->active].flags = DNS_PL_INET6;
-       }
-       portlist->active++;
-       qsort(portlist->list, portlist->active, sizeof(*el), compare);
-       result = ISC_R_SUCCESS;
-unlock:
-       UNLOCK(&portlist->lock);
-       return (result);
-}
-
-void
-dns_portlist_remove(dns_portlist_t *portlist, int af, in_port_t port) {
-       dns_element_t *el;
-
-       REQUIRE(DNS_VALID_PORTLIST(portlist));
-       REQUIRE(af == AF_INET || af == AF_INET6);
-
-       LOCK(&portlist->lock);
-       if (portlist->active != 0) {
-               el = find_port(portlist->list, portlist->active, port);
-               if (el != NULL) {
-                       if (af == AF_INET) {
-                               el->flags &= ~DNS_PL_INET;
-                       } else {
-                               el->flags &= ~DNS_PL_INET6;
-                       }
-                       if (el->flags == 0) {
-                               *el = portlist->list[portlist->active];
-                               portlist->active--;
-                               qsort(portlist->list, portlist->active,
-                                     sizeof(*el), compare);
-                       }
-               }
-       }
-       UNLOCK(&portlist->lock);
-}
-
-bool
-dns_portlist_match(dns_portlist_t *portlist, int af, in_port_t port) {
-       dns_element_t *el;
-       bool result = false;
-
-       REQUIRE(DNS_VALID_PORTLIST(portlist));
-       REQUIRE(af == AF_INET || af == AF_INET6);
-       LOCK(&portlist->lock);
-       if (portlist->active != 0) {
-               el = find_port(portlist->list, portlist->active, port);
-               if (el != NULL) {
-                       if (af == AF_INET && (el->flags & DNS_PL_INET) != 0) {
-                               result = true;
-                       }
-                       if (af == AF_INET6 && (el->flags & DNS_PL_INET6) != 0) {
-                               result = true;
-                       }
-               }
-       }
-       UNLOCK(&portlist->lock);
-       return (result);
-}
-
-void
-dns_portlist_attach(dns_portlist_t *portlist, dns_portlist_t **portlistp) {
-       REQUIRE(DNS_VALID_PORTLIST(portlist));
-       REQUIRE(portlistp != NULL && *portlistp == NULL);
-
-       isc_refcount_increment(&portlist->refcount);
-       *portlistp = portlist;
-}
-
-void
-dns_portlist_detach(dns_portlist_t **portlistp) {
-       REQUIRE(portlistp != NULL && DNS_VALID_PORTLIST(*portlistp));
-       dns_portlist_t *portlist = *portlistp;
-       *portlistp = NULL;
-
-       if (isc_refcount_decrement(&portlist->refcount) == 1) {
-               portlist->magic = 0;
-               isc_refcount_destroy(&portlist->refcount);
-               if (portlist->list != NULL) {
-                       isc_mem_put(portlist->mctx, portlist->list,
-                                   portlist->allocated *
-                                           sizeof(*portlist->list));
-               }
-               isc_mutex_destroy(&portlist->lock);
-               isc_mem_putanddetach(&portlist->mctx, portlist,
-                                    sizeof(*portlist));
-       }
-}
index 56061f76c0c85f8b6c37d1ab06e7bf81f0358c58..6567fa4ceddadb4a9580c31452cea64507db29f0 100644 (file)
@@ -280,10 +280,8 @@ dns_dispatch_starttcp
 dns_dispatchmgr_create
 dns_dispatchmgr_destroy
 dns_dispatchmgr_getblackhole
-dns_dispatchmgr_getblackportlist
 dns_dispatchmgr_setavailports
 dns_dispatchmgr_setblackhole
-dns_dispatchmgr_setblackportlist
 dns_dispatchmgr_setstats
 dns_dispatchset_cancelall
 dns_dispatchset_create
@@ -733,12 +731,6 @@ dns_peerlist_currpeer
 dns_peerlist_detach
 dns_peerlist_new
 dns_peerlist_peerbyaddr
-dns_portlist_add
-dns_portlist_attach
-dns_portlist_create
-dns_portlist_detach
-dns_portlist_match
-dns_portlist_remove
 dns_private_chains
 dns_private_totext
 dns_rbt_addname
index 7469f7bced09521dee53c44b104f33cf4314db5f..a7de95a273bc4c62c6d66528a8796eac1b7858ea 100644 (file)
     <ClCompile Include="..\peer.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
-    <ClCompile Include="..\portlist.c">
-      <Filter>Library Source Files</Filter>
-    </ClCompile>
     <ClCompile Include="..\private.c">
       <Filter>Library Source Files</Filter>
     </ClCompile>
     <ClInclude Include="..\include\dns\peer.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
-    <ClInclude Include="..\include\dns\portlist.h">
-      <Filter>Library Header Files</Filter>
-    </ClInclude>
     <ClInclude Include="..\include\dns\private.h">
       <Filter>Library Header Files</Filter>
     </ClInclude>
index 644e809c3ca63a6c748be30218280f4d105f73b0..6c9fbd62b8cef533671b5f205e3cc9ecc03e8c1c 100644 (file)
     <ClCompile Include="..\pkcs11eddsa_link.c" />
     <ClCompile Include="..\pkcs11rsa_link.c" />
 @END PKCS11
-    <ClCompile Include="..\portlist.c" />
     <ClCompile Include="..\private.c" />
     <ClCompile Include="..\rbt.c" />
     <ClCompile Include="..\rbtdb.c" />
     <ClInclude Include="..\include\dns\opcode.h" />
     <ClInclude Include="..\include\dns\order.h" />
     <ClInclude Include="..\include\dns\peer.h" />
-    <ClInclude Include="..\include\dns\portlist.h" />
     <ClInclude Include="..\include\dns\private.h" />
     <ClInclude Include="..\include\dns\rbt.h" />
     <ClInclude Include="..\include\dns\rcode.h" />
index 16a47dfcb24d13969de771e3747ffa404b72c031..d9a4420a340feb22aaa965d98fb3334cc777b878 100644 (file)
 ./lib/dns/include/dns/opcode.h                 C       2002,2004,2005,2006,2007,2016,2018,2019,2020
 ./lib/dns/include/dns/order.h                  C       2002,2004,2005,2006,2007,2016,2017,2018,2019,2020
 ./lib/dns/include/dns/peer.h                   C       2000,2001,2003,2004,2005,2006,2007,2008,2009,2013,2014,2015,2016,2017,2018,2019,2020
-./lib/dns/include/dns/portlist.h               C       2003,2004,2005,2006,2007,2016,2018,2019,2020
 ./lib/dns/include/dns/private.h                        C       2009,2011,2012,2016,2018,2019,2020
 ./lib/dns/include/dns/rbt.h                    C       1999,2000,2001,2002,2004,2005,2006,2007,2008,2009,2012,2013,2014,2015,2016,2017,2018,2019,2020
 ./lib/dns/include/dns/rcode.h                  C       1999,2000,2001,2004,2005,2006,2007,2008,2016,2018,2019,2020
 ./lib/dns/pkcs11ecdsa_link.c                   C       2014,2015,2016,2017,2018,2019,2020
 ./lib/dns/pkcs11eddsa_link.c                   C       2017,2018,2019,2020
 ./lib/dns/pkcs11rsa_link.c                     C       2014,2015,2016,2017,2018,2019,2020
-./lib/dns/portlist.c                           C       2003,2004,2005,2006,2007,2014,2016,2018,2019,2020
 ./lib/dns/private.c                            C       2009,2011,2012,2015,2016,2017,2018,2019,2020
 ./lib/dns/rbt.c                                        C       1999,2000,2001,2002,2003,2004,2005,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
 ./lib/dns/rbtdb.c                              C       1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020