Merge branch '2060-identify-unused-source-files-via-gcov-ci-job' into 'main'

Resolve "Identify unused source files via gcov CI job"

Closes #2060

See merge request isc-projects/bind9!4261
This commit is contained in:
Michal Nowak 2020-10-22 11:29:04 +00:00
commit 8d5a7cb0dc
21 changed files with 4 additions and 989 deletions

View file

@ -1,3 +1,7 @@
5519. [cleanup] Unused source code was removed: lib/dns/dbtable.c,
lib/dns/portlist.c, lib/isc/bufferlist.c, and code
related to those files. [GL #2060]
5518. [bug] Fix stub zone not transferring nameserver addresses
from masters configured with 'minimal-responses yes'.
[GL #1736]

View file

@ -19,7 +19,6 @@
#include <isc/attributes.h>
#include <isc/buffer.h>
#include <isc/bufferlist.h>
#include <isc/formatcheck.h>
#include <isc/lang.h>
#include <isc/list.h>

View 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>

View file

@ -64,7 +64,6 @@ libdns_la_HEADERS = \
include/dns/compress.h \
include/dns/db.h \
include/dns/dbiterator.h \
include/dns/dbtable.h \
include/dns/diff.h \
include/dns/dispatch.h \
include/dns/dlz.h \
@ -106,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 \
@ -168,7 +166,6 @@ libdns_la_SOURCES = \
compress.c \
db.c \
dbiterator.c \
dbtable.c \
diff.c \
dispatch.c \
dlz.c \
@ -213,7 +210,6 @@ libdns_la_SOURCES = \
order.c \
peer.c \
private.c \
portlist.c \
rbt.c \
rbtdb.h \
rbtdb.c \

View file

@ -1,254 +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.
*/
#include <stdbool.h>
#include <isc/mem.h>
#include <isc/rwlock.h>
#include <isc/util.h>
#include <dns/db.h>
#include <dns/dbtable.h>
#include <dns/rbt.h>
#include <dns/result.h>
struct dns_dbtable {
/* Unlocked. */
unsigned int magic;
isc_mem_t *mctx;
dns_rdataclass_t rdclass;
isc_rwlock_t tree_lock;
/* Protected by atomics */
isc_refcount_t references;
/* Locked by tree_lock. */
dns_rbt_t *rbt;
dns_db_t *default_db;
};
#define DBTABLE_MAGIC ISC_MAGIC('D', 'B', '-', '-')
#define VALID_DBTABLE(dbtable) ISC_MAGIC_VALID(dbtable, DBTABLE_MAGIC)
static void
dbdetach(void *data, void *arg) {
dns_db_t *db = data;
UNUSED(arg);
dns_db_detach(&db);
}
isc_result_t
dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
dns_dbtable_t **dbtablep) {
dns_dbtable_t *dbtable;
isc_result_t result;
REQUIRE(mctx != NULL);
REQUIRE(dbtablep != NULL && *dbtablep == NULL);
dbtable = isc_mem_get(mctx, sizeof(*dbtable));
dbtable->rbt = NULL;
result = dns_rbt_create(mctx, dbdetach, NULL, &dbtable->rbt);
if (result != ISC_R_SUCCESS) {
goto clean1;
}
result = isc_rwlock_init(&dbtable->tree_lock, 0, 0);
if (result != ISC_R_SUCCESS) {
goto clean3;
}
dbtable->default_db = NULL;
dbtable->mctx = NULL;
isc_mem_attach(mctx, &dbtable->mctx);
dbtable->rdclass = rdclass;
dbtable->magic = DBTABLE_MAGIC;
isc_refcount_init(&dbtable->references, 1);
*dbtablep = dbtable;
return (ISC_R_SUCCESS);
clean3:
dns_rbt_destroy(&dbtable->rbt);
clean1:
isc_mem_putanddetach(&mctx, dbtable, sizeof(*dbtable));
return (result);
}
static inline void
dbtable_free(dns_dbtable_t *dbtable) {
/*
* Caller must ensure that it is safe to call.
*/
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
if (dbtable->default_db != NULL) {
dns_db_detach(&dbtable->default_db);
}
dns_rbt_destroy(&dbtable->rbt);
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
isc_rwlock_destroy(&dbtable->tree_lock);
dbtable->magic = 0;
isc_mem_putanddetach(&dbtable->mctx, dbtable, sizeof(*dbtable));
}
void
dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp) {
REQUIRE(VALID_DBTABLE(source));
REQUIRE(targetp != NULL && *targetp == NULL);
isc_refcount_increment(&source->references);
*targetp = source;
}
void
dns_dbtable_detach(dns_dbtable_t **dbtablep) {
dns_dbtable_t *dbtable;
REQUIRE(dbtablep != NULL);
dbtable = *dbtablep;
*dbtablep = NULL;
REQUIRE(VALID_DBTABLE(dbtable));
if (isc_refcount_decrement(&dbtable->references) == 1) {
dbtable_free(dbtable);
}
}
isc_result_t
dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db) {
isc_result_t result;
dns_db_t *dbclone;
REQUIRE(VALID_DBTABLE(dbtable));
REQUIRE(dns_db_class(db) == dbtable->rdclass);
dbclone = NULL;
dns_db_attach(db, &dbclone);
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
result = dns_rbt_addname(dbtable->rbt, dns_db_origin(dbclone), dbclone);
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
return (result);
}
void
dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db) {
dns_db_t *stored_data = NULL;
isc_result_t result;
dns_name_t *name;
REQUIRE(VALID_DBTABLE(dbtable));
name = dns_db_origin(db);
/*
* There is a requirement that the association of name with db
* be verified. With the current rbt.c this is expensive to do,
* because effectively two find operations are being done, but
* deletion is relatively infrequent.
* XXXDCL ... this could be cheaper now with dns_rbt_deletenode.
*/
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
result = dns_rbt_findname(dbtable->rbt, name, 0, NULL,
(void **)(void *)&stored_data);
if (result == ISC_R_SUCCESS) {
INSIST(stored_data == db);
(void)dns_rbt_deletename(dbtable->rbt, name, false);
}
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
}
void
dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db) {
REQUIRE(VALID_DBTABLE(dbtable));
REQUIRE(dbtable->default_db == NULL);
REQUIRE(dns_name_compare(dns_db_origin(db), dns_rootname) == 0);
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
dbtable->default_db = NULL;
dns_db_attach(db, &dbtable->default_db);
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
}
void
dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **dbp) {
REQUIRE(VALID_DBTABLE(dbtable));
REQUIRE(dbp != NULL && *dbp == NULL);
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_read);
dns_db_attach(dbtable->default_db, dbp);
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_read);
}
void
dns_dbtable_removedefault(dns_dbtable_t *dbtable) {
REQUIRE(VALID_DBTABLE(dbtable));
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
dns_db_detach(&dbtable->default_db);
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_write);
}
isc_result_t
dns_dbtable_find(dns_dbtable_t *dbtable, const dns_name_t *name,
unsigned int options, dns_db_t **dbp) {
dns_db_t *stored_data = NULL;
isc_result_t result;
unsigned int rbtoptions = 0;
REQUIRE(dbp != NULL && *dbp == NULL);
if ((options & DNS_DBTABLEFIND_NOEXACT) != 0) {
rbtoptions |= DNS_RBTFIND_NOEXACT;
}
RWLOCK(&dbtable->tree_lock, isc_rwlocktype_read);
result = dns_rbt_findname(dbtable->rbt, name, rbtoptions, NULL,
(void **)(void *)&stored_data);
if (result == ISC_R_SUCCESS || result == DNS_R_PARTIALMATCH) {
dns_db_attach(stored_data, dbp);
} else if (dbtable->default_db != NULL) {
dns_db_attach(dbtable->default_db, dbp);
result = DNS_R_PARTIALMATCH;
} else {
result = ISC_R_NOTFOUND;
}
RWUNLOCK(&dbtable->tree_lock, isc_rwlocktype_read);
return (result);
}

View 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) {

View file

@ -1,157 +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.
*/
#ifndef DNS_DBTABLE_H
#define DNS_DBTABLE_H 1
/*****
***** Module Info
*****/
/*! \file dns/dbtable.h
* \brief
* DNS DB Tables
*
* XXX TBS XXX
*
* MP:
*\li The module ensures appropriate synchronization of data structures it
* creates and manipulates.
*
* Reliability:
*\li No anticipated impact.
*
* Resources:
*\li None.
*
* Security:
*\li No anticipated impact.
*
* Standards:
*\li None.
*/
#include <isc/lang.h>
#include <dns/types.h>
#define DNS_DBTABLEFIND_NOEXACT 0x01
ISC_LANG_BEGINDECLS
isc_result_t
dns_dbtable_create(isc_mem_t *mctx, dns_rdataclass_t rdclass,
dns_dbtable_t **dbtablep);
/*%<
* Make a new dbtable of class 'rdclass'
*
* Requires:
*\li mctx != NULL
* \li dbtablep != NULL && *dptablep == NULL
*\li 'rdclass' is a valid class
*
* Returns:
*\li #ISC_R_SUCCESS
*\li #ISC_R_NOMEMORY
*\li #ISC_R_UNEXPECTED
*/
void
dns_dbtable_attach(dns_dbtable_t *source, dns_dbtable_t **targetp);
/*%<
* Attach '*targetp' to 'source'.
*
* Requires:
*
*\li 'source' is a valid dbtable.
*
*\li 'targetp' points to a NULL dns_dbtable_t *.
*
* Ensures:
*
*\li *targetp is attached to source.
*/
void
dns_dbtable_detach(dns_dbtable_t **dbtablep);
/*%<
* Detach *dbtablep from its dbtable.
*
* Requires:
*
*\li '*dbtablep' points to a valid dbtable.
*
* Ensures:
*
*\li *dbtablep is NULL.
*
*\li If '*dbtablep' is the last reference to the dbtable,
* all resources used by the dbtable will be freed
*/
isc_result_t
dns_dbtable_add(dns_dbtable_t *dbtable, dns_db_t *db);
/*%<
* Add 'db' to 'dbtable'.
*
* Requires:
*\li 'dbtable' is a valid dbtable.
*
*\li 'db' is a valid database with the same class as 'dbtable'
*/
void
dns_dbtable_remove(dns_dbtable_t *dbtable, dns_db_t *db);
/*%<
* Remove 'db' from 'dbtable'.
*
* Requires:
*\li 'db' was previously added to 'dbtable'.
*/
void
dns_dbtable_adddefault(dns_dbtable_t *dbtable, dns_db_t *db);
/*%<
* Use 'db' as the result of a dns_dbtable_find() if no better match is
* available.
*/
void
dns_dbtable_getdefault(dns_dbtable_t *dbtable, dns_db_t **db);
/*%<
* Get the 'db' used as the result of a dns_dbtable_find()
* if no better match is available.
*/
void
dns_dbtable_removedefault(dns_dbtable_t *dbtable);
/*%<
* Remove the default db from 'dbtable'.
*/
isc_result_t
dns_dbtable_find(dns_dbtable_t *dbtable, const dns_name_t *name,
unsigned int options, dns_db_t **dbp);
/*%<
* Find the deepest match to 'name' in the dbtable, and return it
*
* Notes:
*\li If the DNS_DBTABLEFIND_NOEXACT option is set, the best partial
* match (if any) to 'name' will be returned.
*
* Returns:
* \li #ISC_R_SUCCESS on success
*\li something else: no default and match
*/
ISC_LANG_ENDDECLS
#endif /* DNS_DBTABLE_H */

View 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);

View file

@ -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 */

View file

@ -57,7 +57,6 @@ typedef struct dns_dbiterator dns_dbiterator_t;
typedef void dns_dbload_t;
typedef void dns_dbnode_t;
typedef struct dns_dbonupdatelistener dns_dbonupdatelistener_t;
typedef struct dns_dbtable dns_dbtable_t;
typedef void dns_dbversion_t;
typedef struct dns_dlzimplementation dns_dlzimplementation_t;
typedef struct dns_dlzdb dns_dlzdb_t;
@ -117,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;

View file

@ -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));
}
}

View file

@ -240,15 +240,6 @@ dns_dbiterator_pause
dns_dbiterator_prev
dns_dbiterator_seek
dns_dbiterator_setcleanmode
dns_dbtable_add
dns_dbtable_adddefault
dns_dbtable_attach
dns_dbtable_create
dns_dbtable_detach
dns_dbtable_find
dns_dbtable_getdefault
dns_dbtable_remove
dns_dbtable_removedefault
dns_decompress_edns
dns_decompress_getmethods
dns_decompress_init
@ -289,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
@ -742,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

View file

@ -63,9 +63,6 @@
<ClCompile Include="..\dbiterator.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\dbtable.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\diff.c">
<Filter>Library Source Files</Filter>
</ClCompile>
@ -161,9 +158,6 @@
<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>
@ -380,9 +374,6 @@
<ClInclude Include="..\include\dns\dbiterator.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\dns\dbtable.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\dns\diff.h">
<Filter>Library Header Files</Filter>
</ClInclude>
@ -505,9 +496,6 @@
<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>

View file

@ -130,7 +130,6 @@
<ClCompile Include="..\compress.c" />
<ClCompile Include="..\db.c" />
<ClCompile Include="..\dbiterator.c" />
<ClCompile Include="..\dbtable.c" />
<ClCompile Include="..\diff.c" />
<ClCompile Include="..\dispatch.c" />
<ClCompile Include="..\dlz.c" />
@ -184,7 +183,6 @@
<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" />
@ -246,7 +244,6 @@
<ClInclude Include="..\include\dns\compress.h" />
<ClInclude Include="..\include\dns\db.h" />
<ClInclude Include="..\include\dns\dbiterator.h" />
<ClInclude Include="..\include\dns\dbtable.h" />
<ClInclude Include="..\include\dns\diff.h" />
<ClInclude Include="..\include\dns\dispatch.h" />
<ClInclude Include="..\include\dns\dlz.h" />
@ -289,7 +286,6 @@
<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" />

View file

@ -15,7 +15,6 @@ libisc_la_HEADERS = \
include/isc/base64.h \
include/isc/bind9.h \
include/isc/buffer.h \
include/isc/bufferlist.h \
include/isc/cmocka.h \
include/isc/commandline.h \
include/isc/counter.h \
@ -159,7 +158,6 @@ libisc_la_SOURCES = \
base64.c \
bind9.c \
buffer.c \
bufferlist.c \
commandline.c \
counter.c \
crc64.c \

View file

@ -1,54 +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 <stddef.h>
#include <isc/buffer.h>
#include <isc/bufferlist.h>
#include <isc/util.h>
unsigned int
isc_bufferlist_usedcount(isc_bufferlist_t *bl) {
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_usedlength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}
unsigned int
isc_bufferlist_availablecount(isc_bufferlist_t *bl) {
isc_buffer_t *buffer;
unsigned int length;
REQUIRE(bl != NULL);
length = 0;
buffer = ISC_LIST_HEAD(*bl);
while (buffer != NULL) {
REQUIRE(ISC_BUFFER_VALID(buffer));
length += isc_buffer_availablelength(buffer);
buffer = ISC_LIST_NEXT(buffer, link);
}
return (length);
}

View file

@ -1,78 +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.
*/
#ifndef ISC_BUFFERLIST_H
#define ISC_BUFFERLIST_H 1
/*****
***** Module Info
*****/
/*! \file isc/bufferlist.h
*
*
*\brief Buffer lists have no synchronization. Clients must ensure
* exclusive * access.
*
* \li Reliability:
* No anticipated impact.
*
* \li Security:
* No anticipated impact.
*
* \li Standards:
* None.
*/
/***
*** Imports
***/
#include <isc/lang.h>
#include <isc/types.h>
ISC_LANG_BEGINDECLS
/***
*** Functions
***/
unsigned int
isc_bufferlist_usedcount(isc_bufferlist_t *bl);
/*!<
* \brief Return the length of the sum of all used regions of all buffers in
* the buffer list 'bl'
*
* Requires:
*
*\li 'bl' is not NULL.
*
* Returns:
*\li sum of all used regions' lengths.
*/
unsigned int
isc_bufferlist_availablecount(isc_bufferlist_t *bl);
/*!<
* \brief Return the length of the sum of all available regions of all buffers
* in the buffer list 'bl'
*
* Requires:
*
*\li 'bl' is not NULL.
*
* Returns:
*\li sum of all available regions' lengths.
*/
ISC_LANG_ENDDECLS
#endif /* ISC_BUFFERLIST_H */

View file

@ -161,8 +161,6 @@ isc_buffer_putdecint
isc_buffer_reinit
isc_buffer_reserve
isc_buffer_setautorealloc
isc_bufferlist_availablecount
isc_bufferlist_usedcount
isc_commandline_parse
isc_commandline_strtoargv
isc_condition_broadcast

View file

@ -59,9 +59,6 @@
<ClInclude Include="..\include\isc\buffer.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\isc\bufferlist.h">
<Filter>Library Header Files</Filter>
</ClInclude>
<ClInclude Include="..\include\isc\commandline.h">
<Filter>Library Header Files</Filter>
</ClInclude>
@ -470,9 +467,6 @@
<ClCompile Include="..\buffer.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\bufferlist.c">
<Filter>Library Source Files</Filter>
</ClCompile>
<ClCompile Include="..\commandline.c">
<Filter>Library Source Files</Filter>
</ClCompile>

View file

@ -266,7 +266,6 @@ copy InstallFiles ..\Build\Release\
<ClInclude Include="..\include\isc\bind9.h" />
<ClInclude Include="..\include\isc\boolean.h" />
<ClInclude Include="..\include\isc\buffer.h" />
<ClInclude Include="..\include\isc\bufferlist.h" />
<ClInclude Include="..\include\isc\commandline.h" />
<ClInclude Include="..\include\isc\counter.h" />
<ClInclude Include="..\include\isc\crc64.h" />
@ -383,7 +382,6 @@ copy InstallFiles ..\Build\Release\
<ClCompile Include="..\base64.c" />
<ClCompile Include="..\bind9.c" />
<ClCompile Include="..\buffer.c" />
<ClCompile Include="..\bufferlist.c" />
<ClCompile Include="..\commandline.c" />
<ClCompile Include="..\counter.c" />
<ClCompile Include="..\crc64.c" />

View file

@ -1279,7 +1279,6 @@
./lib/dns/compress.c C 1999,2000,2001,2004,2005,2006,2007,2015,2016,2017,2018,2019,2020
./lib/dns/db.c C 1999,2000,2001,2003,2004,2005,2007,2008,2009,2011,2012,2013,2015,2016,2017,2018,2019
./lib/dns/dbiterator.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020
./lib/dns/dbtable.c C 1999,2000,2001,2004,2005,2007,2013,2016,2018,2019,2020
./lib/dns/diff.c C 2000,2001,2002,2003,2004,2005,2007,2008,2009,2011,2013,2014,2015,2016,2017,2018,2019,2020
./lib/dns/dispatch.c C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
./lib/dns/dlz.c C.PORTION 1999,2000,2001,2005,2007,2009,2010,2011,2012,2013,2015,2016,2018,2019,2020
@ -1321,7 +1320,6 @@
./lib/dns/include/dns/compress.h C 1999,2000,2001,2002,2004,2005,2006,2007,2009,2015,2016,2017,2018,2019,2020
./lib/dns/include/dns/db.h C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019
./lib/dns/include/dns/dbiterator.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
./lib/dns/include/dns/dbtable.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
./lib/dns/include/dns/diff.h C 2000,2001,2004,2005,2006,2007,2008,2009,2010,2013,2016,2018,2019,2020
./lib/dns/include/dns/dispatch.h C 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2011,2012,2013,2014,2015,2016,2017,2018,2019,2020
./lib/dns/include/dns/dlz.h C.PORTION 1999,2000,2001,2005,2006,2007,2009,2010,2011,2012,2013,2016,2018,2019,2020
@ -1363,7 +1361,6 @@
./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
@ -1437,7 +1434,6 @@
./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
@ -1763,7 +1759,6 @@
./lib/isc/base64.c C 1998,1999,2000,2001,2003,2004,2005,2007,2009,2013,2014,2015,2016,2018,2019,2020
./lib/isc/bind9.c C 2013,2016,2018,2019,2020
./lib/isc/buffer.c C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2012,2014,2015,2016,2017,2018,2019,2020
./lib/isc/bufferlist.c C 1999,2000,2001,2004,2005,2007,2016,2018,2019,2020
./lib/isc/commandline.c C.PORTION 1999,2000,2001,2004,2005,2007,2008,2014,2015,2016,2018,2019,2020
./lib/isc/counter.c C 2014,2016,2018,2019,2020
./lib/isc/crc64.c C 2013,2016,2018,2019,2020
@ -1792,7 +1787,6 @@
./lib/isc/include/isc/base64.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
./lib/isc/include/isc/bind9.h C 2009,2013,2016,2018,2019,2020
./lib/isc/include/isc/buffer.h C 1998,1999,2000,2001,2002,2004,2005,2006,2007,2008,2010,2012,2014,2016,2017,2018,2019,2020
./lib/isc/include/isc/bufferlist.h C 1999,2000,2001,2004,2005,2006,2007,2016,2018,2019,2020
./lib/isc/include/isc/cmocka.h C 2020
./lib/isc/include/isc/commandline.h C 1999,2000,2001,2004,2005,2006,2007,2015,2016,2018,2019,2020
./lib/isc/include/isc/counter.h C 2014,2016,2018,2019,2020