diff options
| author | 2020-01-09 18:14:47 +0000 | |
|---|---|---|
| committer | 2020-01-09 18:14:47 +0000 | |
| commit | d8522c75c94de2047cbcea221e788dbe519057d5 (patch) | |
| tree | 9a9e67d57996c3824d5d3c0aece5186fbdbf8893 | |
| parent | Rev 1.59 of main.c allows omission of addresses in a range. (diff) | |
| download | wireguard-openbsd-d8522c75c94de2047cbcea221e788dbe519057d5.tar.xz wireguard-openbsd-d8522c75c94de2047cbcea221e788dbe519057d5.zip | |
Nuke atomics support. This gets rid of 4k lines of code including a bunch
of assembly code. It's used for various statistics gathering in the
bind daemon which we won't need in dig etc.
OK millert
63 files changed, 56 insertions, 4188 deletions
diff --git a/usr.sbin/bind/configure b/usr.sbin/bind/configure index 17c996ae18c..13a389458c2 100644 --- a/usr.sbin/bind/configure +++ b/usr.sbin/bind/configure @@ -20350,7 +20350,7 @@ DNS_CRYPTO_LIBS="$NEWFLAGS" # elsewhere if there's a good reason for doing so. # -ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/dig/Makefile lib/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/isc/$arch/Makefile lib/isc/$arch/include/Makefile lib/isc/$arch/include/isc/Makefile lib/isc/nothreads/Makefile lib/isc/nothreads/include/Makefile lib/isc/nothreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/lwres/Makefile" +ac_config_files="$ac_config_files make/Makefile make/mkdep Makefile bin/Makefile bin/dig/Makefile lib/Makefile lib/dns/Makefile lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile lib/isc/nothreads/Makefile lib/isc/nothreads/include/Makefile lib/isc/nothreads/include/isc/Makefile lib/isc/Makefile lib/isc/include/Makefile lib/isc/include/isc/Makefile lib/isc/include/isc/platform.h lib/isc/nls/Makefile lib/isc/unix/Makefile lib/isc/unix/include/Makefile lib/isc/unix/include/isc/Makefile lib/isccfg/Makefile lib/isccfg/include/Makefile lib/isccfg/include/isccfg/Makefile lib/lwres/Makefile" # @@ -21352,9 +21352,6 @@ do "lib/dns/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/dns/include/Makefile" ;; "lib/dns/include/dns/Makefile") CONFIG_FILES="$CONFIG_FILES lib/dns/include/dns/Makefile" ;; "lib/dns/include/dst/Makefile") CONFIG_FILES="$CONFIG_FILES lib/dns/include/dst/Makefile" ;; - "lib/isc/$arch/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/Makefile" ;; - "lib/isc/$arch/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/include/Makefile" ;; - "lib/isc/$arch/include/isc/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/$arch/include/isc/Makefile" ;; "lib/isc/nothreads/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/nothreads/Makefile" ;; "lib/isc/nothreads/include/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/nothreads/include/Makefile" ;; "lib/isc/nothreads/include/isc/Makefile") CONFIG_FILES="$CONFIG_FILES lib/isc/nothreads/include/isc/Makefile" ;; diff --git a/usr.sbin/bind/configure.in b/usr.sbin/bind/configure.in index bd2f8d78895..4f5b7bca340 100644 --- a/usr.sbin/bind/configure.in +++ b/usr.sbin/bind/configure.in @@ -4558,9 +4558,6 @@ AC_CONFIG_FILES([ lib/dns/include/Makefile lib/dns/include/dns/Makefile lib/dns/include/dst/Makefile - lib/isc/$arch/Makefile - lib/isc/$arch/include/Makefile - lib/isc/$arch/include/isc/Makefile lib/isc/nothreads/Makefile lib/isc/nothreads/include/Makefile lib/isc/nothreads/include/isc/Makefile diff --git a/usr.sbin/bind/lib/dns/Makefile.in b/usr.sbin/bind/lib/dns/Makefile.in index faeeb75268b..5b55d92e9fb 100644 --- a/usr.sbin/bind/lib/dns/Makefile.in +++ b/usr.sbin/bind/lib/dns/Makefile.in @@ -72,7 +72,7 @@ DNSOBJS = acache.@O@ acl.@O@ adb.@O@ byaddr.@O@ \ request.@O@ resolver.@O@ result.@O@ rootns.@O@ \ rpz.@O@ rrl.@O@ rriterator.@O@ sdb.@O@ \ sdlz.@O@ soa.@O@ ssu.@O@ ssu_external.@O@ \ - stats.@O@ tcpmsg.@O@ time.@O@ timer.@O@ tkey.@O@ \ + tcpmsg.@O@ time.@O@ timer.@O@ tkey.@O@ \ tsec.@O@ tsig.@O@ ttl.@O@ update.@O@ validator.@O@ \ version.@O@ view.@O@ xfrin.@O@ zone.@O@ zonekey.@O@ zt.@O@ PORTDNSOBJS = client.@O@ ecdb.@O@ @@ -104,7 +104,7 @@ DNSSRCS = acache.c acl.c adb.c byaddr.c \ rdataset.c rdatasetiter.c rdataslab.c request.c \ resolver.c result.c rootns.c rpz.c rrl.c rriterator.c \ sdb.c sdlz.c soa.c ssu.c ssu_external.c \ - stats.c tcpmsg.c time.c timer.c tkey.c \ + tcpmsg.c time.c timer.c tkey.c \ tsec.c tsig.c ttl.c update.c validator.c \ version.c view.c xfrin.c zone.c zonekey.c zt.c ${OTHERSRCS} PORTDNSSRCS = client.c ecdb.c diff --git a/usr.sbin/bind/lib/dns/acache.c b/usr.sbin/bind/lib/dns/acache.c index 8eb17cd154a..74755e5e6e9 100644 --- a/usr.sbin/bind/lib/dns/acache.c +++ b/usr.sbin/bind/lib/dns/acache.c @@ -14,12 +14,12 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: acache.c,v 1.4 2020/01/09 14:24:07 florian Exp $ */ +/* $Id: acache.c,v 1.5 2020/01/09 18:14:48 florian Exp $ */ #include <config.h> #include <stdlib.h> -#include <isc/atomic.h> + #include <isc/event.h> #include <isc/hash.h> #include <isc/magic.h> @@ -45,10 +45,6 @@ #include <dns/result.h> #include <dns/zone.h> -#if defined(ISC_PLATFORM_HAVESTDATOMIC) -#include <stdatomic.h> -#endif - #define ACACHE_MAGIC ISC_MAGIC('A', 'C', 'H', 'E') #define DNS_ACACHE_VALID(acache) ISC_MAGIC_VALID(acache, ACACHE_MAGIC) @@ -85,38 +81,12 @@ #define DEFAULT_ACACHE_ENTRY_LOCK_COUNT 1009 /*%< Should be prime. */ -#if defined(ISC_RWLOCK_USEATOMIC) && \ - ((defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE)) || \ - defined(ISC_PLATFORM_HAVEATOMICSTORE)) -#define ACACHE_USE_RWLOCK 1 -#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE)) -#define ACACHE_HAVESTDATOMIC 1 -#endif -#endif - -#ifdef ACACHE_USE_RWLOCK -#define ACACHE_INITLOCK(l) isc_rwlock_init((l), 0, 0) -#define ACACHE_DESTROYLOCK(l) isc_rwlock_destroy(l) -#define ACACHE_LOCK(l, t) RWLOCK((l), (t)) -#define ACACHE_UNLOCK(l, t) RWUNLOCK((l), (t)) - -#ifdef ACACHE_HAVESTDATOMIC -#define acache_storetime(entry, t) \ - atomic_store_explicit(&(entry)->lastused, (t), \ - memory_order_relaxed); -#else -#define acache_storetime(entry, t) \ - (isc_atomic_store((isc_int32_t *)&(entry)->lastused, (t))) -#endif - -#else #define ACACHE_INITLOCK(l) isc_mutex_init(l) #define ACACHE_DESTROYLOCK(l) DESTROYLOCK(l) #define ACACHE_LOCK(l, t) LOCK(l) #define ACACHE_UNLOCK(l, t) UNLOCK(l) #define acache_storetime(entry, t) ((entry)->lastused = (t)) -#endif /* Locked by acache lock */ typedef struct dbentry { @@ -254,11 +224,7 @@ struct dns_acacheentry { void *cbarg; /* Timestamp of the last time this entry is referred to */ -#ifdef ACACHE_HAVESTDATOMIC - atomic_uint_fast32_t lastused; -#else isc_stdtime32_t lastused; -#endif }; /* diff --git a/usr.sbin/bind/lib/dns/adb.c b/usr.sbin/bind/lib/dns/adb.c index ebfa7e1bde8..586f85e427b 100644 --- a/usr.sbin/bind/lib/dns/adb.c +++ b/usr.sbin/bind/lib/dns/adb.c @@ -32,7 +32,7 @@ #include <isc/netaddr.h> -#include <isc/stats.h> + #include <isc/string.h> /* Required for HP/UX (and others?) */ #include <isc/task.h> #include <isc/util.h> @@ -47,7 +47,7 @@ #include <dns/rdatatype.h> #include <dns/resolver.h> #include <dns/result.h> -#include <dns/stats.h> + #define DNS_ADB_MAGIC ISC_MAGIC('D', 'a', 'd', 'b') #define DNS_ADB_VALID(x) ISC_MAGIC_VALID(x, DNS_ADB_MAGIC) @@ -509,36 +509,6 @@ DP(int level, const char *format, ...) { va_end(args); } -/*% - * Increment resolver-related statistics counters. - */ -static inline void -inc_stats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->resstats != NULL) - isc_stats_increment(adb->view->resstats, counter); -} - -/*% - * Set adb-related statistics counters. - */ -static inline void -set_adbstat(dns_adb_t *adb, isc_uint64_t val, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) - isc_stats_set(adb->view->adbstats, val, counter); -} - -static inline void -dec_adbstats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) - isc_stats_decrement(adb->view->adbstats, counter); -} - -static inline void -inc_adbstats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) - isc_stats_increment(adb->view->adbstats, counter); -} - static inline dns_ttl_t ttlclamp(dns_ttl_t ttl) { if (ttl < ADB_CACHE_MINIMUM) @@ -686,8 +656,6 @@ grow_entries(isc_task_t *task, isc_event_t *ev) { adb->entry_refcnt = newentry_refcnt; adb->nentries = n; - set_adbstat(adb, adb->nentries, dns_adbstats_nentries); - /* * Only on success do we set adb->growentries_sent to ISC_FALSE. * This will prevent us being continuously being called on error. @@ -843,8 +811,6 @@ grow_names(isc_task_t *task, isc_event_t *ev) { adb->name_refcnt = newname_refcnt; adb->nnames = n; - set_adbstat(adb, adb->nnames, dns_adbstats_nnames); - /* * Only on success do we set adb->grownames_sent to ISC_FALSE. * This will prevent us being continuously being called on error. @@ -1712,7 +1678,6 @@ new_adbname(dns_adb_t *adb, dns_name_t *dnsname) { LOCK(&adb->namescntlock); adb->namescnt++; - inc_adbstats(adb, dns_adbstats_namescnt); if (!adb->grownames_sent && adb->excl != NULL && adb->namescnt > (adb->nnames * 8)) { @@ -1748,7 +1713,6 @@ free_adbname(dns_adb_t *adb, dns_adbname_t **name) { isc_mempool_put(adb->nmp, n); LOCK(&adb->namescntlock); adb->namescnt--; - dec_adbstats(adb, dns_adbstats_namescnt); UNLOCK(&adb->namescntlock); } @@ -1860,7 +1824,6 @@ new_adbentry(dns_adb_t *adb) { ISC_LINK_INIT(e, plink); LOCK(&adb->entriescntlock); adb->entriescnt++; - inc_adbstats(adb, dns_adbstats_entriescnt); if (!adb->growentries_sent && adb->excl != NULL && adb->entriescnt > (adb->nentries * 8)) { @@ -1902,7 +1865,6 @@ free_adbentry(dns_adb_t *adb, dns_adbentry_t **entry) { isc_mempool_put(adb->emp, e); LOCK(&adb->entriescntlock); adb->entriescnt--; - dec_adbstats(adb, dns_adbstats_entriescnt); UNLOCK(&adb->entriescntlock); } @@ -2741,13 +2703,6 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_timermgr_t *timermgr, isc_task_setname(adb->task, "ADB", adb); - result = isc_stats_create(adb->mctx, &view->adbstats, dns_adbstats_max); - if (result != ISC_R_SUCCESS) - goto fail3; - - set_adbstat(adb, adb->nentries, dns_adbstats_nentries); - set_adbstat(adb, adb->nnames, dns_adbstats_nnames); - /* * Normal return. */ @@ -3943,7 +3898,6 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { name->fetch_err = FIND_ERR_NXDOMAIN; else name->fetch_err = FIND_ERR_NXRRSET; - inc_stats(adb, dns_resstatscounter_gluefetchv4fail); } else { DP(NCACHE_LEVEL, "adb fetch name %p: " "caching negative entry for AAAA (ttl %u)", @@ -3954,7 +3908,6 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { name->fetch6_err = FIND_ERR_NXDOMAIN; else name->fetch6_err = FIND_ERR_NXRRSET; - inc_stats(adb, dns_resstatscounter_gluefetchv6fail); } goto out; } @@ -4000,11 +3953,9 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { if (address_type == DNS_ADBFIND_INET) { name->expire_v4 = ISC_MIN(name->expire_v4, now + 10); name->fetch_err = FIND_ERR_FAILURE; - inc_stats(adb, dns_resstatscounter_gluefetchv4fail); } else { name->expire_v6 = ISC_MIN(name->expire_v6, now + 10); name->fetch6_err = FIND_ERR_FAILURE; - inc_stats(adb, dns_resstatscounter_gluefetchv6fail); } goto out; } @@ -4092,10 +4043,8 @@ fetch_name(dns_adbname_t *adbname, isc_boolean_t start_at_zone, if (type == dns_rdatatype_a) { adbname->fetch_a = fetch; - inc_stats(adb, dns_resstatscounter_gluefetchv4); } else { adbname->fetch_aaaa = fetch; - inc_stats(adb, dns_resstatscounter_gluefetchv6); } fetch = NULL; /* Keep us from cleaning this up below. */ diff --git a/usr.sbin/bind/lib/dns/cache.c b/usr.sbin/bind/lib/dns/cache.c index 3a537d7a4fa..212f3d91846 100644 --- a/usr.sbin/bind/lib/dns/cache.c +++ b/usr.sbin/bind/lib/dns/cache.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cache.c,v 1.9 2020/01/09 13:47:12 florian Exp $ */ +/* $Id: cache.c,v 1.10 2020/01/09 18:14:48 florian Exp $ */ /*! \file */ @@ -24,7 +24,7 @@ #include <isc/mem.h> #include <isc/string.h> -#include <isc/stats.h> + #include <isc/task.h> #include <isc/time.h> #include <isc/timer.h> @@ -42,7 +42,7 @@ #include <dns/rdataset.h> #include <dns/rdatasetiter.h> #include <dns/result.h> -#include <dns/stats.h> + #include "rbtdb.h" @@ -141,7 +141,6 @@ struct dns_cache { int db_argc; char **db_argv; size_t size; - isc_stats_t *stats; /* Locked by 'filelock'. */ char *filename; @@ -242,16 +241,10 @@ dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, cache->live_tasks = 0; cache->rdclass = rdclass; - cache->stats = NULL; - result = isc_stats_create(cmctx, &cache->stats, - dns_cachestatscounter_max); - if (result != ISC_R_SUCCESS) - goto cleanup_filelock; - cache->db_type = isc_mem_strdup(cmctx, db_type); if (cache->db_type == NULL) { result = ISC_R_NOMEMORY; - goto cleanup_stats; + goto cleanup_lock; } /* @@ -320,11 +313,6 @@ dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, if (result != ISC_R_SUCCESS) goto cleanup_db; - result = dns_db_setcachestats(cache->db, cache->stats); - if (result != ISC_R_SUCCESS) - goto cleanup_db; - - *cachep = cache; return (ISC_R_SUCCESS); @@ -339,10 +327,7 @@ dns_cache_create3(isc_mem_t *cmctx, isc_mem_t *hmctx, isc_taskmgr_t *taskmgr, cache->db_argc * sizeof(char *)); cleanup_dbtype: isc_mem_free(cmctx, cache->db_type); - cleanup_filelock: DESTROYLOCK(&cache->filelock); - cleanup_stats: - isc_stats_detach(&cache->stats); cleanup_lock: DESTROYLOCK(&cache->lock); cleanup_mem: @@ -405,9 +390,6 @@ cache_free(dns_cache_t *cache) { if (cache->name != NULL) isc_mem_free(cache->mctx, cache->name); - if (cache->stats != NULL) - isc_stats_detach(&cache->stats); - DESTROYLOCK(&cache->lock); DESTROYLOCK(&cache->filelock); @@ -1165,7 +1147,6 @@ dns_cache_flush(dns_cache_t *cache) { } olddb = cache->db; cache->db = db; - dns_db_setcachestats(cache->db, cache->stats); UNLOCK(&cache->cleaner.lock); UNLOCK(&cache->lock); @@ -1315,129 +1296,6 @@ dns_cache_flushnode(dns_cache_t *cache, dns_name_t *name, return (result); } -isc_stats_t * -dns_cache_getstats(dns_cache_t *cache) { - REQUIRE(VALID_CACHE(cache)); - return (cache->stats); -} - -void -dns_cache_updatestats(dns_cache_t *cache, isc_result_t result) { - REQUIRE(VALID_CACHE(cache)); - if (cache->stats == NULL) - return; - - switch (result) { - case ISC_R_SUCCESS: - case DNS_R_NCACHENXDOMAIN: - case DNS_R_NCACHENXRRSET: - case DNS_R_CNAME: - case DNS_R_DNAME: - case DNS_R_GLUE: - case DNS_R_ZONECUT: - isc_stats_increment(cache->stats, - dns_cachestatscounter_queryhits); - break; - default: - isc_stats_increment(cache->stats, - dns_cachestatscounter_querymisses); - } -} - -/* - * XXX: Much of the following code has been copied in from statschannel.c. - * We should refactor this into a generic function in stats.c that can be - * called from both places. - */ -typedef struct -cache_dumparg { - isc_statsformat_t type; - void *arg; /* type dependent argument */ - int ncounters; /* for general statistics */ - int *counterindices; /* for general statistics */ - isc_uint64_t *countervalues; /* for general statistics */ - isc_result_t result; -} cache_dumparg_t; - -static void -getcounter(isc_statscounter_t counter, isc_uint64_t val, void *arg) { - cache_dumparg_t *dumparg = arg; - - REQUIRE(counter < dumparg->ncounters); - dumparg->countervalues[counter] = val; -} - -static void -getcounters(isc_stats_t *stats, isc_statsformat_t type, int ncounters, - int *indices, isc_uint64_t *values) -{ - cache_dumparg_t dumparg; - - memset(values, 0, sizeof(values[0]) * ncounters); - - dumparg.type = type; - dumparg.ncounters = ncounters; - dumparg.counterindices = indices; - dumparg.countervalues = values; - - isc_stats_dump(stats, getcounter, &dumparg, ISC_STATSDUMP_VERBOSE); -} - -void -dns_cache_dumpstats(dns_cache_t *cache, FILE *fp) { - int indices[dns_cachestatscounter_max]; - isc_uint64_t values[dns_cachestatscounter_max]; - - REQUIRE(VALID_CACHE(cache)); - - getcounters(cache->stats, isc_statsformat_file, - dns_cachestatscounter_max, indices, values); - - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_hits], - "cache hits"); - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_misses], - "cache misses"); - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_queryhits], - "cache hits (from query)"); - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_querymisses], - "cache misses (from query)"); - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_deletelru], - "cache records deleted due to memory exhaustion"); - fprintf(fp, "%20llu %s\n", - values[dns_cachestatscounter_deletettl], - "cache records deleted due to TTL expiration"); - fprintf(fp, "%20u %s\n", dns_db_nodecount(cache->db), - "cache database nodes"); - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) dns_db_hashsize(cache->db), - "cache database hash buckets"); - - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_total(cache->mctx), - "cache tree memory total"); - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_inuse(cache->mctx), - "cache tree memory in use"); - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_maxinuse(cache->mctx), - "cache tree highest memory in use"); - - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_total(cache->hmctx), - "cache heap memory total"); - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_inuse(cache->hmctx), - "cache heap memory in use"); - fprintf(fp, "%20llu %s\n", - (isc_uint64_t) isc_mem_maxinuse(cache->hmctx), - "cache heap highest memory in use"); -} - #ifdef HAVE_LIBXML2 #define TRY0(a) do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0) static int diff --git a/usr.sbin/bind/lib/dns/dispatch.c b/usr.sbin/bind/lib/dns/dispatch.c index 26527fcc5dd..aba548330b3 100644 --- a/usr.sbin/bind/lib/dns/dispatch.c +++ b/usr.sbin/bind/lib/dns/dispatch.c @@ -30,7 +30,7 @@ #include <isc/socket.h> -#include <isc/stats.h> + #include <isc/string.h> #include <isc/task.h> #include <isc/time.h> @@ -42,7 +42,7 @@ #include <dns/log.h> #include <dns/message.h> #include <dns/portlist.h> -#include <dns/stats.h> + #include <dns/tcpmsg.h> #include <dns/types.h> @@ -347,18 +347,6 @@ mgr_log(dns_dispatchmgr_t *mgr, int level, const char *fmt, ...) { level, "dispatchmgr %p: %s", mgr, msgbuf); } -static inline void -inc_stats(dns_dispatchmgr_t *mgr, isc_statscounter_t counter) { - if (mgr->stats != NULL) - isc_stats_increment(mgr->stats, counter); -} - -static inline void -dec_stats(dns_dispatchmgr_t *mgr, isc_statscounter_t counter) { - if (mgr->stats != NULL) - isc_stats_decrement(mgr->stats, counter); -} - static void dispatch_log(dns_dispatch_t *disp, int level, const char *fmt, ...) ISC_FORMAT_PRINTF(3, 4); @@ -1193,7 +1181,6 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { bucket, (resp == NULL ? "not found" : "found")); if (resp == NULL) { - inc_stats(mgr, dns_resstatscounter_mismatch); free_buffer(disp, ev->region.base, ev->region.length); goto unlock; } @@ -1201,7 +1188,6 @@ udp_recv(isc_event_t *ev_in, dns_dispatch_t *disp, dispsocket_t *dispsock) { &resp->host)) { dispatch_log(disp, LVL(90), "response to an exclusive socket doesn't match"); - inc_stats(mgr, dns_resstatscounter_mismatch); free_buffer(disp, ev->region.base, ev->region.length); goto unlock; } @@ -1654,9 +1640,6 @@ destroy_mgr(dns_dispatchmgr_t **mgrp) { if (mgr->blackhole != NULL) dns_acl_detach(&mgr->blackhole); - if (mgr->stats != NULL) - isc_stats_detach(&mgr->stats); - if (mgr->v4ports != NULL) { isc_mem_put(mctx, mgr->v4ports, mgr->nv4ports * sizeof(in_port_t)); @@ -2104,15 +2087,6 @@ dns_dispatchmgr_destroy(dns_dispatchmgr_t **mgrp) { destroy_mgr(&mgr); } -void -dns_dispatchmgr_setstats(dns_dispatchmgr_t *mgr, isc_stats_t *stats) { - REQUIRE(VALID_DISPATCHMGR(mgr)); - REQUIRE(ISC_LIST_EMPTY(mgr->list)); - REQUIRE(mgr->stats == NULL); - - isc_stats_attach(stats, &mgr->stats); -} - static int port_cmp(const void *key, const void *ent) { in_port_t p1 = *(const in_port_t *)key; @@ -3053,8 +3027,6 @@ dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, oldestresp->item_out = ISC_TRUE; isc_task_send(oldestresp->task, ISC_EVENT_PTR(&rev)); - inc_stats(disp->mgr, - dns_resstatscounter_dispabort); } } @@ -3076,7 +3048,6 @@ dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, &localport); if (result != ISC_R_SUCCESS) { UNLOCK(&disp->lock); - inc_stats(disp->mgr, dns_resstatscounter_dispsockfail); return (result); } } else { @@ -3143,10 +3114,6 @@ dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, ISC_LIST_APPEND(qid->qid_table[bucket], res, link); UNLOCK(&qid->lock); - inc_stats(disp->mgr, (qid == disp->mgr->qid) ? - dns_resstatscounter_disprequdp : - dns_resstatscounter_dispreqtcp); - request_log(disp, res, LVL(90), "attached to task %p", res->task); @@ -3164,10 +3131,6 @@ dns_dispatch_addresponse3(dns_dispatch_t *disp, unsigned int options, disp->refcount--; disp->requests--; - dec_stats(disp->mgr, (qid == disp->mgr->qid) ? - dns_resstatscounter_disprequdp : - dns_resstatscounter_dispreqtcp); - UNLOCK(&disp->lock); isc_task_detach(&res->task); isc_mempool_put(disp->mgr->rpool, res); @@ -3254,9 +3217,6 @@ dns_dispatch_removeresponse(dns_dispentry_t **resp, INSIST(disp->requests > 0); disp->requests--; - dec_stats(disp->mgr, (qid == disp->mgr->qid) ? - dns_resstatscounter_disprequdp : - dns_resstatscounter_dispreqtcp); INSIST(disp->refcount > 0); disp->refcount--; if (disp->refcount == 0) { diff --git a/usr.sbin/bind/lib/dns/dnssec.c b/usr.sbin/bind/lib/dns/dnssec.c index ef8fa4f4ce7..a3f3caa99ad 100644 --- a/usr.sbin/bind/lib/dns/dnssec.c +++ b/usr.sbin/bind/lib/dns/dnssec.c @@ -15,7 +15,7 @@ */ /* - * $Id: dnssec.c,v 1.9 2020/01/09 14:18:29 florian Exp $ + * $Id: dnssec.c,v 1.10 2020/01/09 18:14:48 florian Exp $ */ /*! \file */ @@ -45,13 +45,11 @@ #include <dns/rdataset.h> #include <dns/rdatastruct.h> #include <dns/result.h> -#include <dns/stats.h> + #include <dns/tsig.h> /* for DNS_TSIG_FUDGE */ #include <dst/result.h> -isc_stats_t *dns_dnssec_stats; - #define is_response(msg) (msg->flags & DNS_MESSAGEFLAG_QR) #define RETERR(x) do { \ @@ -81,12 +79,6 @@ digest_callback(void *arg, isc_region_t *data) { return (dst_context_adddata(ctx, data)); } -static inline void -inc_stat(isc_statscounter_t counter) { - if (dns_dnssec_stats != NULL) - isc_stats_increment(dns_dnssec_stats, counter); -} - /* * Make qsort happy. */ @@ -412,7 +404,6 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, return (DNS_R_SIGINVALID); if (isc_serial_lt(sig.timeexpire, sig.timesigned)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGINVALID); } @@ -423,10 +414,8 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, * Is SIG temporally valid? */ if (isc_serial_lt((isc_uint32_t)now, sig.timesigned)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGFUTURE); } else if (isc_serial_lt(sig.timeexpire, (isc_uint32_t)now)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGEXPIRED); } } @@ -440,19 +429,16 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, case dns_rdatatype_soa: case dns_rdatatype_dnskey: if (!dns_name_equal(name, &sig.signer)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGINVALID); } break; case dns_rdatatype_ds: if (dns_name_equal(name, &sig.signer)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGINVALID); } /* FALLTHROUGH */ default: if (!dns_name_issubdomain(name, &sig.signer)) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_SIGINVALID); } break; @@ -463,11 +449,9 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, */ flags = dst_key_flags(key); if (flags & DNS_KEYTYPE_NOAUTH) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_KEYUNAUTHORIZED); } if ((flags & DNS_KEYFLAG_OWNERMASK) != DNS_KEYOWNER_ZONE) { - inc_stat(dns_dnssecstats_fail); return (DNS_R_KEYUNAUTHORIZED); } @@ -566,9 +550,7 @@ dns_dnssec_verify3(dns_name_t *name, dns_rdataset_t *set, dst_key_t *key, DNS_LOGMODULE_DNSSEC, ISC_LOG_DEBUG(1), "successfully validated after lower casing " "signer '%s'", namebuf); - inc_stat(dns_dnssecstats_downcase); - } else if (ret == ISC_R_SUCCESS) - inc_stat(dns_dnssecstats_asis); + } cleanup_array: isc_mem_put(mctx, rdatas, nrdatas * sizeof(dns_rdata_t)); @@ -584,15 +566,11 @@ cleanup_struct: if (ret == DST_R_VERIFYFAILURE) ret = DNS_R_SIGINVALID; - if (ret != ISC_R_SUCCESS) - inc_stat(dns_dnssecstats_fail); - if (ret == ISC_R_SUCCESS && labels - sig.labels > 0) { if (wild != NULL) RUNTIME_CHECK(dns_name_concatenate(dns_wildcardname, dns_fixedname_name(&fnewname), wild, NULL) == ISC_R_SUCCESS); - inc_stat(dns_dnssecstats_wildcard); ret = DNS_R_FROMWILDCARD; } return (ret); diff --git a/usr.sbin/bind/lib/dns/include/dns/Makefile.in b/usr.sbin/bind/lib/dns/include/dns/Makefile.in index ee07ab1faff..76297739c21 100644 --- a/usr.sbin/bind/lib/dns/include/dns/Makefile.in +++ b/usr.sbin/bind/lib/dns/include/dns/Makefile.in @@ -12,7 +12,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: Makefile.in,v 1.4 2020/01/07 19:06:07 florian Exp $ +# $Id: Makefile.in,v 1.5 2020/01/09 18:14:48 florian Exp $ srcdir = @srcdir@ VPATH = @srcdir@ @@ -32,7 +32,7 @@ HEADERS = acache.h acl.h adb.h bit.h byaddr.h cache.h callbacks.h cert.h \ rbt.h rcode.h rdata.h rdataclass.h rdatalist.h \ rdataset.h rdatasetiter.h rdataslab.h rdatatype.h request.h \ resolver.h result.h rootns.h rpz.h rriterator.h rrl.h \ - sdb.h sdlz.h secalg.h secproto.h soa.h ssu.h stats.h \ + sdb.h sdlz.h secalg.h secproto.h soa.h ssu.h \ tcpmsg.h time.h timer.h tkey.h tsec.h tsig.h ttl.h types.h \ update.h validator.h version.h view.h xfrin.h \ zone.h zonekey.h zt.h diff --git a/usr.sbin/bind/lib/dns/include/dns/cache.h b/usr.sbin/bind/lib/dns/include/dns/cache.h index 219439b9dad..08f87bbf990 100644 --- a/usr.sbin/bind/lib/dns/include/dns/cache.h +++ b/usr.sbin/bind/lib/dns/include/dns/cache.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: cache.h,v 1.3 2019/12/17 01:46:32 sthen Exp $ */ +/* $Id: cache.h,v 1.4 2020/01/09 18:14:48 florian Exp $ */ #ifndef DNS_CACHE_H #define DNS_CACHE_H 1 @@ -50,7 +50,7 @@ #include <isc/json.h> #include <isc/lang.h> -#include <isc/stats.h> + #include <isc/stdtime.h> #include <dns/types.h> diff --git a/usr.sbin/bind/lib/dns/include/dns/db.h b/usr.sbin/bind/lib/dns/include/dns/db.h index 42e97085328..e9cc63fc797 100644 --- a/usr.sbin/bind/lib/dns/include/dns/db.h +++ b/usr.sbin/bind/lib/dns/include/dns/db.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: db.h,v 1.6 2019/12/17 01:46:32 sthen Exp $ */ +/* $Id: db.h,v 1.7 2020/01/09 18:14:48 florian Exp $ */ #ifndef DNS_DB_H #define DNS_DB_H 1 @@ -56,7 +56,7 @@ #include <isc/lang.h> #include <isc/magic.h> #include <isc/ondestroy.h> -#include <isc/stats.h> + #include <isc/stdtime.h> #include <dns/clientinfo.h> diff --git a/usr.sbin/bind/lib/dns/include/dns/dnssec.h b/usr.sbin/bind/lib/dns/include/dns/dnssec.h index dedbfabb660..ba65c9b11ba 100644 --- a/usr.sbin/bind/lib/dns/include/dns/dnssec.h +++ b/usr.sbin/bind/lib/dns/include/dns/dnssec.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: dnssec.h,v 1.4 2020/01/09 14:18:29 florian Exp $ */ +/* $Id: dnssec.h,v 1.5 2020/01/09 18:14:48 florian Exp $ */ #ifndef DNS_DNSSEC_H #define DNS_DNSSEC_H 1 @@ -23,7 +23,7 @@ #include <isc/lang.h> #include <isc/stdtime.h> -#include <isc/stats.h> + #include <dns/diff.h> #include <dns/types.h> diff --git a/usr.sbin/bind/lib/dns/include/dns/rbt.h b/usr.sbin/bind/lib/dns/include/dns/rbt.h index 1ccb03b53c5..d4df33f37a8 100644 --- a/usr.sbin/bind/lib/dns/include/dns/rbt.h +++ b/usr.sbin/bind/lib/dns/include/dns/rbt.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rbt.h,v 1.3 2019/12/17 01:46:32 sthen Exp $ */ +/* $Id: rbt.h,v 1.4 2020/01/09 18:14:48 florian Exp $ */ #ifndef DNS_RBT_H #define DNS_RBT_H 1 @@ -45,9 +45,6 @@ ISC_LANG_BEGINDECLS /*@}*/ #ifndef DNS_RBT_USEISCREFCOUNT -#ifdef ISC_REFCOUNT_HAVEATOMIC -#define DNS_RBT_USEISCREFCOUNT 1 -#endif #endif #define DNS_RBT_USEMAGIC 1 diff --git a/usr.sbin/bind/lib/dns/include/dns/resolver.h b/usr.sbin/bind/lib/dns/include/dns/resolver.h index f218ca661dd..203e5b8d589 100644 --- a/usr.sbin/bind/lib/dns/include/dns/resolver.h +++ b/usr.sbin/bind/lib/dns/include/dns/resolver.h @@ -51,7 +51,7 @@ #include <isc/lang.h> #include <isc/socket.h> -#include <isc/stats.h> + #include <dns/types.h> #include <dns/fixedname.h> diff --git a/usr.sbin/bind/lib/dns/include/dns/stats.h b/usr.sbin/bind/lib/dns/include/dns/stats.h deleted file mode 100644 index f65298cb36f..00000000000 --- a/usr.sbin/bind/lib/dns/include/dns/stats.h +++ /dev/null @@ -1,419 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stats.h,v 1.4 2020/01/09 14:18:29 florian Exp $ */ - -#ifndef DNS_STATS_H -#define DNS_STATS_H 1 - -/*! \file dns/stats.h */ - -#include <dns/types.h> - -/*% - * Statistics counters. Used as isc_statscounter_t values. - */ -enum { - /*% - * Resolver statistics counters. - */ - dns_resstatscounter_queryv4 = 0, - dns_resstatscounter_queryv6 = 1, - dns_resstatscounter_responsev4 = 2, - dns_resstatscounter_responsev6 = 3, - dns_resstatscounter_nxdomain = 4, - dns_resstatscounter_servfail = 5, - dns_resstatscounter_formerr = 6, - dns_resstatscounter_othererror = 7, - dns_resstatscounter_edns0fail = 8, - dns_resstatscounter_mismatch = 9, - dns_resstatscounter_truncated = 10, - dns_resstatscounter_lame = 11, - dns_resstatscounter_retry = 12, - dns_resstatscounter_gluefetchv4 = 13, - dns_resstatscounter_gluefetchv6 = 14, - dns_resstatscounter_gluefetchv4fail = 15, - dns_resstatscounter_gluefetchv6fail = 16, - dns_resstatscounter_val = 17, - dns_resstatscounter_valsuccess = 18, - dns_resstatscounter_valnegsuccess = 19, - dns_resstatscounter_valfail = 20, - dns_resstatscounter_dispabort = 21, - dns_resstatscounter_dispsockfail = 22, - dns_resstatscounter_querytimeout = 23, - dns_resstatscounter_queryrtt0 = 24, - dns_resstatscounter_queryrtt1 = 25, - dns_resstatscounter_queryrtt2 = 26, - dns_resstatscounter_queryrtt3 = 27, - dns_resstatscounter_queryrtt4 = 28, - dns_resstatscounter_queryrtt5 = 29, - dns_resstatscounter_nfetch = 30, - dns_resstatscounter_disprequdp = 31, - dns_resstatscounter_dispreqtcp = 32, - dns_resstatscounter_buckets = 33, - dns_resstatscounter_refused = 34, - dns_resstatscounter_sitcc = 35, - dns_resstatscounter_sitout = 36, - dns_resstatscounter_sitin = 37, - dns_resstatscounter_sitok = 38, - dns_resstatscounter_badvers = 39, - dns_resstatscounter_zonequota = 40, - dns_resstatscounter_serverquota = 41, - dns_resstatscounter_max = 42, - - /* - * DNSSEC stats. - */ - dns_dnssecstats_asis = 0, - dns_dnssecstats_downcase = 1, - dns_dnssecstats_wildcard = 2, - dns_dnssecstats_fail = 3, - - dns_dnssecstats_max = 4, - - /*% - * Zone statistics counters. - */ - dns_zonestatscounter_notifyoutv4 = 0, - dns_zonestatscounter_notifyoutv6 = 1, - dns_zonestatscounter_notifyinv4 = 2, - dns_zonestatscounter_notifyinv6 = 3, - dns_zonestatscounter_notifyrej = 4, - dns_zonestatscounter_soaoutv4 = 5, - dns_zonestatscounter_soaoutv6 = 6, - dns_zonestatscounter_axfrreqv4 = 7, - dns_zonestatscounter_axfrreqv6 = 8, - dns_zonestatscounter_ixfrreqv4 = 9, - dns_zonestatscounter_ixfrreqv6 = 10, - dns_zonestatscounter_xfrsuccess = 11, - dns_zonestatscounter_xfrfail = 12, - - dns_zonestatscounter_max = 13, - - /* - * Adb statistics values. - */ - dns_adbstats_nentries = 0, - dns_adbstats_entriescnt = 1, - dns_adbstats_nnames = 2, - dns_adbstats_namescnt = 3, - - dns_adbstats_max = 4, - - /* - * Cache statistics values. - */ - dns_cachestatscounter_hits = 1, - dns_cachestatscounter_misses = 2, - dns_cachestatscounter_queryhits = 3, - dns_cachestatscounter_querymisses = 4, - dns_cachestatscounter_deletelru = 5, - dns_cachestatscounter_deletettl = 6, - - dns_cachestatscounter_max = 7, - - /*% - * Query statistics counters (obsolete). - */ - dns_statscounter_success = 0, /*%< Successful lookup */ - dns_statscounter_referral = 1, /*%< Referral result */ - dns_statscounter_nxrrset = 2, /*%< NXRRSET result */ - dns_statscounter_nxdomain = 3, /*%< NXDOMAIN result */ - dns_statscounter_recursion = 4, /*%< Recursion was used */ - dns_statscounter_failure = 5, /*%< Some other failure */ - dns_statscounter_duplicate = 6, /*%< Duplicate query */ - dns_statscounter_dropped = 7 /*%< Duplicate query (dropped) */ -}; - -#define DNS_STATS_NCOUNTERS 8 - -#if 0 -/*%< - * Flag(s) for dns_xxxstats_dump(). DNS_STATSDUMP_VERBOSE is obsolete. - * ISC_STATSDUMP_VERBOSE should be used instead. These two values are - * intentionally defined to be the same value to ensure binary compatibility. - */ -#define DNS_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */ -#endif - -/*%< - * (Obsoleted) - */ -extern const char *dns_statscounter_names[]; - -/*% - * Attributes for statistics counters of RRset and Rdatatype types. - * - * _OTHERTYPE - * The rdata type is not explicitly supported and the corresponding counter - * is counted for other such types, too. When this attribute is set, - * the base type is of no use. - * - * _NXRRSET - * RRset type counters only. Indicates the RRset is non existent. - * - * _NXDOMAIN - * RRset type counters only. Indicates a non existent name. When this - * attribute is set, the base type is of no use. - * - * _STALE - * RRset type counters only. This indicates a record that marked for - * removal. - * - * Note: incrementing _STALE will decrement the corresponding non-stale - * counter. - */ -#define DNS_RDATASTATSTYPE_ATTR_OTHERTYPE 0x0001 -#define DNS_RDATASTATSTYPE_ATTR_NXRRSET 0x0002 -#define DNS_RDATASTATSTYPE_ATTR_NXDOMAIN 0x0004 -#define DNS_RDATASTATSTYPE_ATTR_STALE 0x0008 - -/*%< - * Conversion macros among dns_rdatatype_t, attributes and isc_statscounter_t. - */ -#define DNS_RDATASTATSTYPE_BASE(type) ((dns_rdatatype_t)((type) & 0xFFFF)) -#define DNS_RDATASTATSTYPE_ATTR(type) ((type) >> 16) -#define DNS_RDATASTATSTYPE_VALUE(b, a) (((a) << 16) | (b)) - -/*%< - * Types of dump callbacks. - */ -typedef void (*dns_generalstats_dumper_t)(isc_statscounter_t, isc_uint64_t, - void *); -typedef void (*dns_rdatatypestats_dumper_t)(dns_rdatastatstype_t, isc_uint64_t, - void *); -typedef void (*dns_opcodestats_dumper_t)(dns_opcode_t, isc_uint64_t, void *); - -ISC_LANG_BEGINDECLS - -isc_result_t -dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters); -/*%< - * Create a statistics counter structure of general type. It counts a general - * set of counters indexed by an ID between 0 and ncounters -1. - * This function is obsolete. A more general function, isc_stats_create(), - * should be used. - * - * Requires: - *\li 'mctx' must be a valid memory context. - * - *\li 'statsp' != NULL && '*statsp' == NULL. - * - * Returns: - *\li ISC_R_SUCCESS -- all ok - * - *\li anything else -- failure - */ - -isc_result_t -dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp); -/*%< - * Create a statistics counter structure per rdatatype. - * - * Requires: - *\li 'mctx' must be a valid memory context. - * - *\li 'statsp' != NULL && '*statsp' == NULL. - * - * Returns: - *\li ISC_R_SUCCESS -- all ok - * - *\li anything else -- failure - */ - -isc_result_t -dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp); -/*%< - * Create a statistics counter structure per RRset. - * - * Requires: - *\li 'mctx' must be a valid memory context. - * - *\li 'statsp' != NULL && '*statsp' == NULL. - * - * Returns: - *\li ISC_R_SUCCESS -- all ok - * - *\li anything else -- failure - */ - -isc_result_t -dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp); -/*%< - * Create a statistics counter structure per opcode. - * - * Requires: - *\li 'mctx' must be a valid memory context. - * - *\li 'statsp' != NULL && '*statsp' == NULL. - * - * Returns: - *\li ISC_R_SUCCESS -- all ok - * - *\li anything else -- failure - */ - -void -dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp); -/*%< - * Attach to a statistics set. - * - * Requires: - *\li 'stats' is a valid dns_stats_t. - * - *\li 'statsp' != NULL && '*statsp' == NULL - */ - -void -dns_stats_detach(dns_stats_t **statsp); -/*%< - * Detaches from the statistics set. - * - * Requires: - *\li 'statsp' != NULL and '*statsp' is a valid dns_stats_t. - */ - -void -dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter); -/*%< - * Increment the counter-th counter of stats. This function is obsolete. - * A more general function, isc_stats_increment(), should be used. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). - * - *\li counter is less than the maximum available ID for the stats specified - * on creation. - */ - -void -dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type); -/*%< - * Increment the statistics counter for 'type'. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_rdatatypestats_create(). - */ - -void -dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype); -/*%< - * Increment the statistics counter for 'rrsettype'. - * - * Note: if 'rrsettype' has the _STALE attribute set the corresponding - * non-stale counter will be decremented. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create(). - */ - -void -dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype); -/*%< - * Decrement the statistics counter for 'rrsettype'. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_rdatasetstats_create(). - */ - -void -dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code); -/*%< - * Increment the statistics counter for 'code'. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_opcodestats_create(). - */ - -void -dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn, - void *arg, unsigned int options); -/*%< - * Dump the current statistics counters in a specified way. For each counter - * in stats, dump_fn is called with its current value and the given argument - * arg. By default counters that have a value of 0 is skipped; if options has - * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. - * - * This function is obsolete. A more general function, isc_stats_dump(), - * should be used. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). - */ - -void -dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, - void *arg, unsigned int options); -/*%< - * Dump the current statistics counters in a specified way. For each counter - * in stats, dump_fn is called with the corresponding type in the form of - * dns_rdatastatstype_t, the current counter value and the given argument - * arg. By default counters that have a value of 0 is skipped; if options has - * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). - */ - -void -dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, - void *arg, unsigned int options); -/*%< - * Dump the current statistics counters in a specified way. For each counter - * in stats, dump_fn is called with the corresponding type in the form of - * dns_rdatastatstype_t, the current counter value and the given argument - * arg. By default counters that have a value of 0 is skipped; if options has - * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). - */ - -void -dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn, - void *arg, unsigned int options); -/*%< - * Dump the current statistics counters in a specified way. For each counter - * in stats, dump_fn is called with the corresponding opcode, the current - * counter value and the given argument arg. By default counters that have a - * value of 0 is skipped; if options has the ISC_STATSDUMP_VERBOSE flag, even - * such counters are dumped. - * - * Requires: - *\li 'stats' is a valid dns_stats_t created by dns_generalstats_create(). - */ - -isc_result_t -dns_stats_alloccounters(isc_mem_t *mctx, isc_uint64_t **ctrp); -/*%< - * Allocate an array of query statistics counters from the memory - * context 'mctx'. - * - * This function is obsoleted. Use dns_xxxstats_create() instead. - */ - -void -dns_stats_freecounters(isc_mem_t *mctx, isc_uint64_t **ctrp); -/*%< - * Free an array of query statistics counters allocated from the memory - * context 'mctx'. - * - * This function is obsoleted. Use dns_stats_destroy() instead. - */ - -ISC_LANG_ENDDECLS - -#endif /* DNS_STATS_H */ diff --git a/usr.sbin/bind/lib/dns/rbtdb.c b/usr.sbin/bind/lib/dns/rbtdb.c index 9b331ecf99b..a125e4c43a9 100644 --- a/usr.sbin/bind/lib/dns/rbtdb.c +++ b/usr.sbin/bind/lib/dns/rbtdb.c @@ -69,7 +69,7 @@ #include <dns/rdataslab.h> #include <dns/rdatastruct.h> #include <dns/result.h> -#include <dns/stats.h> + #include <dns/time.h> #include <dns/version.h> #include <dns/view.h> @@ -216,7 +216,6 @@ typedef isc_uint64_t rbtdb_serial_t; #define free_rdataset free_rdataset64 #define getnsec3parameters getnsec3parameters64 #define getoriginnode getoriginnode64 -#define getrrsetstats getrrsetstats64 #define getsigningtime getsigningtime64 #define getsize getsize64 #define hashsize hashsize64 @@ -278,18 +277,15 @@ typedef isc_uint64_t rbtdb_serial_t; #define serialize serialize64 #define set_index set_index64 #define set_ttl set_ttl64 -#define setcachestats setcachestats64 #define setnsec3parameters setnsec3parameters64 #define setsigningtime setsigningtime64 #define settask settask64 #define setup_delegation setup_delegation64 #define subtractrdataset subtractrdataset64 #define ttl_sooner ttl_sooner64 -#define update_cachestats update_cachestats64 #define update_header update_header64 #define update_newheader update_newheader64 #define update_recordsandbytes update_recordsandbytes64 -#define update_rrsetstats update_rrsetstats64 #define valid_glue valid_glue64 #define zone_find zone_find64 #define zone_findrdataset zone_findrdataset64 @@ -329,11 +325,7 @@ typedef isc_uint32_t rbtdb_rdatatype_t; * would require more memory or can even make lookups slower due to its own * overhead (when it internally calls mutex locks). */ -#ifdef ISC_RWLOCK_USEATOMIC -#define DNS_RBTDB_USERWLOCK 1 -#else #define DNS_RBTDB_USERWLOCK 0 -#endif #if DNS_RBTDB_USERWLOCK #define RBTDB_INITLOCK(l) isc_rwlock_init((l), 0, 0) @@ -366,21 +358,6 @@ typedef isc_uint32_t rbtdb_rdatatype_t; * Note that we cannot use NODE_LOCK()/NODE_UNLOCK() wherever the protected * section is also protected by NODE_STRONGLOCK(). */ -#if defined(ISC_RWLOCK_USEATOMIC) && defined(DNS_RBT_USEISCREFCOUNT) -typedef isc_rwlock_t nodelock_t; - -#define NODE_INITLOCK(l) isc_rwlock_init((l), 0, 0) -#define NODE_DESTROYLOCK(l) isc_rwlock_destroy(l) -#define NODE_LOCK(l, t) RWLOCK((l), (t)) -#define NODE_UNLOCK(l, t) RWUNLOCK((l), (t)) -#define NODE_TRYUPGRADE(l) isc_rwlock_tryupgrade(l) - -#define NODE_STRONGLOCK(l) ((void)0) -#define NODE_STRONGUNLOCK(l) ((void)0) -#define NODE_WEAKLOCK(l, t) NODE_LOCK(l, t) -#define NODE_WEAKUNLOCK(l, t) NODE_UNLOCK(l, t) -#define NODE_WEAKDOWNGRADE(l) isc_rwlock_downgrade(l) -#else typedef isc_mutex_t nodelock_t; #define NODE_INITLOCK(l) isc_mutex_init(l) @@ -394,7 +371,6 @@ typedef isc_mutex_t nodelock_t; #define NODE_WEAKLOCK(l, t) ((void)0) #define NODE_WEAKUNLOCK(l, t) ((void)0) #define NODE_WEAKDOWNGRADE(l) ((void)0) -#endif /*% * Whether to rate-limit updating the LRU to avoid possible thread contention. @@ -649,8 +625,6 @@ struct dns_rbtdb { rbtdb_nodelock_t * node_locks; dns_rbtnode_t * origin_node; dns_rbtnode_t * nsec3_origin_node; - dns_stats_t * rrsetstats; /* cache DB only */ - isc_stats_t * cachestats; /* cache DB only */ /* Locked by lock. */ unsigned int active; isc_refcount_t references; @@ -989,60 +963,6 @@ free_rbtdb_callback(isc_task_t *task, isc_event_t *event) { } static void -update_cachestats(dns_rbtdb_t *rbtdb, isc_result_t result) { - INSIST(IS_CACHE(rbtdb)); - - if (rbtdb->cachestats == NULL) - return; - - switch (result) { - case ISC_R_SUCCESS: - case DNS_R_CNAME: - case DNS_R_DNAME: - case DNS_R_DELEGATION: - case DNS_R_NCACHENXDOMAIN: - case DNS_R_NCACHENXRRSET: - isc_stats_increment(rbtdb->cachestats, - dns_cachestatscounter_hits); - break; - default: - isc_stats_increment(rbtdb->cachestats, - dns_cachestatscounter_misses); - } -} - -static void -update_rrsetstats(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, - isc_boolean_t increment) -{ - dns_rdatastatstype_t statattributes = 0; - dns_rdatastatstype_t base = 0; - dns_rdatastatstype_t type; - - /* At the moment we count statistics only for cache DB */ - INSIST(IS_CACHE(rbtdb)); - - if (NEGATIVE(header)) { - if (NXDOMAIN(header)) - statattributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN; - else { - statattributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET; - base = RBTDB_RDATATYPE_EXT(header->type); - } - } else - base = RBTDB_RDATATYPE_BASE(header->type); - - if (STALE(header)) - statattributes |= DNS_RDATASTATSTYPE_ATTR_STALE; - - type = DNS_RDATASTATSTYPE_VALUE(base, statattributes); - if (increment) - dns_rdatasetstats_increment(rbtdb->rrsetstats, type); - else - dns_rdatasetstats_decrement(rbtdb->rrsetstats, type); -} - -static void set_ttl(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, dns_ttl_t newttl) { int idx; isc_heap_t *heap; @@ -1289,11 +1209,6 @@ free_rbtdb(dns_rbtdb_t *rbtdb, isc_boolean_t log, isc_event_t *event) { rbtdb->node_lock_count * sizeof(isc_heap_t *)); } - if (rbtdb->rrsetstats != NULL) - dns_stats_detach(&rbtdb->rrsetstats); - if (rbtdb->cachestats != NULL) - isc_stats_detach(&rbtdb->cachestats); - if (rbtdb->load_rpzs != NULL) { /* * We must be cleaning up after a failed zone loading. @@ -1646,11 +1561,6 @@ free_rdataset(dns_rbtdb_t *rbtdb, isc_mem_t *mctx, rdatasetheader_t *rdataset) { unsigned int size; int idx; - if (EXISTS(rdataset) && - (rdataset->attributes & RDATASET_ATTR_STATCOUNT) != 0) { - update_rrsetstats(rbtdb, rdataset, ISC_FALSE); - } - idx = rdataset->node->locknum; if (ISC_LINK_LINKED(rdataset, link)) { INSIST(IS_CACHE(rbtdb)); @@ -1716,6 +1626,8 @@ rollback_node(dns_rbtnode_t *node, rbtdb_serial_t serial) { static inline void mark_stale_header(dns_rbtdb_t *rbtdb, rdatasetheader_t *header) { + UNUSED(rbtdb); + /* * If we are already stale there is nothing to do. */ @@ -1731,8 +1643,6 @@ mark_stale_header(dns_rbtdb_t *rbtdb, rdatasetheader_t *header) { if ((header->attributes & RDATASET_ATTR_STATCOUNT) == 0) return; - if (EXISTS(header)) - update_rrsetstats(rbtdb, header, ISC_TRUE); } static inline void @@ -4607,9 +4517,7 @@ check_stale_header(dns_rbtnode_t *node, rdatasetheader_t *header, rbtdb_search_t *search, rdatasetheader_t **header_prev) { -#if !defined(ISC_RWLOCK_USEATOMIC) || !defined(DNS_RBT_USEISCREFCOUNT) UNUSED(lock); -#endif if (!ACTIVE(header, search->now)) { /* @@ -5293,7 +5201,6 @@ cache_find(dns_db_t *db, dns_name_t *name, dns_dbversion_t *version, dns_rbtnodechain_reset(&search.chain); - update_cachestats(search.rbtdb, result); return (result); } @@ -5868,8 +5775,6 @@ cache_findrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, result = DNS_R_NCACHENXRRSET; } - update_cachestats(rbtdb, result); - return (result); } @@ -6834,11 +6739,6 @@ addrdataset(dns_db_t *db, dns_dbnode_t *node, dns_dbversion_t *version, NODE_LOCK(&rbtdb->node_locks[rbtnode->locknum].lock, isc_rwlocktype_write); - if (rbtdb->rrsetstats != NULL) { - newheader->attributes |= RDATASET_ATTR_STATCOUNT; - update_rrsetstats(rbtdb, newheader, ISC_TRUE); - } - if (IS_CACHE(rbtdb)) { if (tree_locked) cleanup_dead_nodes(rbtdb, rbtnode->locknum); @@ -8221,28 +8121,6 @@ resigned(dns_db_t *db, dns_rdataset_t *rdataset, dns_dbversion_t *version) RWUNLOCK(&rbtdb->tree_lock, isc_rwlocktype_write); } -static isc_result_t -setcachestats(dns_db_t *db, isc_stats_t *stats) { - dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db; - - REQUIRE(VALID_RBTDB(rbtdb)); - REQUIRE(IS_CACHE(rbtdb)); /* current restriction */ - REQUIRE(stats != NULL); - - isc_stats_attach(stats, &rbtdb->cachestats); - return (ISC_R_SUCCESS); -} - -static dns_stats_t * -getrrsetstats(dns_db_t *db) { - dns_rbtdb_t *rbtdb = (dns_rbtdb_t *)db; - - REQUIRE(VALID_RBTDB(rbtdb)); - REQUIRE(IS_CACHE(rbtdb)); /* current restriction */ - - return (rbtdb->rrsetstats); -} - static dns_dbmethods_t zone_methods = { attach, detach, @@ -8327,12 +8205,12 @@ static dns_dbmethods_t cache_methods = { NULL, NULL, isdnssec, - getrrsetstats, NULL, NULL, NULL, NULL, - setcachestats, + NULL, + NULL, hashsize, NULL }; @@ -8412,17 +8290,12 @@ dns_rbtdb_create goto cleanup_tree_lock; } - rbtdb->cachestats = NULL; - rbtdb->rrsetstats = NULL; if (IS_CACHE(rbtdb)) { - result = dns_rdatasetstats_create(mctx, &rbtdb->rrsetstats); - if (result != ISC_R_SUCCESS) - goto cleanup_node_locks; rbtdb->rdatasets = isc_mem_get(mctx, rbtdb->node_lock_count * sizeof(rdatasetheaderlist_t)); if (rbtdb->rdatasets == NULL) { result = ISC_R_NOMEMORY; - goto cleanup_rrsetstats; + goto cleanup_node_locks; } for (i = 0; i < (int)rbtdb->node_lock_count; i++) ISC_LIST_INIT(rbtdb->rdatasets[i]); @@ -8673,10 +8546,6 @@ dns_rbtdb_create if (rbtdb->rdatasets != NULL) isc_mem_put(mctx, rbtdb->rdatasets, rbtdb->node_lock_count * sizeof(rdatasetheaderlist_t)); - cleanup_rrsetstats: - if (rbtdb->rrsetstats != NULL) - dns_stats_detach(&rbtdb->rrsetstats); - cleanup_node_locks: isc_mem_put(mctx, rbtdb->node_locks, rbtdb->node_lock_count * sizeof(rbtdb_nodelock_t)); @@ -10131,6 +10000,7 @@ static void expire_header(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, isc_boolean_t tree_locked, expire_t reason) { + UNUSED(reason); set_ttl(rbtdb, header, 0); mark_stale_header(rbtdb, header); @@ -10150,21 +10020,5 @@ expire_header(dns_rbtdb_t *rbtdb, rdatasetheader_t *header, tree_locked ? isc_rwlocktype_write : isc_rwlocktype_none, ISC_FALSE); - if (rbtdb->cachestats == NULL) - return; - - switch (reason) { - case expire_ttl: - isc_stats_increment(rbtdb->cachestats, - dns_cachestatscounter_deletettl); - break; - case expire_lru: - isc_stats_increment(rbtdb->cachestats, - dns_cachestatscounter_deletelru); - break; - default: - break; - } - } } diff --git a/usr.sbin/bind/lib/dns/resolver.c b/usr.sbin/bind/lib/dns/resolver.c index c66547caf13..148c254b7a5 100644 --- a/usr.sbin/bind/lib/dns/resolver.c +++ b/usr.sbin/bind/lib/dns/resolver.c @@ -27,7 +27,7 @@ #include <isc/string.h> #include <isc/socket.h> -#include <isc/stats.h> + #include <isc/task.h> #include <isc/timer.h> #include <isc/util.h> @@ -65,7 +65,7 @@ #include <dns/resolver.h> #include <dns/result.h> #include <dns/rootns.h> -#include <dns/stats.h> + #include <dns/tsig.h> #include <dns/validator.h> @@ -588,21 +588,6 @@ static inline isc_result_t findnoqname(fetchctx_t *fctx, dns_name_t *name, static void fctx_increference(fetchctx_t *fctx); static isc_boolean_t fctx_decreference(fetchctx_t *fctx); -/*% - * Increment resolver-related statistics counters. - */ -static inline void -inc_stats(dns_resolver_t *res, isc_statscounter_t counter) { - if (res->view->resstats != NULL) - isc_stats_increment(res->view->resstats, counter); -} - -static inline void -dec_stats(dns_resolver_t *res, isc_statscounter_t counter) { - if (res->view->resstats != NULL) - isc_stats_decrement(res->view->resstats, counter); -} - static isc_result_t valcreate(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, dns_name_t *name, dns_rdatatype_t type, dns_rdataset_t *rdataset, @@ -630,7 +615,6 @@ valcreate(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, dns_name_t *name, valoptions, task, validated, valarg, &validator); if (result == ISC_R_SUCCESS) { - inc_stats(fctx->res, dns_resstatscounter_val); if ((valoptions & DNS_VALIDATOR_DEFER) == 0) { INSIST(fctx->validator == NULL); fctx->validator = validator; @@ -939,25 +923,6 @@ fctx_cancelquery(resquery_t **queryp, dns_dispatchevent_t **deventp, factor = DNS_ADB_RTTADJDEFAULT; rttms = rtt / 1000; - if (rttms < DNS_RESOLVER_QRYRTTCLASS0) { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt0); - } else if (rttms < DNS_RESOLVER_QRYRTTCLASS1) { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt1); - } else if (rttms < DNS_RESOLVER_QRYRTTCLASS2) { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt2); - } else if (rttms < DNS_RESOLVER_QRYRTTCLASS3) { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt3); - } else if (rttms < DNS_RESOLVER_QRYRTTCLASS4) { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt4); - } else { - inc_stats(fctx->res, - dns_resstatscounter_queryrtt5); - } } else { isc_uint32_t value; isc_uint32_t mask; @@ -1874,13 +1839,6 @@ fctx_query(fetchctx_t *fctx, dns_adbaddrinfo_t *addrinfo, ISC_LIST_APPEND(fctx->queries, query, link); query->fctx->nqueries++; - if (isc_sockaddr_pf(&addrinfo->sockaddr) == PF_INET) - inc_stats(res, dns_resstatscounter_queryv4); - else - inc_stats(res, dns_resstatscounter_queryv6); - if (res->view->resquerystats != NULL) - dns_rdatatypestats_increment(res->view->resquerystats, - fctx->type); return (ISC_R_SUCCESS); @@ -2353,14 +2311,10 @@ resquery_send(resquery_t *query) { cookie, sizeof(cookie)); if (ednsopts[ednsopt].length != 0) { ednsopts[ednsopt].value = cookie; - inc_stats(fctx->res, - dns_resstatscounter_sitout); } else { compute_cc(query, cookie, 8); ednsopts[ednsopt].value = cookie; ednsopts[ednsopt].length = 8; - inc_stats(fctx->res, - dns_resstatscounter_sitcc); } ednsopt++; } @@ -3394,7 +3348,6 @@ fctx_getaddresses(fetchctx_t *fctx, isc_boolean_t badcache) { */ if (all_spilled) { result = res->quotaresp[dns_quotatype_server]; - inc_stats(res, dns_resstatscounter_serverquota); } #endif /* ENABLE_FETCHLIMIT */ } @@ -3626,6 +3579,7 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { unsigned int bucketnum; isc_boolean_t bucket_empty; + UNUSED(retrying); FCTXTRACE5("try", "fctx->qc=", isc_counter_used(fctx->qc)); REQUIRE(!ADDRWAIT(fctx)); @@ -3713,8 +3667,7 @@ fctx_try(fetchctx_t *fctx, isc_boolean_t retrying, isc_boolean_t badcache) { UNLOCK(&res->buckets[bucketnum].lock); if (bucket_empty) empty_bucket(res); - } else if (retrying) - inc_stats(res, dns_resstatscounter_retry); + } } static isc_boolean_t @@ -3747,7 +3700,6 @@ fctx_unlink(fetchctx_t *fctx) { LOCK(&res->nlock); res->nfctx--; UNLOCK(&res->nlock); - dec_stats(res, dns_resstatscounter_nfetch); if (res->buckets[bucketnum].exiting && ISC_LIST_EMPTY(res->buckets[bucketnum].fctxs)) @@ -3844,7 +3796,6 @@ fctx_timeout(isc_task_t *task, isc_event_t *event) { FCTXTRACE("timeout"); - inc_stats(fctx->res, dns_resstatscounter_querytimeout); if (event->ev_type == ISC_TIMEREVENT_LIFE) { fctx->reason = NULL; @@ -4338,7 +4289,6 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, result = fcount_incr(fctx, ISC_FALSE); if (result != ISC_R_SUCCESS) { result = fctx->res->quotaresp[dns_quotatype_zone]; - inc_stats(res, dns_resstatscounter_zonequota); goto cleanup_domain; } #endif /* ENABLE_FETCHLIMIT */ @@ -4421,7 +4371,6 @@ fctx_create(dns_resolver_t *res, dns_name_t *name, dns_rdatatype_t type, LOCK(&res->nlock); res->nfctx++; UNLOCK(&res->nlock); - inc_stats(res, dns_resstatscounter_nfetch); *fctxp = fctx; @@ -4839,7 +4788,6 @@ validated(isc_task_t *task, isc_event_t *event) { if (vevent->result != ISC_R_SUCCESS) { FCTXTRACE("validation failed"); - inc_stats(res, dns_resstatscounter_valfail); fctx->valfail++; fctx->vresult = vevent->result; if (fctx->vresult != DNS_R_BROKENCHAIN) { @@ -4920,8 +4868,6 @@ validated(isc_task_t *task, isc_event_t *event) { dns_rdatatype_t covers; FCTXTRACE("nonexistence validation OK"); - inc_stats(res, dns_resstatscounter_valnegsuccess); - /* * Cache DS NXDOMAIN seperately to other types. */ @@ -4952,8 +4898,7 @@ validated(isc_task_t *task, isc_event_t *event) { if (result != ISC_R_SUCCESS) goto noanswer_response; goto answer_response; - } else - inc_stats(res, dns_resstatscounter_valsuccess); + } FCTXTRACE("validation OK"); @@ -7586,8 +7531,6 @@ process_opt(resquery_t *query, dns_rdataset_t *opt) { if (optlen >= 8U && memcmp(cookie, optvalue, 8) == 0) { query->fctx->rmessage->sitok = 1; - inc_stats(query->fctx->res, - dns_resstatscounter_sitok); addrinfo = query->addrinfo; dns_adb_setsit(query->fctx->adb, addrinfo, optvalue, @@ -7595,8 +7538,6 @@ process_opt(resquery_t *query, dns_rdataset_t *opt) { } else query->fctx->rmessage->sitbad = 1; isc_buffer_forward(&optbuf, optlen); - inc_stats(query->fctx->res, - dns_resstatscounter_sitin); seen_cookie = ISC_TRUE; break; default: @@ -7641,10 +7582,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { QTRACE("response"); res = fctx->res; - if (isc_sockaddr_pf(&query->addrinfo->sockaddr) == PF_INET) - inc_stats(res, dns_resstatscounter_responsev4); - else - inc_stats(res, dns_resstatscounter_responsev6); (void)isc_timer_touch(fctx->timer); @@ -7772,8 +7709,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { resend = ISC_TRUE; add_bad_edns(fctx, &query->addrinfo->sockaddr); - inc_stats(res, - dns_resstatscounter_edns0fail); } else { broken_server = result; keep_trying = ISC_TRUE; @@ -7796,7 +7731,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { options |= DNS_FETCHOPT_NOEDNS0; resend = ISC_TRUE; add_bad_edns(fctx, &query->addrinfo->sockaddr); - inc_stats(res, dns_resstatscounter_edns0fail); } else { broken_server = DNS_R_UNEXPECTEDRCODE; keep_trying = ISC_TRUE; @@ -7949,7 +7883,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { truncated = ISC_TRUE; if (truncated) { - inc_stats(res, dns_resstatscounter_truncated); if ((options & DNS_FETCHOPT_TCP) != 0) { broken_server = DNS_R_TRUNCATEDTCP; keep_trying = ISC_TRUE; @@ -7973,32 +7906,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { } /* - * Update statistics about erroneous responses. - */ - if (message->rcode != dns_rcode_noerror) { - switch (message->rcode) { - case dns_rcode_nxdomain: - inc_stats(res, dns_resstatscounter_nxdomain); - break; - case dns_rcode_servfail: - inc_stats(res, dns_resstatscounter_servfail); - break; - case dns_rcode_formerr: - inc_stats(res, dns_resstatscounter_formerr); - break; - case dns_rcode_refused: - inc_stats(res, dns_resstatscounter_refused); - break; - case dns_rcode_badvers: - inc_stats(res, dns_resstatscounter_badvers); - break; - default: - inc_stats(res, dns_resstatscounter_othererror); - break; - } - } - - /* * Is the remote server broken, or does it dislike us? */ if (message->rcode != dns_rcode_noerror && @@ -8044,7 +7951,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { * Remember that they may not like EDNS0. */ add_bad_edns(fctx, &query->addrinfo->sockaddr); - inc_stats(res, dns_resstatscounter_edns0fail); } else if (message->rcode == dns_rcode_formerr) { if (ISFORWARDER(query->addrinfo)) { /* @@ -8162,7 +8068,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { */ if (res->lame_ttl != 0 && !ISFORWARDER(query->addrinfo) && is_lame(fctx)) { - inc_stats(res, dns_resstatscounter_lame); log_lame(fctx, query->addrinfo); result = dns_adb_marklame(fctx->adb, query->addrinfo, &fctx->name, fctx->type, @@ -8507,7 +8412,6 @@ resquery_response(isc_task_t *task, isc_event_t *event) { * Resend (probably with changed options). */ FCTXTRACE("resend"); - inc_stats(res, dns_resstatscounter_retry); bucketnum = fctx->bucketnum; fctx_increference(fctx); result = fctx_query(fctx, addrinfo, options); @@ -8786,9 +8690,6 @@ dns_resolver_create(dns_view_t *view, res->quotaresp[dns_quotatype_zone] = DNS_R_DROP; res->quotaresp[dns_quotatype_server] = DNS_R_SERVFAIL; res->nbuckets = ntasks; - if (view->resstats != NULL) - isc_stats_set(view->resstats, ntasks, - dns_resstatscounter_buckets); res->activebuckets = ntasks; res->buckets = isc_mem_get(view->mctx, ntasks * sizeof(fctxbucket_t)); diff --git a/usr.sbin/bind/lib/dns/stats.c b/usr.sbin/bind/lib/dns/stats.c deleted file mode 100644 index 7cd2cfe990e..00000000000 --- a/usr.sbin/bind/lib/dns/stats.c +++ /dev/null @@ -1,436 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stats.c,v 1.4 2020/01/09 14:18:29 florian Exp $ */ - -/*! \file */ - -#include <config.h> - -#include <isc/magic.h> -#include <isc/mem.h> -#include <isc/stats.h> -#include <isc/util.h> - -#include <dns/opcode.h> -#include <dns/rdatatype.h> -#include <dns/stats.h> - -#define DNS_STATS_MAGIC ISC_MAGIC('D', 's', 't', 't') -#define DNS_STATS_VALID(x) ISC_MAGIC_VALID(x, DNS_STATS_MAGIC) - -/*% - * Statistics types. - */ -typedef enum { - dns_statstype_general = 0, - dns_statstype_rdtype = 1, - dns_statstype_rdataset = 2, - dns_statstype_opcode = 3 -} dns_statstype_t; - -/*% - * It doesn't make sense to have 2^16 counters for all possible types since - * most of them won't be used. We have counters for the first 256 types and - * those explicitly supported in the rdata implementation. - * XXXJT: this introduces tight coupling with the rdata implementation. - * Ideally, we should have rdata handle this type of details. - */ -/* - * types, !types, nxdomain, stale types, stale !types, stale nxdomain - */ -enum { - /* For 0-255, we use the rdtype value as counter indices */ - rdtypecounter_dlv = 256, /* for dns_rdatatype_dlv */ - rdtypecounter_others = 257, /* anything else */ - rdtypecounter_max = 258, - /* The following are used for rdataset */ - rdtypenxcounter_max = rdtypecounter_max * 2, - rdtypecounter_nxdomain = rdtypenxcounter_max, - /* stale counters offset */ - rdtypecounter_stale = rdtypecounter_nxdomain + 1, - rdatasettypecounter_max = rdtypecounter_stale * 2 -}; - -struct dns_stats { - /*% Unlocked */ - unsigned int magic; - dns_statstype_t type; - isc_mem_t *mctx; - isc_mutex_t lock; - isc_stats_t *counters; - - /*% Locked by lock */ - unsigned int references; -}; - -typedef struct rdatadumparg { - dns_rdatatypestats_dumper_t fn; - void *arg; -} rdatadumparg_t; - -typedef struct opcodedumparg { - dns_opcodestats_dumper_t fn; - void *arg; -} opcodedumparg_t; - -void -dns_stats_attach(dns_stats_t *stats, dns_stats_t **statsp) { - REQUIRE(DNS_STATS_VALID(stats)); - REQUIRE(statsp != NULL && *statsp == NULL); - - LOCK(&stats->lock); - stats->references++; - UNLOCK(&stats->lock); - - *statsp = stats; -} - -void -dns_stats_detach(dns_stats_t **statsp) { - dns_stats_t *stats; - - REQUIRE(statsp != NULL && DNS_STATS_VALID(*statsp)); - - stats = *statsp; - *statsp = NULL; - - LOCK(&stats->lock); - stats->references--; - UNLOCK(&stats->lock); - - if (stats->references == 0) { - isc_stats_detach(&stats->counters); - DESTROYLOCK(&stats->lock); - isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); - } -} - -/*% - * Create methods - */ -static isc_result_t -create_stats(isc_mem_t *mctx, dns_statstype_t type, int ncounters, - dns_stats_t **statsp) -{ - dns_stats_t *stats; - isc_result_t result; - - stats = isc_mem_get(mctx, sizeof(*stats)); - if (stats == NULL) - return (ISC_R_NOMEMORY); - - stats->counters = NULL; - stats->references = 1; - - result = isc_mutex_init(&stats->lock); - if (result != ISC_R_SUCCESS) - goto clean_stats; - - result = isc_stats_create(mctx, &stats->counters, ncounters); - if (result != ISC_R_SUCCESS) - goto clean_mutex; - - stats->magic = DNS_STATS_MAGIC; - stats->type = type; - stats->mctx = NULL; - isc_mem_attach(mctx, &stats->mctx); - *statsp = stats; - - return (ISC_R_SUCCESS); - - clean_mutex: - DESTROYLOCK(&stats->lock); - clean_stats: - isc_mem_put(mctx, stats, sizeof(*stats)); - - return (result); -} - -isc_result_t -dns_generalstats_create(isc_mem_t *mctx, dns_stats_t **statsp, int ncounters) { - REQUIRE(statsp != NULL && *statsp == NULL); - - return (create_stats(mctx, dns_statstype_general, ncounters, statsp)); -} - -isc_result_t -dns_rdatatypestats_create(isc_mem_t *mctx, dns_stats_t **statsp) { - REQUIRE(statsp != NULL && *statsp == NULL); - - return (create_stats(mctx, dns_statstype_rdtype, rdtypecounter_max, - statsp)); -} - -isc_result_t -dns_rdatasetstats_create(isc_mem_t *mctx, dns_stats_t **statsp) { - REQUIRE(statsp != NULL && *statsp == NULL); - - return (create_stats(mctx, dns_statstype_rdataset, - rdatasettypecounter_max, statsp)); -} - -isc_result_t -dns_opcodestats_create(isc_mem_t *mctx, dns_stats_t **statsp) { - REQUIRE(statsp != NULL && *statsp == NULL); - - return (create_stats(mctx, dns_statstype_opcode, 16, statsp)); -} - -/*% - * Increment/Decrement methods - */ -void -dns_generalstats_increment(dns_stats_t *stats, isc_statscounter_t counter) { - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_general); - - isc_stats_increment(stats->counters, counter); -} - -void -dns_rdatatypestats_increment(dns_stats_t *stats, dns_rdatatype_t type) { - int counter; - - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_rdtype); - - if (type == dns_rdatatype_dlv) - counter = rdtypecounter_dlv; - else if (type > dns_rdatatype_any) - counter = rdtypecounter_others; - else - counter = (int)type; - - isc_stats_increment(stats->counters, (isc_statscounter_t)counter); -} - -static inline void -update_rdatasetstats(dns_stats_t *stats, dns_rdatastatstype_t rrsettype, - isc_boolean_t increment) -{ - int counter; - dns_rdatatype_t rdtype; - - if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) & - DNS_RDATASTATSTYPE_ATTR_NXDOMAIN) != 0) { - counter = rdtypecounter_nxdomain; - } else { - rdtype = DNS_RDATASTATSTYPE_BASE(rrsettype); - if (rdtype == dns_rdatatype_dlv) - counter = (int)rdtypecounter_dlv; - else if (rdtype > dns_rdatatype_any) - counter = (int)rdtypecounter_others; - else - counter = (int)rdtype; - - if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) & - DNS_RDATASTATSTYPE_ATTR_NXRRSET) != 0) - counter += rdtypecounter_max; - } - - if (increment) { - if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) & - DNS_RDATASTATSTYPE_ATTR_STALE) != 0) { - isc_stats_decrement(stats->counters, counter); - counter += rdtypecounter_stale; - } - isc_stats_increment(stats->counters, counter); - } else { - if ((DNS_RDATASTATSTYPE_ATTR(rrsettype) & - DNS_RDATASTATSTYPE_ATTR_STALE) != 0) - counter += rdtypecounter_stale; - isc_stats_decrement(stats->counters, counter); - } -} - -void -dns_rdatasetstats_increment(dns_stats_t *stats, dns_rdatastatstype_t rrsettype) -{ - REQUIRE(DNS_STATS_VALID(stats) && - stats->type == dns_statstype_rdataset); - - update_rdatasetstats(stats, rrsettype, ISC_TRUE); -} - -void -dns_rdatasetstats_decrement(dns_stats_t *stats, dns_rdatastatstype_t rrsettype) -{ - REQUIRE(DNS_STATS_VALID(stats) && - stats->type == dns_statstype_rdataset); - - update_rdatasetstats(stats, rrsettype, ISC_FALSE); -} - -void -dns_opcodestats_increment(dns_stats_t *stats, dns_opcode_t code) { - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_opcode); - - isc_stats_increment(stats->counters, (isc_statscounter_t)code); -} - -/*% - * Dump methods - */ -void -dns_generalstats_dump(dns_stats_t *stats, dns_generalstats_dumper_t dump_fn, - void *arg, unsigned int options) -{ - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_general); - - isc_stats_dump(stats->counters, (isc_stats_dumper_t)dump_fn, - arg, options); -} - -static void -dump_rdentry(int rdcounter, isc_uint64_t value, dns_rdatastatstype_t attributes, - dns_rdatatypestats_dumper_t dump_fn, void * arg) -{ - dns_rdatatype_t rdtype = dns_rdatatype_none; /* sentinel */ - dns_rdatastatstype_t type; - - if (rdcounter == rdtypecounter_others) - attributes |= DNS_RDATASTATSTYPE_ATTR_OTHERTYPE; - else { - if (rdcounter == rdtypecounter_dlv) - rdtype = dns_rdatatype_dlv; - else - rdtype = (dns_rdatatype_t)rdcounter; - } - type = DNS_RDATASTATSTYPE_VALUE((dns_rdatastatstype_t)rdtype, - attributes); - dump_fn(type, value, arg); -} - -static void -rdatatype_dumpcb(isc_statscounter_t counter, isc_uint64_t value, void *arg) { - rdatadumparg_t *rdatadumparg = arg; - - dump_rdentry(counter, value, 0, rdatadumparg->fn, rdatadumparg->arg); -} - -void -dns_rdatatypestats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, - void *arg0, unsigned int options) -{ - rdatadumparg_t arg; - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_rdtype); - - arg.fn = dump_fn; - arg.arg = arg0; - isc_stats_dump(stats->counters, rdatatype_dumpcb, &arg, options); -} - -static void -rdataset_dumpcb(isc_statscounter_t counter, isc_uint64_t value, void *arg) { - rdatadumparg_t *rdatadumparg = arg; - unsigned int attributes; - - if (counter < rdtypecounter_max) { - dump_rdentry(counter, value, 0, rdatadumparg->fn, - rdatadumparg->arg); - } else if (counter < rdtypecounter_nxdomain) { - counter -= rdtypecounter_max; - attributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET; - dump_rdentry(counter, value, attributes, rdatadumparg->fn, - rdatadumparg->arg); - } else if (counter == rdtypecounter_nxdomain) { - dump_rdentry(0, value, DNS_RDATASTATSTYPE_ATTR_NXDOMAIN, - rdatadumparg->fn, rdatadumparg->arg); - } else if (counter < rdtypecounter_stale + rdtypecounter_max) { - counter -= rdtypecounter_stale; - attributes = DNS_RDATASTATSTYPE_ATTR_STALE; - dump_rdentry(counter, value, attributes, rdatadumparg->fn, - rdatadumparg->arg); - } else if (counter < rdtypecounter_stale + rdtypecounter_nxdomain) { - counter -= rdtypecounter_stale + rdtypecounter_max; - attributes = DNS_RDATASTATSTYPE_ATTR_NXRRSET | - DNS_RDATASTATSTYPE_ATTR_STALE; - dump_rdentry(counter, value, attributes, rdatadumparg->fn, - rdatadumparg->arg); - } else { - attributes = DNS_RDATASTATSTYPE_ATTR_NXDOMAIN | - DNS_RDATASTATSTYPE_ATTR_STALE; - dump_rdentry(0, value, attributes, rdatadumparg->fn, - rdatadumparg->arg); - } -} - -void -dns_rdatasetstats_dump(dns_stats_t *stats, dns_rdatatypestats_dumper_t dump_fn, - void *arg0, unsigned int options) -{ - rdatadumparg_t arg; - - REQUIRE(DNS_STATS_VALID(stats) && - stats->type == dns_statstype_rdataset); - - arg.fn = dump_fn; - arg.arg = arg0; - isc_stats_dump(stats->counters, rdataset_dumpcb, &arg, options); -} - -static void -opcode_dumpcb(isc_statscounter_t counter, isc_uint64_t value, void *arg) { - opcodedumparg_t *opcodearg = arg; - - opcodearg->fn((dns_opcode_t)counter, value, opcodearg->arg); -} - -void -dns_opcodestats_dump(dns_stats_t *stats, dns_opcodestats_dumper_t dump_fn, - void *arg0, unsigned int options) -{ - opcodedumparg_t arg; - - REQUIRE(DNS_STATS_VALID(stats) && stats->type == dns_statstype_opcode); - - arg.fn = dump_fn; - arg.arg = arg0; - isc_stats_dump(stats->counters, opcode_dumpcb, &arg, options); -} - -/*** - *** Obsolete variables and functions follow: - ***/ -const char *dns_statscounter_names[DNS_STATS_NCOUNTERS] = - { - "success", - "referral", - "nxrrset", - "nxdomain", - "recursion", - "failure", - "duplicate", - "dropped" - }; - -isc_result_t -dns_stats_alloccounters(isc_mem_t *mctx, isc_uint64_t **ctrp) { - int i; - isc_uint64_t *p = - isc_mem_get(mctx, DNS_STATS_NCOUNTERS * sizeof(isc_uint64_t)); - if (p == NULL) - return (ISC_R_NOMEMORY); - for (i = 0; i < DNS_STATS_NCOUNTERS; i++) - p[i] = 0; - *ctrp = p; - return (ISC_R_SUCCESS); -} - -void -dns_stats_freecounters(isc_mem_t *mctx, isc_uint64_t **ctrp) { - isc_mem_put(mctx, *ctrp, DNS_STATS_NCOUNTERS * sizeof(isc_uint64_t)); - *ctrp = NULL; -} diff --git a/usr.sbin/bind/lib/dns/update.c b/usr.sbin/bind/lib/dns/update.c index 0db3afc5c26..0ce329b0376 100644 --- a/usr.sbin/bind/lib/dns/update.c +++ b/usr.sbin/bind/lib/dns/update.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: update.c,v 1.3 2020/01/09 13:47:13 florian Exp $ */ +/* $Id: update.c,v 1.4 2020/01/09 18:14:48 florian Exp $ */ #include <config.h> @@ -25,7 +25,7 @@ #include <isc/platform.h> #include <isc/serial.h> -#include <isc/stats.h> + #include <isc/stdtime.h> #include <isc/string.h> #include <isc/taskpool.h> diff --git a/usr.sbin/bind/lib/dns/view.c b/usr.sbin/bind/lib/dns/view.c index fab5b48ed1a..d0c019a7f5f 100644 --- a/usr.sbin/bind/lib/dns/view.c +++ b/usr.sbin/bind/lib/dns/view.c @@ -22,7 +22,7 @@ #include <isc/hash.h> #include <isc/sha2.h> -#include <isc/stats.h> + #include <isc/string.h> /* Required for HP/UX (and others?) */ #include <isc/task.h> #include <isc/util.h> @@ -51,7 +51,7 @@ #include <dns/result.h> #include <dns/rpz.h> #include <dns/rrl.h> -#include <dns/stats.h> + #include <dns/tsig.h> #include <dns/zone.h> #include <dns/zt.h> @@ -435,12 +435,6 @@ destroy(dns_view_t *view) { sizeof(dns_namelist_t) * DNS_VIEW_DELONLYHASH); view->rootexclude = NULL; } - if (view->adbstats != NULL) - isc_stats_detach(&view->adbstats); - if (view->resstats != NULL) - isc_stats_detach(&view->resstats); - if (view->resquerystats != NULL) - dns_stats_detach(&view->resquerystats); if (view->secroots_priv != NULL) dns_keytable_detach(&view->secroots_priv); for (dns64 = ISC_LIST_HEAD(view->dns64); @@ -1721,61 +1715,6 @@ dns_view_freezezones(dns_view_t *view, isc_boolean_t value) { return (dns_zt_freezezones(view->zonetable, value)); } -void -dns_view_setadbstats(dns_view_t *view, isc_stats_t *stats) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->adbstats == NULL); - - isc_stats_attach(stats, &view->adbstats); -} - -void -dns_view_getadbstats(dns_view_t *view, isc_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->adbstats != NULL) - isc_stats_attach(view->adbstats, statsp); -} - -void -dns_view_setresstats(dns_view_t *view, isc_stats_t *stats) { - - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->resstats == NULL); - - isc_stats_attach(stats, &view->resstats); -} - -void -dns_view_getresstats(dns_view_t *view, isc_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->resstats != NULL) - isc_stats_attach(view->resstats, statsp); -} - -void -dns_view_setresquerystats(dns_view_t *view, dns_stats_t *stats) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->resquerystats == NULL); - - dns_stats_attach(stats, &view->resquerystats); -} - -void -dns_view_getresquerystats(dns_view_t *view, dns_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->resquerystats != NULL) - dns_stats_attach(view->resquerystats, statsp); -} - isc_result_t dns_view_initsecroots(dns_view_t *view, isc_mem_t *mctx) { REQUIRE(DNS_VIEW_VALID(view)); diff --git a/usr.sbin/bind/lib/dns/zone.c b/usr.sbin/bind/lib/dns/zone.c index 0b50069695f..6ee638268b1 100644 --- a/usr.sbin/bind/lib/dns/zone.c +++ b/usr.sbin/bind/lib/dns/zone.c @@ -30,7 +30,7 @@ #include <isc/refcount.h> #include <isc/rwlock.h> #include <isc/serial.h> -#include <isc/stats.h> + #include <isc/stdtime.h> #include <isc/strerror.h> #include <isc/string.h> @@ -76,7 +76,7 @@ #include <dns/rriterator.h> #include <dns/soa.h> #include <dns/ssu.h> -#include <dns/stats.h> + #include <dns/time.h> #include <dns/tsig.h> #include <dns/update.h> @@ -181,17 +181,10 @@ typedef struct dns_include dns_include_t; do { result = isc_mutex_trylock(&(z)->lock); } while (0) #endif -#ifdef ISC_RWLOCK_USEATOMIC -#define ZONEDB_INITLOCK(l) isc_rwlock_init((l), 0, 0) -#define ZONEDB_DESTROYLOCK(l) isc_rwlock_destroy(l) -#define ZONEDB_LOCK(l, t) RWLOCK((l), (t)) -#define ZONEDB_UNLOCK(l, t) RWUNLOCK((l), (t)) -#else #define ZONEDB_INITLOCK(l) isc_mutex_init(l) #define ZONEDB_DESTROYLOCK(l) DESTROYLOCK(l) #define ZONEDB_LOCK(l, t) LOCK(l) #define ZONEDB_UNLOCK(l, t) UNLOCK(l) -#endif struct dns_zone { /* Unlocked */ @@ -203,11 +196,7 @@ struct dns_zone { isc_mem_t *mctx; isc_refcount_t erefs; -#ifdef ISC_RWLOCK_USEATOMIC - isc_rwlock_t dblock; -#else isc_mutex_t dblock; -#endif dns_db_t *db; /* Locked by dblock */ /* Locked */ @@ -854,15 +843,6 @@ struct np3event { nsec3param_t params; }; -/*% - * Increment resolver-related statistics counters. Zone must be locked. - */ -static inline void -inc_stats(dns_zone_t *zone, isc_statscounter_t counter) { - if (zone->stats != NULL) - isc_stats_increment(zone->stats, counter); -} - /*** *** Public functions. ***/ @@ -1153,15 +1133,6 @@ zone_free(dns_zone_t *zone) { isc_mem_free(zone->mctx, zone->journal); } zone->journal = NULL; - if (zone->stats != NULL) { - isc_stats_detach(&zone->stats); - } - if (zone->requeststats != NULL) { - isc_stats_detach(&zone->requeststats); - } - if (zone->rcvquerystats != NULL){ - dns_stats_detach(&zone->rcvquerystats); - } if (zone->db != NULL) { zone_detachdb(zone); } @@ -10932,15 +10903,6 @@ notify_send_toaddr(isc_task_t *task, isc_event_t *event) { options, key, timeout * 3, timeout, 0, notify->zone->task, notify_done, notify, ¬ify->request); - if (result == ISC_R_SUCCESS) { - if (isc_sockaddr_pf(¬ify->dst) == AF_INET) { - inc_stats(notify->zone, - dns_zonestatscounter_notifyoutv4); - } else { - inc_stats(notify->zone, - dns_zonestatscounter_notifyoutv6); - } - } cleanup_key: if (key != NULL) @@ -12245,11 +12207,6 @@ soa_query(isc_task_t *task, isc_event_t *event) { "dns_request_createvia4() failed: %s", dns_result_totext(result)); goto skip_master; - } else { - if (isc_sockaddr_pf(&zone->masteraddr) == PF_INET) - inc_stats(zone, dns_zonestatscounter_soaoutv4); - else - inc_stats(zone, dns_zonestatscounter_soaoutv6); } cancel = ISC_FALSE; @@ -13008,10 +12965,6 @@ dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, /* * We only handle NOTIFY (SOA) at the present. */ - if (isc_sockaddr_pf(from) == PF_INET) - inc_stats(zone, dns_zonestatscounter_notifyinv4); - else - inc_stats(zone, dns_zonestatscounter_notifyinv6); if (msg->counts[DNS_SECTION_QUESTION] == 0 || dns_message_findname(msg, DNS_SECTION_QUESTION, &zone->origin, dns_rdatatype_soa, dns_rdatatype_none, @@ -13068,7 +13021,6 @@ dns_zone_notifyreceive2(dns_zone_t *zone, isc_sockaddr_t *from, UNLOCK_ZONE(zone); dns_zone_log(zone, ISC_LOG_INFO, "refused notify from non-master: %s", fromtext); - inc_stats(zone, dns_zonestatscounter_notifyrej); return (DNS_R_REFUSED); } @@ -15059,7 +15011,6 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) { dns_result_totext(result)); } DNS_ZONE_CLRFLAG(zone, DNS_ZONEFLG_NODELAY); - inc_stats(zone, dns_zonestatscounter_xfrsuccess); break; case DNS_R_BADIXFR: @@ -15069,7 +15020,6 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) { case DNS_R_TOOMANYRECORDS: DNS_ZONE_JITTER_ADD(&now, zone->refresh, &zone->refreshtime); - inc_stats(zone, dns_zonestatscounter_xfrfail); break; default: @@ -15099,7 +15049,6 @@ zone_xfrdone(dns_zone_t *zone, isc_result_t result) { DNS_ZONE_SETFLAG(zone, DNS_ZONEFLG_REFRESH); again = ISC_TRUE; } - inc_stats(zone, dns_zonestatscounter_xfrfail); break; } zone_settimer(zone, &now); @@ -15467,21 +15416,6 @@ got_transfer_quota(isc_task_t *task, isc_event_t *event) { dscp, zone->tsigkey, zone->mctx, zone->zmgr->timermgr, zone->zmgr->socketmgr, zone->task, zone_xfrdone, &zone->xfr); - if (result == ISC_R_SUCCESS) { - LOCK_ZONE(zone); - if (xfrtype == dns_rdatatype_axfr) { - if (isc_sockaddr_pf(&masteraddr) == PF_INET) - inc_stats(zone, dns_zonestatscounter_axfrreqv4); - else - inc_stats(zone, dns_zonestatscounter_axfrreqv6); - } else if (xfrtype == dns_rdatatype_ixfr) { - if (isc_sockaddr_pf(&masteraddr) == PF_INET) - inc_stats(zone, dns_zonestatscounter_ixfrreqv4); - else - inc_stats(zone, dns_zonestatscounter_ixfrreqv6); - } - UNLOCK_ZONE(zone); - } cleanup: /* * Any failure in this function is handled like a failed @@ -16763,96 +16697,6 @@ dns_zone_isforced(dns_zone_t *zone) { return (DNS_ZONE_FLAG(zone, DNS_ZONEFLG_FORCEXFER)); } -isc_result_t -dns_zone_setstatistics(dns_zone_t *zone, isc_boolean_t on) { - /* - * This function is obsoleted. - */ - UNUSED(zone); - UNUSED(on); - return (ISC_R_NOTIMPLEMENTED); -} - -isc_uint64_t * -dns_zone_getstatscounters(dns_zone_t *zone) { - /* - * This function is obsoleted. - */ - UNUSED(zone); - return (NULL); -} - -void -dns_zone_setstats(dns_zone_t *zone, isc_stats_t *stats) { - REQUIRE(DNS_ZONE_VALID(zone)); - REQUIRE(zone->stats == NULL); - - LOCK_ZONE(zone); - zone->stats = NULL; - isc_stats_attach(stats, &zone->stats); - UNLOCK_ZONE(zone); -} - -void -dns_zone_setrequeststats(dns_zone_t *zone, isc_stats_t *stats) { - - REQUIRE(DNS_ZONE_VALID(zone)); - - LOCK_ZONE(zone); - if (zone->requeststats_on && stats == NULL) - zone->requeststats_on = ISC_FALSE; - else if (!zone->requeststats_on && stats != NULL) { - if (zone->requeststats == NULL) { - isc_stats_attach(stats, &zone->requeststats); - zone->requeststats_on = ISC_TRUE; - } - } - UNLOCK_ZONE(zone); -} - -void -dns_zone_setrcvquerystats(dns_zone_t *zone, dns_stats_t *stats) { - - REQUIRE(DNS_ZONE_VALID(zone)); - - LOCK_ZONE(zone); - if (zone->requeststats_on && stats != NULL) { - if (zone->rcvquerystats == NULL) { - dns_stats_attach(stats, &zone->rcvquerystats); - zone->requeststats_on = ISC_TRUE; - } - } - UNLOCK_ZONE(zone); -} - -isc_stats_t * -dns_zone_getrequeststats(dns_zone_t *zone) { - /* - * We don't lock zone for efficiency reason. This is not catastrophic - * because requeststats must always be valid when requeststats_on is - * true. - * Some counters may be incremented while requeststats_on is becoming - * false, or some cannot be incremented just after the statistics are - * installed, but it shouldn't matter much in practice. - */ - if (zone->requeststats_on) - return (zone->requeststats); - else - return (NULL); -} - -/* - * Return the received query stats bucket - * see note from dns_zone_getrequeststats() - */ -dns_stats_t * -dns_zone_getrcvquerystats(dns_zone_t *zone) { - if (zone->requeststats_on) - return (zone->rcvquerystats); - else - return (NULL); -} - void dns_zone_dialup(dns_zone_t *zone) { diff --git a/usr.sbin/bind/lib/isc/Makefile.in b/usr.sbin/bind/lib/isc/Makefile.in index 77a8b6e561d..39c6b213645 100644 --- a/usr.sbin/bind/lib/isc/Makefile.in +++ b/usr.sbin/bind/lib/isc/Makefile.in @@ -24,7 +24,6 @@ VERSION=@BIND9_VERSION@ CINCLUDES = -I${srcdir}/unix/include \ -I${srcdir}/nothreads/include \ - -I${srcdir}/@ISC_ARCH_DIR@/include \ -I./include \ -I${srcdir}/include ${DNS_INCLUDES} @ISC_OPENSSL_INC@ CDEFINES = @CRYPTO@ @@ -57,7 +56,7 @@ OBJS = @ISC_EXTRA_OBJS@ @ISC_PK11_O@ @ISC_PK11_RESULT_O@ \ parseint.@O@ portset.@O@ quota.@O@ radix.@O@ \ ratelimiter.@O@ refcount.@O@ region.@O@ regex.@O@ result.@O@ \ rwlock.@O@ \ - safe.@O@ serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ stats.@O@ \ + safe.@O@ serial.@O@ sha1.@O@ sha2.@O@ sockaddr.@O@ \ string.@O@ symtab.@O@ task.@O@ taskpool.@O@ \ tm.@O@ timer.@O@ version.@O@ \ ${UNIXOBJS} ${NLSOBJS} ${THREADOBJS} @@ -73,7 +72,7 @@ SRCS = @ISC_EXTRA_SRCS@ @ISC_PK11_C@ @ISC_PK11_RESULT_C@ \ netaddr.c netscope.c pool.c ondestroy.c \ parseint.c portset.c quota.c radix.c \ ratelimiter.c refcount.c region.c regex.c result.c rwlock.c \ - safe.c serial.c sha1.c sha2.c sockaddr.c stats.c string.c \ + safe.c serial.c sha1.c sha2.c sockaddr.c string.c \ symtab.c task.c taskpool.c timer.c \ tm.c version.c @@ -83,7 +82,7 @@ LIBS = @ISC_OPENSSL_LIBS@ @LIBS@ # Attempt to disable parallel processing. .NOTPARALLEL: .NO_PARALLEL: -SUBDIRS = include unix nls nothreads @ISC_ARCH_DIR@ +SUBDIRS = include unix nls nothreads TARGETS = timestamp TESTDIRS = @UNITTESTS@ diff --git a/usr.sbin/bind/lib/isc/alpha/Makefile.in b/usr.sbin/bind/lib/isc/alpha/Makefile.in deleted file mode 100644 index f5e6ae31d38..00000000000 --- a/usr.sbin/bind/lib/isc/alpha/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:34 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/alpha/include/Makefile.in b/usr.sbin/bind/lib/isc/alpha/include/Makefile.in deleted file mode 100644 index da088d317a6..00000000000 --- a/usr.sbin/bind/lib/isc/alpha/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:34 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/alpha/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/alpha/include/isc/Makefile.in deleted file mode 100644 index 7f32bd84323..00000000000 --- a/usr.sbin/bind/lib/isc/alpha/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:34 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/alpha/include/isc/atomic.h b/usr.sbin/bind/lib/isc/alpha/include/isc/atomic.h deleted file mode 100644 index 740a9a42645..00000000000 --- a/usr.sbin/bind/lib/isc/alpha/include/isc/atomic.h +++ /dev/null @@ -1,184 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.3 2019/12/17 01:46:34 sthen Exp $ */ - -/* - * This code was written based on FreeBSD's kernel source whose copyright - * follows: - */ - -/*- - * Copyright (c) 1998 Doug Rabson - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD: src/sys/alpha/include/atomic.h,v 1.18.6.1 2004/09/13 21:52:04 wilko Exp $ - */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#ifdef ISC_PLATFORM_USEOSFASM -#include <c_asm.h> - -#pragma intrinsic(asm) - -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. Memory access ordering around this function - * can be critical, so we add explicit memory block instructions at the - * beginning and the end of it (same for other functions). - */ -static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - return (asm("mb;" - "1:" - "ldl_l %t0, 0(%a0);" /* load old value */ - "mov %t0, %v0;" /* copy the old value */ - "addl %t0, %a1, %t0;" /* calculate new value */ - "stl_c %t0, 0(%a0);" /* attempt to store */ - "beq %t0, 1b;" /* spin if failed */ - "mb;", - p, val)); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - (void)asm("mb;" - "1:" - "ldl_l %t0, 0(%a0);" /* load old value */ - "mov %a1, %t0;" /* value to store */ - "stl_c %t0, 0(%a0);" /* attempt to store */ - "beq %t0, 1b;" /* spin if failed */ - "mb;", - p, val); -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - - return(asm("mb;" - "1:" - "ldl_l %t0, 0(%a0);" /* load old value */ - "mov %t0, %v0;" /* copy the old value */ - "cmpeq %t0, %a1, %t0;" /* compare */ - "beq %t0, 2f;" /* exit if not equal */ - "mov %a2, %t0;" /* value to store */ - "stl_c %t0, 0(%a0);" /* attempt to store */ - "beq %t0, 1b;" /* if it failed, spin */ - "2:" - "mb;", - p, cmpval, val)); -} -#elif defined (ISC_PLATFORM_USEGCCASM) -static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - isc_int32_t temp, prev; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %0, %2;" /* copy the old value */ - "addl %0, %3, %0;" /* calculate new value */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* spin if failed */ - "mb;" - : "=&r"(temp), "+m"(*p), "=&r"(prev) - : "r"(val) - : "memory"); - - return (prev); -} - -static inline void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - isc_int32_t temp; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %2, %0;" /* value to store */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* if it failed, spin */ - "mb;" - : "=&r"(temp), "+m"(*p) - : "r"(val) - : "memory"); -} - -static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - isc_int32_t temp, prev; - - __asm__ volatile( - "mb;" - "1:" - "ldl_l %0, %1;" /* load old value */ - "mov %0, %2;" /* copy the old value */ - "cmpeq %0, %3, %0;" /* compare */ - "beq %0, 2f;" /* exit if not equal */ - "mov %4, %0;" /* value to store */ - "stl_c %0, %1;" /* attempt to store */ - "beq %0, 1b;" /* if it failed, spin */ - "2:" - "mb;" - : "=&r"(temp), "+m"(*p), "=&r"(prev) - : "r"(cmpval), "r"(val) - : "memory"); - - return (prev); -} -#else - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif - -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/ia64/Makefile.in b/usr.sbin/bind/lib/isc/ia64/Makefile.in deleted file mode 100644 index f5e6ae31d38..00000000000 --- a/usr.sbin/bind/lib/isc/ia64/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:34 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/ia64/include/Makefile.in b/usr.sbin/bind/lib/isc/ia64/include/Makefile.in deleted file mode 100644 index 26e6c3bd7f5..00000000000 --- a/usr.sbin/bind/lib/isc/ia64/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:35 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/ia64/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/ia64/include/isc/Makefile.in deleted file mode 100644 index aefa23abcd5..00000000000 --- a/usr.sbin/bind/lib/isc/ia64/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:35 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/ia64/include/isc/atomic.h b/usr.sbin/bind/lib/isc/ia64/include/isc/atomic.h deleted file mode 100644 index a5a3fdc61d8..00000000000 --- a/usr.sbin/bind/lib/isc/ia64/include/isc/atomic.h +++ /dev/null @@ -1,100 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.3 2019/12/17 01:46:35 sthen Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - * - * Open issue: can 'fetchadd' make the code faster for some particular values - * (e.g., 1 and -1)? - */ -static inline isc_int32_t -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) -{ - isc_int32_t prev, swapped; - - for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) { - swapped = prev + val; - __asm__ volatile( - "mov ar.ccv=%2;;" - "cmpxchg4.acq %0=%4,%3,ar.ccv" - : "=r" (swapped), "=m" (*p) - : "r" (prev), "r" (swapped), "m" (*p) - : "memory"); - if (swapped == prev) - break; - } - - return (prev); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_store(isc_int32_t *p, isc_int32_t val) -{ - __asm__ volatile( - "st4.rel %0=%1" - : "=m" (*p) - : "r" (val) - : "memory" - ); -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline isc_int32_t -#ifdef __GNUC__ -__attribute__ ((unused)) -#endif -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) -{ - isc_int32_t ret; - - __asm__ volatile( - "mov ar.ccv=%2;;" - "cmpxchg4.acq %0=%4,%3,ar.ccv" - : "=r" (ret), "=m" (*p) - : "r" (cmpval), "r" (val), "m" (*p) - : "memory"); - - return (ret); -} -#else /* !ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/include/isc/Makefile.in index d36c4064102..2a71b2affb4 100644 --- a/usr.sbin/bind/lib/isc/include/isc/Makefile.in +++ b/usr.sbin/bind/lib/isc/include/isc/Makefile.in @@ -36,7 +36,7 @@ HEADERS = aes.h app.h assertions.h base32.h base64.h \ radix.h ratelimiter.h refcount.h regex.h \ region.h resource.h result.h resultclass.h rwlock.h \ safe.h serial.h sha1.h sha2.h sockaddr.h socket.h \ - stats.h stdio.h stdlib.h string.h symtab.h task.h \ + stdio.h stdlib.h string.h symtab.h task.h \ taskpool.h timer.h tm.h types.h util.h version.h \ xml.h diff --git a/usr.sbin/bind/lib/isc/include/isc/platform.h.in b/usr.sbin/bind/lib/isc/include/isc/platform.h.in index 4430aabeb7f..78797b564fa 100644 --- a/usr.sbin/bind/lib/isc/include/isc/platform.h.in +++ b/usr.sbin/bind/lib/isc/include/isc/platform.h.in @@ -28,57 +28,6 @@ ***/ /* - * If the "xadd" operation is available on this architecture, - * ISC_PLATFORM_HAVEXADD will be defined. - */ -@ISC_PLATFORM_HAVEXADD@ - -/* - * If the "xaddq" operation (64bit xadd) is available on this architecture, - * ISC_PLATFORM_HAVEXADDQ will be defined. - */ -@ISC_PLATFORM_HAVEXADDQ@ - -/* - * If the 32-bit "atomic swap" operation is available on this - * architecture, ISC_PLATFORM_HAVEATOMICSTORE" will be defined. - */ -@ISC_PLATFORM_HAVEATOMICSTORE@ - -/* - * If the 64-bit "atomic swap" operation is available on this - * architecture, ISC_PLATFORM_HAVEATOMICSTORE" will be defined. - */ -@ISC_PLATFORM_HAVEATOMICSTOREQ@ - -/* - * If the "compare-and-exchange" operation is available on this architecture, - * ISC_PLATFORM_HAVECMPXCHG will be defined. - */ -@ISC_PLATFORM_HAVECMPXCHG@ - -/* - * If <stdatomic.h> is available on this architecture, - * ISC_PLATFORM_HAVESTDATOMIC will be defined. - */ -@ISC_PLATFORM_HAVESTDATOMIC@ - -/* - * Define if gcc ASM extension is available - */ -@ISC_PLATFORM_USEGCCASM@ - -/* - * Define if Tru64 style ASM syntax must be used. - */ -@ISC_PLATFORM_USEOSFASM@ - -/* - * Define if the standard __asm function must be used. - */ -@ISC_PLATFORM_USESTDASM@ - -/* * Define if the hash functions must be provided by OpenSSL. */ @ISC_PLATFORM_OPENSSLHASH@ @@ -90,12 +39,6 @@ @ISC_PLATFORM_NORETURN_POST@ /* - * Define if MacOS style of PPC assembly must be used. - * e.g. "r6", not "6", for register six. - */ -@ISC_PLATFORM_USEMACASM@ - -/* * Tell emacs to use C mode for this file. * * Local Variables: diff --git a/usr.sbin/bind/lib/isc/include/isc/refcount.h b/usr.sbin/bind/lib/isc/include/isc/refcount.h index b413017c788..0982d1afdff 100644 --- a/usr.sbin/bind/lib/isc/include/isc/refcount.h +++ b/usr.sbin/bind/lib/isc/include/isc/refcount.h @@ -14,23 +14,19 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: refcount.h,v 1.7 2020/01/07 19:08:09 florian Exp $ */ +/* $Id: refcount.h,v 1.8 2020/01/09 18:14:48 florian Exp $ */ #ifndef ISC_REFCOUNT_H #define ISC_REFCOUNT_H 1 #include <isc/assertions.h> -#include <isc/atomic.h> + #include <isc/error.h> #include <isc/lang.h> #include <isc/mutex.h> #include <isc/platform.h> #include <isc/types.h> -#if defined(ISC_PLATFORM_HAVESTDATOMIC) -#include <stdatomic.h> -#endif - /*! \file isc/refcount.h * \brief Implements a locked reference counter. * diff --git a/usr.sbin/bind/lib/isc/include/isc/rwlock.h b/usr.sbin/bind/lib/isc/include/isc/rwlock.h index 3b6bd2697e4..3640da9d648 100644 --- a/usr.sbin/bind/lib/isc/include/isc/rwlock.h +++ b/usr.sbin/bind/lib/isc/include/isc/rwlock.h @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rwlock.h,v 1.7 2020/01/07 19:08:09 florian Exp $ */ +/* $Id: rwlock.h,v 1.8 2020/01/09 18:14:48 florian Exp $ */ #ifndef ISC_RWLOCK_H #define ISC_RWLOCK_H 1 @@ -26,11 +26,6 @@ #include <isc/platform.h> #include <isc/types.h> -#if defined(ISC_PLATFORM_HAVESTDATOMIC) -#include <stdint.h> -#include <stdatomic.h> -#endif - ISC_LANG_BEGINDECLS typedef enum { diff --git a/usr.sbin/bind/lib/isc/include/isc/stats.h b/usr.sbin/bind/lib/isc/include/isc/stats.h deleted file mode 100644 index 7e2fa71015f..00000000000 --- a/usr.sbin/bind/lib/isc/include/isc/stats.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stats.h,v 1.2 2019/12/17 01:46:35 sthen Exp $ */ - -#ifndef ISC_STATS_H -#define ISC_STATS_H 1 - -/*! \file isc/stats.h */ - -#include <isc/types.h> - -ISC_LANG_BEGINDECLS - -/*%< - * Flag(s) for isc_stats_dump(). - */ -#define ISC_STATSDUMP_VERBOSE 0x00000001 /*%< dump 0-value counters */ - -/*%< - * Dump callback type. - */ -typedef void (*isc_stats_dumper_t)(isc_statscounter_t, isc_uint64_t, void *); - -isc_result_t -isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters); -/*%< - * Create a statistics counter structure of general type. It counts a general - * set of counters indexed by an ID between 0 and ncounters -1. - * - * Requires: - *\li 'mctx' must be a valid memory context. - * - *\li 'statsp' != NULL && '*statsp' == NULL. - * - * Returns: - *\li ISC_R_SUCCESS -- all ok - * - *\li anything else -- failure - */ - -void -isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp); -/*%< - * Attach to a statistics set. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - * - *\li 'statsp' != NULL && '*statsp' == NULL - */ - -void -isc_stats_detach(isc_stats_t **statsp); -/*%< - * Detaches from the statistics set. - * - * Requires: - *\li 'statsp' != NULL and '*statsp' is a valid isc_stats_t. - */ - -int -isc_stats_ncounters(isc_stats_t *stats); -/*%< - * Returns the number of counters contained in stats. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - * - */ - -void -isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter); -/*%< - * Increment the counter-th counter of stats. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - * - *\li counter is less than the maximum available ID for the stats specified - * on creation. - */ - -void -isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter); -/*%< - * Decrement the counter-th counter of stats. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - */ - -void -isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, void *arg, - unsigned int options); -/*%< - * Dump the current statistics counters in a specified way. For each counter - * in stats, dump_fn is called with its current value and the given argument - * arg. By default counters that have a value of 0 is skipped; if options has - * the ISC_STATSDUMP_VERBOSE flag, even such counters are dumped. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - */ - -void -isc_stats_set(isc_stats_t *stats, isc_uint64_t val, - isc_statscounter_t counter); -/*%< - * Set the given counter to the specfied value. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - */ - -void -isc_stats_set(isc_stats_t *stats, isc_uint64_t val, - isc_statscounter_t counter); -/*%< - * Set the given counter to the specfied value. - * - * Requires: - *\li 'stats' is a valid isc_stats_t. - */ - -ISC_LANG_ENDDECLS - -#endif /* ISC_STATS_H */ diff --git a/usr.sbin/bind/lib/isc/mips/Makefile.in b/usr.sbin/bind/lib/isc/mips/Makefile.in deleted file mode 100644 index 5831ff61b35..00000000000 --- a/usr.sbin/bind/lib/isc/mips/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:35 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/mips/include/Makefile.in b/usr.sbin/bind/lib/isc/mips/include/Makefile.in deleted file mode 100644 index 26e6c3bd7f5..00000000000 --- a/usr.sbin/bind/lib/isc/mips/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:35 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/mips/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/mips/include/isc/Makefile.in deleted file mode 100644 index aefa23abcd5..00000000000 --- a/usr.sbin/bind/lib/isc/mips/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:35 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/mips/include/isc/atomic.h b/usr.sbin/bind/lib/isc/mips/include/isc/atomic.h deleted file mode 100644 index 2434791efc0..00000000000 --- a/usr.sbin/bind/lib/isc/mips/include/isc/atomic.h +++ /dev/null @@ -1,94 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.3 2019/12/17 01:46:35 sthen Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, int val) { - isc_int32_t orig; - - __asm__ __volatile__ ( - " .set push \n" - " .set mips2 \n" - " .set noreorder \n" - " .set noat \n" - "1: ll $1, %1 \n" - " addu %0, $1, %2 \n" - " sc %0, %1 \n" - " beqz %0, 1b \n" - " move %0, $1 \n" - " .set pop \n" - : "=&r" (orig), "+R" (*p) - : "r" (val) - : "memory"); - - return (orig); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - *p = val; -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, int cmpval, int val) { - isc_int32_t orig; - isc_int32_t tmp; - - __asm__ __volatile__ ( - " .set push \n" - " .set mips2 \n" - " .set noreorder \n" - " .set noat \n" - "1: ll $1, %1 \n" - " bne $1, %3, 2f \n" - " move %2, %4 \n" - " sc %2, %1 \n" - " beqz %2, 1b \n" - "2: move %0, $1 \n" - " .set pop \n" - : "=&r"(orig), "+R" (*p), "=r" (tmp) - : "r"(cmpval), "r"(val) - : "memory"); - - return (orig); -} - -#else /* !ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/noatomic/Makefile.in b/usr.sbin/bind/lib/isc/noatomic/Makefile.in deleted file mode 100644 index fbb45ceca23..00000000000 --- a/usr.sbin/bind/lib/isc/noatomic/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/noatomic/include/Makefile.in b/usr.sbin/bind/lib/isc/noatomic/include/Makefile.in deleted file mode 100644 index 01fdc099eef..00000000000 --- a/usr.sbin/bind/lib/isc/noatomic/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/noatomic/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/noatomic/include/isc/Makefile.in deleted file mode 100644 index dcdcb942fd4..00000000000 --- a/usr.sbin/bind/lib/isc/noatomic/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/noatomic/include/isc/atomic.h b/usr.sbin/bind/lib/isc/noatomic/include/isc/atomic.h deleted file mode 100644 index 5804285062e..00000000000 --- a/usr.sbin/bind/lib/isc/noatomic/include/isc/atomic.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.3 2019/12/17 01:46:36 sthen Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -/* This file is inherently empty. */ - -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/powerpc/Makefile.in b/usr.sbin/bind/lib/isc/powerpc/Makefile.in deleted file mode 100644 index fbb45ceca23..00000000000 --- a/usr.sbin/bind/lib/isc/powerpc/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/powerpc/include/Makefile.in b/usr.sbin/bind/lib/isc/powerpc/include/Makefile.in deleted file mode 100644 index 01fdc099eef..00000000000 --- a/usr.sbin/bind/lib/isc/powerpc/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/powerpc/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/powerpc/include/isc/Makefile.in deleted file mode 100644 index dcdcb942fd4..00000000000 --- a/usr.sbin/bind/lib/isc/powerpc/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/powerpc/include/isc/atomic.h b/usr.sbin/bind/lib/isc/powerpc/include/isc/atomic.h deleted file mode 100644 index fcda930e4f1..00000000000 --- a/usr.sbin/bind/lib/isc/powerpc/include/isc/atomic.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.4 2019/12/18 20:33:49 sthen Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -/*!\file - * static inline isc_int32_t - * isc_atomic_xadd(isc_int32_t *p, isc_int32_t val); - * - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - * - * static inline void - * isc_atomic_store(void *p, isc_int32_t val); - * - * This routine atomically stores the value 'val' in 'p'. - * - * static inline isc_int32_t - * isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val); - * - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ - -#if defined(ISC_PLATFORM_USEGCCASM) || defined(ISC_PLATFORM_USEMACASM) -static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - isc_int32_t orig; - - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %1\n" - "mr %0, r6\n" - "add r6, r6, %2\n" - "stwcx. r6, 0, %1\n" - "bne- 1b\n" - "sync" -#else - "1:" - "lwarx 6, 0, %1\n" - "mr %0, 6\n" - "add 6, 6, %2\n" - "stwcx. 6, 0, %1\n" - "bne- 1b\n" - "sync" -#endif - : "=&r"(orig) - : "r"(p), "r"(val) - : "r6", "memory" - ); - - return (orig); -} - -static inline void -isc_atomic_store(void *p, isc_int32_t val) { - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %0\n" - "lwz r6, %1\n" - "stwcx. r6, 0, %0\n" - "bne- 1b\n" - "sync" -#else - "1:" - "lwarx 6, 0, %0\n" - "lwz 6, %1\n" - "stwcx. 6, 0, %0\n" - "bne- 1b\n" - "sync" -#endif - : - : "r"(p), "m"(val) - : "r6", "memory" - ); -} - -static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - isc_int32_t orig; - - __asm__ volatile ( -#ifdef ISC_PLATFORM_USEMACASM - "1:" - "lwarx r6, 0, %1\n" - "mr %0,r6\n" - "cmpw r6, %2\n" - "bne 2f\n" - "mr r6, %3\n" - "stwcx. r6, 0, %1\n" - "bne- 1b\n" - "2:\n" - "sync" -#else - "1:" - "lwarx 6, 0, %1\n" - "mr %0,6\n" - "cmpw 6, %2\n" - "bne 2f\n" - "mr 6, %3\n" - "stwcx. 6, 0, %1\n" - "bne- 1b\n" - "2:\n" - "sync" -#endif - : "=&r" (orig) - : "r"(p), "r"(cmpval), "r"(val) - : "r6", "memory" - ); - - return (orig); -} - -#else - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/rwlock.c b/usr.sbin/bind/lib/isc/rwlock.c index ec07636f144..95d4d05ed42 100644 --- a/usr.sbin/bind/lib/isc/rwlock.c +++ b/usr.sbin/bind/lib/isc/rwlock.c @@ -14,7 +14,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rwlock.c,v 1.9 2020/01/09 13:47:14 florian Exp $ */ +/* $Id: rwlock.c,v 1.10 2020/01/09 18:14:48 florian Exp $ */ /*! \file */ @@ -22,7 +22,7 @@ #include <stddef.h> -#include <isc/atomic.h> + #include <isc/magic.h> #include <isc/msgs.h> #include <isc/platform.h> diff --git a/usr.sbin/bind/lib/isc/sparc64/Makefile.in b/usr.sbin/bind/lib/isc/sparc64/Makefile.in deleted file mode 100644 index fbb45ceca23..00000000000 --- a/usr.sbin/bind/lib/isc/sparc64/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/sparc64/include/Makefile.in b/usr.sbin/bind/lib/isc/sparc64/include/Makefile.in deleted file mode 100644 index 01fdc099eef..00000000000 --- a/usr.sbin/bind/lib/isc/sparc64/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/sparc64/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/sparc64/include/isc/Makefile.in deleted file mode 100644 index 4219b9ae09f..00000000000 --- a/usr.sbin/bind/lib/isc/sparc64/include/isc/Makefile.in +++ /dev/null @@ -1,36 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:36 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done diff --git a/usr.sbin/bind/lib/isc/sparc64/include/isc/atomic.h b/usr.sbin/bind/lib/isc/sparc64/include/isc/atomic.h deleted file mode 100644 index 92ecf87a08e..00000000000 --- a/usr.sbin/bind/lib/isc/sparc64/include/isc/atomic.h +++ /dev/null @@ -1,126 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.3 2019/12/17 01:46:36 sthen Exp $ */ - -/* - * This code was written based on FreeBSD's kernel source whose copyright - * follows: - */ - -/*- - * Copyright (c) 1998 Doug Rabson. - * Copyright (c) 2001 Jake Burkholder. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: FreeBSD: src/sys/i386/include/atomic.h,v 1.20 2001/02/11 - * $FreeBSD: src/sys/sparc64/include/atomic.h,v 1.8 2004/05/22 00:52:16 marius Exp $ - */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#define ASI_P 0x80 /* Primary Address Space Identifier */ - -#ifdef ISC_PLATFORM_USEGCCASM - -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static inline isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - isc_int32_t prev, swapped; - - for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) { - swapped = prev + val; - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(swapped), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); - if (swapped == prev) - break; - } - - return (prev); -} - -/* - * This routine atomically stores the value 'val' in 'p'. - */ -static inline void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - isc_int32_t prev, swapped; - - for (prev = *(volatile isc_int32_t *)p; ; prev = swapped) { - swapped = val; - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(swapped), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(prev), "m"(*p)); - if (swapped == prev) - break; - } -} - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static inline isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - isc_int32_t temp = val; - - __asm__ volatile( - "casa [%2] %3, %4, %0" - : "+r"(temp), "=m"(*p) - : "r"(p), "n"(ASI_P), "r"(cmpval), "m"(*p)); - - return (temp); -} - -#else /* ISC_PLATFORM_USEGCCASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif /* ISC_PLATFORM_USEGCCASM */ - -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/stats.c b/usr.sbin/bind/lib/isc/stats.c deleted file mode 100644 index 282c738b642..00000000000 --- a/usr.sbin/bind/lib/isc/stats.c +++ /dev/null @@ -1,455 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: stats.c,v 1.3 2020/01/09 13:47:14 florian Exp $ */ - -/*! \file */ - -#include <config.h> - -#include <string.h> - -#include <isc/atomic.h> -#include <isc/buffer.h> -#include <isc/magic.h> -#include <isc/mem.h> -#include <isc/platform.h> - -#include <isc/rwlock.h> -#include <isc/stats.h> -#include <isc/util.h> - -#if defined(ISC_PLATFORM_HAVESTDATOMIC) -#include <stdatomic.h> -#endif - -#define ISC_STATS_MAGIC ISC_MAGIC('S', 't', 'a', 't') -#define ISC_STATS_VALID(x) ISC_MAGIC_VALID(x, ISC_STATS_MAGIC) - -/*% - * Local macro confirming prescence of 64-bit - * increment and store operations, just to make - * the later macros simpler - */ -#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE)) || \ - (defined(ISC_PLATFORM_HAVEXADDQ) && defined(ISC_PLATFORM_HAVEATOMICSTOREQ)) -#define ISC_STATS_HAVEATOMICQ 1 -#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_LONG_LOCK_FREE)) -#define ISC_STATS_HAVESTDATOMICQ 1 -#endif -#else -#define ISC_STATS_HAVEATOMICQ 0 -#endif - -/*% - * Only lock the counters if 64-bit atomic operations are - * not available but cheap atomic lock operations are. - * On a modern 64-bit system this should never be the case. - * - * Normal locks are too expensive to be used whenever a counter - * is updated. - */ -#if !ISC_STATS_HAVEATOMICQ && defined(ISC_RWLOCK_HAVEATOMIC) -#define ISC_STATS_LOCKCOUNTERS 1 -#else -#define ISC_STATS_LOCKCOUNTERS 0 -#endif - -/*% - * If 64-bit atomic operations are not available but - * 32-bit operations are then split the counter into two, - * using the atomic operations to try to ensure that any carry - * from the low word is correctly carried into the high word. - * - * Otherwise, just rely on standard 64-bit data types - * and operations - */ -#if !ISC_STATS_HAVEATOMICQ && ((defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) || defined(ISC_PLATFORM_HAVEXADD)) -#define ISC_STATS_USEMULTIFIELDS 1 -#if (defined(ISC_PLATFORM_HAVESTDATOMIC) && defined(ATOMIC_INT_LOCK_FREE)) -#define ISC_STATS_HAVESTDATOMIC 1 -#endif -#else -#define ISC_STATS_USEMULTIFIELDS 0 -#endif - -#if ISC_STATS_USEMULTIFIELDS -typedef struct { -#if defined(ISC_STATS_HAVESTDATOMIC) - atomic_int_fast32_t hi; - atomic_int_fast32_t lo; -#else - isc_uint32_t hi; - isc_uint32_t lo; -#endif -} isc_stat_t; -#else -#if defined(ISC_STATS_HAVESTDATOMICQ) -typedef atomic_int_fast64_t isc_stat_t; -#else -typedef isc_uint64_t isc_stat_t; -#endif -#endif - -struct isc_stats { - /*% Unlocked */ - unsigned int magic; - isc_mem_t *mctx; - int ncounters; - - isc_mutex_t lock; - unsigned int references; /* locked by lock */ - - /*% - * Locked by counterlock or unlocked if efficient rwlock is not - * available. - */ -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_t counterlock; -#endif - isc_stat_t *counters; - - /*% - * We don't want to lock the counters while we are dumping, so we first - * copy the current counter values into a local array. This buffer - * will be used as the copy destination. It's allocated on creation - * of the stats structure so that the dump operation won't fail due - * to memory allocation failure. - * XXX: this approach is weird for non-threaded build because the - * additional memory and the copy overhead could be avoided. We prefer - * simplicity here, however, under the assumption that this function - * should be only rarely called. - */ - isc_uint64_t *copiedcounters; -}; - -static isc_result_t -create_stats(isc_mem_t *mctx, int ncounters, isc_stats_t **statsp) { - isc_stats_t *stats; - isc_result_t result = ISC_R_SUCCESS; - - REQUIRE(statsp != NULL && *statsp == NULL); - - stats = isc_mem_get(mctx, sizeof(*stats)); - if (stats == NULL) - return (ISC_R_NOMEMORY); - - result = isc_mutex_init(&stats->lock); - if (result != ISC_R_SUCCESS) - goto clean_stats; - - stats->counters = isc_mem_get(mctx, sizeof(isc_stat_t) * ncounters); - if (stats->counters == NULL) { - result = ISC_R_NOMEMORY; - goto clean_mutex; - } - stats->copiedcounters = isc_mem_get(mctx, - sizeof(isc_uint64_t) * ncounters); - if (stats->copiedcounters == NULL) { - result = ISC_R_NOMEMORY; - goto clean_counters; - } - -#if ISC_STATS_LOCKCOUNTERS - result = isc_rwlock_init(&stats->counterlock, 0, 0); - if (result != ISC_R_SUCCESS) - goto clean_copiedcounters; -#endif - - stats->references = 1; - memset(stats->counters, 0, sizeof(isc_stat_t) * ncounters); - stats->mctx = NULL; - isc_mem_attach(mctx, &stats->mctx); - stats->ncounters = ncounters; - stats->magic = ISC_STATS_MAGIC; - - *statsp = stats; - - return (result); - -clean_counters: - isc_mem_put(mctx, stats->counters, sizeof(isc_stat_t) * ncounters); - -#if ISC_STATS_LOCKCOUNTERS -clean_copiedcounters: - isc_mem_put(mctx, stats->copiedcounters, - sizeof(isc_stat_t) * ncounters); -#endif - -clean_mutex: - DESTROYLOCK(&stats->lock); - -clean_stats: - isc_mem_put(mctx, stats, sizeof(*stats)); - - return (result); -} - -void -isc_stats_attach(isc_stats_t *stats, isc_stats_t **statsp) { - REQUIRE(ISC_STATS_VALID(stats)); - REQUIRE(statsp != NULL && *statsp == NULL); - - LOCK(&stats->lock); - stats->references++; - UNLOCK(&stats->lock); - - *statsp = stats; -} - -void -isc_stats_detach(isc_stats_t **statsp) { - isc_stats_t *stats; - - REQUIRE(statsp != NULL && ISC_STATS_VALID(*statsp)); - - stats = *statsp; - *statsp = NULL; - - LOCK(&stats->lock); - stats->references--; - - if (stats->references == 0) { - isc_mem_put(stats->mctx, stats->copiedcounters, - sizeof(isc_stat_t) * stats->ncounters); - isc_mem_put(stats->mctx, stats->counters, - sizeof(isc_stat_t) * stats->ncounters); - UNLOCK(&stats->lock); - DESTROYLOCK(&stats->lock); -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_destroy(&stats->counterlock); -#endif - isc_mem_putanddetach(&stats->mctx, stats, sizeof(*stats)); - return; - } - - UNLOCK(&stats->lock); -} - -int -isc_stats_ncounters(isc_stats_t *stats) { - REQUIRE(ISC_STATS_VALID(stats)); - - return (stats->ncounters); -} - -static inline void -incrementcounter(isc_stats_t *stats, int counter) { - isc_int32_t prev; - -#if ISC_STATS_LOCKCOUNTERS - /* - * We use a "read" lock to prevent other threads from reading the - * counter while we "writing" a counter field. The write access itself - * is protected by the atomic operation. - */ - isc_rwlock_lock(&stats->counterlock, isc_rwlocktype_read); -#endif - -#if ISC_STATS_USEMULTIFIELDS -#if defined(ISC_STATS_HAVESTDATOMIC) - prev = atomic_fetch_add_explicit(&stats->counters[counter].lo, 1, - memory_order_relaxed); -#else - prev = isc_atomic_xadd((isc_int32_t *)&stats->counters[counter].lo, 1); -#endif - /* - * If the lower 32-bit field overflows, increment the higher field. - * Note that it's *theoretically* possible that the lower field - * overlaps again before the higher field is incremented. It doesn't - * matter, however, because we don't read the value until - * isc_stats_copy() is called where the whole process is protected - * by the write (exclusive) lock. - */ - if (prev == (isc_int32_t)0xffffffff) { -#if defined(ISC_STATS_HAVESTDATOMIC) - atomic_fetch_add_explicit(&stats->counters[counter].hi, 1, - memory_order_relaxed); -#else - isc_atomic_xadd((isc_int32_t *)&stats->counters[counter].hi, 1); -#endif - } -#elif ISC_STATS_HAVEATOMICQ - UNUSED(prev); -#if defined(ISC_STATS_HAVESTDATOMICQ) - atomic_fetch_add_explicit(&stats->counters[counter], 1, - memory_order_relaxed); -#else - isc_atomic_xaddq((isc_int64_t *)&stats->counters[counter], 1); -#endif -#else - UNUSED(prev); - stats->counters[counter]++; -#endif - -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_unlock(&stats->counterlock, isc_rwlocktype_read); -#endif -} - -static inline void -decrementcounter(isc_stats_t *stats, int counter) { - isc_int32_t prev; - -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_lock(&stats->counterlock, isc_rwlocktype_read); -#endif - -#if ISC_STATS_USEMULTIFIELDS -#if defined(ISC_STATS_HAVESTDATOMIC) - prev = atomic_fetch_sub_explicit(&stats->counters[counter].lo, 1, - memory_order_relaxed); -#else - prev = isc_atomic_xadd((isc_int32_t *)&stats->counters[counter].lo, -1); -#endif - if (prev == 0) { -#if defined(ISC_STATS_HAVESTDATOMIC) - atomic_fetch_sub_explicit(&stats->counters[counter].hi, 1, - memory_order_relaxed); -#else - isc_atomic_xadd((isc_int32_t *)&stats->counters[counter].hi, - -1); -#endif - } -#elif ISC_STATS_HAVEATOMICQ - UNUSED(prev); -#if defined(ISC_STATS_HAVESTDATOMICQ) - atomic_fetch_sub_explicit(&stats->counters[counter], 1, - memory_order_relaxed); -#else - isc_atomic_xaddq((isc_int64_t *)&stats->counters[counter], -1); -#endif -#else - UNUSED(prev); - stats->counters[counter]--; -#endif - -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_unlock(&stats->counterlock, isc_rwlocktype_read); -#endif -} - -static void -copy_counters(isc_stats_t *stats) { - int i; - -#if ISC_STATS_LOCKCOUNTERS - /* - * We use a "write" lock before "reading" the statistics counters as - * an exclusive lock. - */ - isc_rwlock_lock(&stats->counterlock, isc_rwlocktype_write); -#endif - - for (i = 0; i < stats->ncounters; i++) { -#if ISC_STATS_USEMULTIFIELDS - stats->copiedcounters[i] = - (isc_uint64_t)(stats->counters[i].hi) << 32 | - stats->counters[i].lo; -#elif ISC_STATS_HAVEATOMICQ -#if defined(ISC_STATS_HAVESTDATOMICQ) - stats->copiedcounters[i] = - atomic_load_explicit(&stats->counters[i], - memory_order_relaxed); -#else - /* use xaddq(..., 0) as an atomic load */ - stats->copiedcounters[i] = - (isc_uint64_t)isc_atomic_xaddq((isc_int64_t *)&stats->counters[i], 0); -#endif -#else - stats->copiedcounters[i] = stats->counters[i]; -#endif - } - -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_unlock(&stats->counterlock, isc_rwlocktype_write); -#endif -} - -isc_result_t -isc_stats_create(isc_mem_t *mctx, isc_stats_t **statsp, int ncounters) { - REQUIRE(statsp != NULL && *statsp == NULL); - - return (create_stats(mctx, ncounters, statsp)); -} - -void -isc_stats_increment(isc_stats_t *stats, isc_statscounter_t counter) { - REQUIRE(ISC_STATS_VALID(stats)); - REQUIRE(counter < stats->ncounters); - - incrementcounter(stats, (int)counter); -} - -void -isc_stats_decrement(isc_stats_t *stats, isc_statscounter_t counter) { - REQUIRE(ISC_STATS_VALID(stats)); - REQUIRE(counter < stats->ncounters); - - decrementcounter(stats, (int)counter); -} - -void -isc_stats_dump(isc_stats_t *stats, isc_stats_dumper_t dump_fn, - void *arg, unsigned int options) -{ - int i; - - REQUIRE(ISC_STATS_VALID(stats)); - - copy_counters(stats); - - for (i = 0; i < stats->ncounters; i++) { - if ((options & ISC_STATSDUMP_VERBOSE) == 0 && - stats->copiedcounters[i] == 0) - continue; - dump_fn((isc_statscounter_t)i, stats->copiedcounters[i], arg); - } -} - -void -isc_stats_set(isc_stats_t *stats, isc_uint64_t val, - isc_statscounter_t counter) -{ - REQUIRE(ISC_STATS_VALID(stats)); - REQUIRE(counter < stats->ncounters); - -#if ISC_STATS_LOCKCOUNTERS - /* - * We use a "write" lock before "reading" the statistics counters as - * an exclusive lock. - */ - isc_rwlock_lock(&stats->counterlock, isc_rwlocktype_write); -#endif - -#if ISC_STATS_USEMULTIFIELDS - stats->counters[counter].hi = (isc_uint32_t)((val >> 32) & 0xffffffff); - stats->counters[counter].lo = (isc_uint32_t)(val & 0xffffffff); -#elif ISC_STATS_HAVEATOMICQ -#if defined(ISC_STATS_HAVESTDATOMICQ) - atomic_store_explicit(&stats->counters[counter], val, - memory_order_relaxed); -#else - isc_atomic_storeq((isc_int64_t *)&stats->counters[counter], val); -#endif -#else - stats->counters[counter] = val; -#endif - -#if ISC_STATS_LOCKCOUNTERS - isc_rwlock_unlock(&stats->counterlock, isc_rwlocktype_write); -#endif -} diff --git a/usr.sbin/bind/lib/isc/unix/socket.c b/usr.sbin/bind/lib/isc/unix/socket.c index 6dc3c30881f..203a5afe9fc 100644 --- a/usr.sbin/bind/lib/isc/unix/socket.c +++ b/usr.sbin/bind/lib/isc/unix/socket.c @@ -57,7 +57,7 @@ #include <isc/region.h> #include <isc/resource.h> #include <isc/socket.h> -#include <isc/stats.h> + #include <isc/strerror.h> #include <isc/string.h> #include <isc/task.h> @@ -306,7 +306,6 @@ struct isc__socket { isc__socketmgr_t *manager; isc_mutex_t lock; isc_sockettype_t type; - const isc_statscounter_t *statsindex; /* Locked by socket lock. */ ISC_LINK(isc__socket_t) link; @@ -362,7 +361,6 @@ struct isc__socketmgr { isc_mem_t *mctx; isc_mutex_t lock; isc_mutex_t *fdlock; - isc_stats_t *stats; #ifdef USE_KQUEUE int kqueue_fd; int nevents; @@ -568,8 +566,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp, isc_result_t isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp); void -isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats); -void isc__socketmgr_destroy(isc_socketmgr_t **managerp); void isc__socket_setname(isc_socket_t *socket0, const char *name, void *tag); @@ -654,97 +650,6 @@ enum { STATID_RECVFAIL = 9, STATID_ACTIVE = 10 }; -static const isc_statscounter_t udp4statsindex[] = { - isc_sockstatscounter_udp4open, - isc_sockstatscounter_udp4openfail, - isc_sockstatscounter_udp4close, - isc_sockstatscounter_udp4bindfail, - isc_sockstatscounter_udp4connectfail, - isc_sockstatscounter_udp4connect, - -1, - -1, - isc_sockstatscounter_udp4sendfail, - isc_sockstatscounter_udp4recvfail, - isc_sockstatscounter_udp4active -}; -static const isc_statscounter_t udp6statsindex[] = { - isc_sockstatscounter_udp6open, - isc_sockstatscounter_udp6openfail, - isc_sockstatscounter_udp6close, - isc_sockstatscounter_udp6bindfail, - isc_sockstatscounter_udp6connectfail, - isc_sockstatscounter_udp6connect, - -1, - -1, - isc_sockstatscounter_udp6sendfail, - isc_sockstatscounter_udp6recvfail, - isc_sockstatscounter_udp6active -}; -static const isc_statscounter_t tcp4statsindex[] = { - isc_sockstatscounter_tcp4open, - isc_sockstatscounter_tcp4openfail, - isc_sockstatscounter_tcp4close, - isc_sockstatscounter_tcp4bindfail, - isc_sockstatscounter_tcp4connectfail, - isc_sockstatscounter_tcp4connect, - isc_sockstatscounter_tcp4acceptfail, - isc_sockstatscounter_tcp4accept, - isc_sockstatscounter_tcp4sendfail, - isc_sockstatscounter_tcp4recvfail, - isc_sockstatscounter_tcp4active -}; -static const isc_statscounter_t tcp6statsindex[] = { - isc_sockstatscounter_tcp6open, - isc_sockstatscounter_tcp6openfail, - isc_sockstatscounter_tcp6close, - isc_sockstatscounter_tcp6bindfail, - isc_sockstatscounter_tcp6connectfail, - isc_sockstatscounter_tcp6connect, - isc_sockstatscounter_tcp6acceptfail, - isc_sockstatscounter_tcp6accept, - isc_sockstatscounter_tcp6sendfail, - isc_sockstatscounter_tcp6recvfail, - isc_sockstatscounter_tcp6active -}; -static const isc_statscounter_t unixstatsindex[] = { - isc_sockstatscounter_unixopen, - isc_sockstatscounter_unixopenfail, - isc_sockstatscounter_unixclose, - isc_sockstatscounter_unixbindfail, - isc_sockstatscounter_unixconnectfail, - isc_sockstatscounter_unixconnect, - isc_sockstatscounter_unixacceptfail, - isc_sockstatscounter_unixaccept, - isc_sockstatscounter_unixsendfail, - isc_sockstatscounter_unixrecvfail, - isc_sockstatscounter_unixactive -}; -static const isc_statscounter_t fdwatchstatsindex[] = { - -1, - -1, - isc_sockstatscounter_fdwatchclose, - isc_sockstatscounter_fdwatchbindfail, - isc_sockstatscounter_fdwatchconnectfail, - isc_sockstatscounter_fdwatchconnect, - -1, - -1, - isc_sockstatscounter_fdwatchsendfail, - isc_sockstatscounter_fdwatchrecvfail, - -1 -}; -static const isc_statscounter_t rawstatsindex[] = { - isc_sockstatscounter_rawopen, - isc_sockstatscounter_rawopenfail, - isc_sockstatscounter_rawclose, - -1, - -1, - -1, - -1, - -1, - -1, - isc_sockstatscounter_rawrecvfail, - isc_sockstatscounter_rawactive -}; #if defined(USE_KQUEUE) || defined(USE_EPOLL) || defined(USE_DEVPOLL) || \ defined(USE_WATCHER_THREAD) @@ -806,28 +711,6 @@ socket_log(isc__socket_t *sock, isc_sockaddr_t *address, } } -/*% - * Increment socket-related statistics counters. - */ -static inline void -inc_stats(isc_stats_t *stats, isc_statscounter_t counterid) { - REQUIRE(counterid != -1); - - if (stats != NULL) - isc_stats_increment(stats, counterid); -} - -/*% - * Decrement socket-related statistics counters. - */ -static inline void -dec_stats(isc_stats_t *stats, isc_statscounter_t counterid) { - REQUIRE(counterid != -1); - - if (stats != NULL) - isc_stats_decrement(stats, counterid); -} - static inline isc_result_t watch_fd(isc__socketmgr_t *manager, int fd, int msg) { isc_result_t result = ISC_R_SUCCESS; @@ -1778,8 +1661,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { if (recv_errno == _system) { \ if (sock->connected) { \ dev->result = _isc; \ - inc_stats(sock->manager->stats, \ - sock->statsindex[STATID_RECVFAIL]); \ return (DOIO_HARD); \ } \ return (DOIO_SOFT); \ @@ -1787,8 +1668,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { #define ALWAYS_HARD(_system, _isc) \ if (recv_errno == _system) { \ dev->result = _isc; \ - inc_stats(sock->manager->stats, \ - sock->statsindex[STATID_RECVFAIL]); \ return (DOIO_HARD); \ } @@ -1816,8 +1695,6 @@ doio_recv(isc__socket_t *sock, isc_socketevent_t *dev) { #undef ALWAYS_HARD dev->result = isc__errno2result(recv_errno); - inc_stats(sock->manager->stats, - sock->statsindex[STATID_RECVFAIL]); return (DOIO_HARD); } @@ -1972,8 +1849,6 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) { if (send_errno == _system) { \ if (sock->connected) { \ dev->result = _isc; \ - inc_stats(sock->manager->stats, \ - sock->statsindex[STATID_SENDFAIL]); \ return (DOIO_HARD); \ } \ return (DOIO_SOFT); \ @@ -1981,8 +1856,6 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) { #define ALWAYS_HARD(_system, _isc) \ if (send_errno == _system) { \ dev->result = _isc; \ - inc_stats(sock->manager->stats, \ - sock->statsindex[STATID_SENDFAIL]); \ return (DOIO_HARD); \ } @@ -2017,14 +1890,10 @@ doio_send(isc__socket_t *sock, isc_socketevent_t *dev) { UNEXPECTED_ERROR(__FILE__, __LINE__, "internal_send: %s: %s", addrbuf, strbuf); dev->result = isc__errno2result(send_errno); - inc_stats(sock->manager->stats, - sock->statsindex[STATID_SENDFAIL]); return (DOIO_HARD); } if (cc == 0) { - inc_stats(sock->manager->stats, - sock->statsindex[STATID_SENDFAIL]); UNEXPECTED_ERROR(__FILE__, __LINE__, "doio_send: send() %s 0", isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL, @@ -2083,9 +1952,7 @@ socketclose(isc__socketmgr_t *manager, isc__socket_t *sock, int fd) { } else select_poke(manager, fd, SELECT_POKE_CLOSE); - inc_stats(manager->stats, sock->statsindex[STATID_CLOSE]); if (sock->active == 1) { - dec_stats(manager->stats, sock->statsindex[STATID_ACTIVE]); sock->active = 0; } @@ -2173,7 +2040,6 @@ allocate_socket(isc__socketmgr_t *manager, isc_sockettype_t type, sock->fd = -1; sock->dscp = 0; /* TOS/TCLASS is zero until set. */ sock->dupped = 0; - sock->statsindex = NULL; sock->active = 0; ISC_LINK_INIT(sock, link); @@ -2500,7 +2366,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, ISC_MSG_TOOMANYFDS, "socket: file descriptor exceeds limit (%d/%u)", sock->fd, manager->maxsocks); - inc_stats(manager->stats, sock->statsindex[STATID_OPENFAIL]); return (ISC_R_NORESOURCES); } @@ -2516,8 +2381,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, "%s: %s", err, strbuf); /* fallthrough */ case ENOBUFS: - inc_stats(manager->stats, - sock->statsindex[STATID_OPENFAIL]); return (ISC_R_NORESOURCES); case EPROTONOSUPPORT: @@ -2528,8 +2391,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, * EAFNOSUPPORT. */ case EINVAL: - inc_stats(manager->stats, - sock->statsindex[STATID_OPENFAIL]); return (ISC_R_FAMILYNOSUPPORT); default: @@ -2541,8 +2402,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, ISC_MSG_FAILED, "failed"), strbuf); - inc_stats(manager->stats, - sock->statsindex[STATID_OPENFAIL]); return (ISC_R_UNEXPECTED); } } @@ -2553,7 +2412,6 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, result = make_nonblock(sock->fd); if (result != ISC_R_SUCCESS) { (void)close(sock->fd); - inc_stats(manager->stats, sock->statsindex[STATID_OPENFAIL]); return (result); } @@ -2713,9 +2571,7 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, } setup_done: - inc_stats(manager->stats, sock->statsindex[STATID_OPEN]); if (sock->active == 0) { - inc_stats(manager->stats, sock->statsindex[STATID_ACTIVE]); sock->active = 1; } @@ -2747,20 +2603,14 @@ socket_create(isc_socketmgr_t *manager0, int pf, isc_sockettype_t type, switch (sock->type) { case isc_sockettype_udp: - sock->statsindex = - (pf == AF_INET) ? udp4statsindex : udp6statsindex; #define DCSPPKT(pf) ((pf == AF_INET) ? ISC_NET_DSCPPKTV4 : ISC_NET_DSCPPKTV6) sock->pktdscp = (isc_net_probedscp() & DCSPPKT(pf)) != 0; break; case isc_sockettype_tcp: - sock->statsindex = - (pf == AF_INET) ? tcp4statsindex : tcp6statsindex; break; case isc_sockettype_unix: - sock->statsindex = unixstatsindex; break; case isc_sockettype_raw: - sock->statsindex = rawstatsindex; break; default: INSIST(0); @@ -2917,7 +2767,6 @@ isc__socket_fdwatchcreate(isc_socketmgr_t *manager0, int fd, int flags, sock->fdwatchcb = callback; sock->fdwatchflags = flags; sock->fdwatchtask = task; - sock->statsindex = fdwatchstatsindex; sock->common.methods = (isc_socketmethods_t *)&socketmethods; sock->references = 1; @@ -3476,8 +3325,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { dev->address = NEWCONNSOCK(dev)->peer_address; if (NEWCONNSOCK(dev)->active == 0) { - inc_stats(manager->stats, - NEWCONNSOCK(dev)->statsindex[STATID_ACTIVE]); NEWCONNSOCK(dev)->active = 1; } @@ -3505,9 +3352,7 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { UNLOCK(&manager->lock); - inc_stats(manager->stats, sock->statsindex[STATID_ACCEPT]); } else { - inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]); NEWCONNSOCK(dev)->references--; free_socket((isc__socket_t **)&dev->newsocket); } @@ -3526,7 +3371,6 @@ internal_accept(isc_task_t *me, isc_event_t *ev) { select_poke(sock->manager, sock->fd, SELECT_POKE_ACCEPT); UNLOCK(&sock->lock); - inc_stats(manager->stats, sock->statsindex[STATID_ACCEPTFAIL]); return; } @@ -4445,7 +4289,6 @@ isc__socketmgr_create2(isc_mem_t *mctx, isc_socketmgr_t **managerp, } memset(manager->epoll_events, 0, manager->maxsocks * sizeof(uint32_t)); #endif - manager->stats = NULL; manager->common.methods = &socketmgrmethods; manager->common.magic = ISCAPI_SOCKETMGR_MAGIC; @@ -4597,18 +4440,6 @@ isc_socketmgr_getmaxsockets(isc_socketmgr_t *manager0, unsigned int *nsockp) { } void -isc_socketmgr_setstats(isc_socketmgr_t *manager0, isc_stats_t *stats) { - isc__socketmgr_t *manager = (isc__socketmgr_t *)manager0; - - REQUIRE(VALID_MANAGER(manager)); - REQUIRE(ISC_LIST_EMPTY(manager->socklist)); - REQUIRE(manager->stats == NULL); - REQUIRE(isc_stats_ncounters(stats) == isc_sockstatscounter_max); - - isc_stats_attach(stats, &manager->stats); -} - -void isc__socketmgr_destroy(isc_socketmgr_t **managerp) { isc__socketmgr_t *manager; int i; @@ -4694,9 +4525,6 @@ isc__socketmgr_destroy(isc_socketmgr_t **managerp) { isc_mem_put(manager->mctx, manager->fdstate, manager->maxsocks * sizeof(int)); - if (manager->stats != NULL) - isc_stats_detach(&manager->stats); - if (manager->fdlock != NULL) { for (i = 0; i < FDLOCK_COUNT; i++) DESTROYLOCK(&manager->fdlock[i]); @@ -5329,8 +5157,6 @@ isc__socket_bind(isc_socket_t *sock0, isc_sockaddr_t *sockaddr, bind_socket: #endif if (bind(sock->fd, &sockaddr->type.sa, sockaddr->length) < 0) { - inc_stats(sock->manager->stats, - sock->statsindex[STATID_BINDFAIL]); UNLOCK(&sock->lock); switch (errno) { @@ -5493,7 +5319,6 @@ isc__socket_accept(isc_socket_t *sock0, return (ISC_R_SHUTTINGDOWN); } nsock->references++; - nsock->statsindex = sock->statsindex; dev->ev_sender = ntask; dev->newsocket = (isc_socket_t *)nsock; @@ -5599,8 +5424,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr, addrbuf, errno, strbuf); UNLOCK(&sock->lock); - inc_stats(sock->manager->stats, - sock->statsindex[STATID_CONNECTFAIL]); isc_event_free(ISC_EVENT_PTR(&dev)); return (ISC_R_UNEXPECTED); @@ -5609,8 +5432,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr, isc_task_send(task, ISC_EVENT_PTR(&dev)); UNLOCK(&sock->lock); - inc_stats(sock->manager->stats, - sock->statsindex[STATID_CONNECTFAIL]); return (ISC_R_SUCCESS); } @@ -5626,8 +5447,6 @@ isc__socket_connect(isc_socket_t *sock0, isc_sockaddr_t *addr, UNLOCK(&sock->lock); - inc_stats(sock->manager->stats, - sock->statsindex[STATID_CONNECT]); return (ISC_R_SUCCESS); } @@ -5727,8 +5546,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) { return; } - inc_stats(sock->manager->stats, - sock->statsindex[STATID_CONNECTFAIL]); /* * Translate other errors into ISC_R_* flavors. @@ -5760,8 +5577,6 @@ internal_connect(isc_task_t *me, isc_event_t *ev) { peerbuf, strbuf); } } else { - inc_stats(sock->manager->stats, - sock->statsindex[STATID_CONNECT]); dev->result = ISC_R_SUCCESS; sock->connected = 1; sock->bound = 1; diff --git a/usr.sbin/bind/lib/isc/x86_32/Makefile.in b/usr.sbin/bind/lib/isc/x86_32/Makefile.in deleted file mode 100644 index 7689722b50a..00000000000 --- a/usr.sbin/bind/lib/isc/x86_32/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/x86_32/include/Makefile.in b/usr.sbin/bind/lib/isc/x86_32/include/Makefile.in deleted file mode 100644 index 056586b4787..00000000000 --- a/usr.sbin/bind/lib/isc/x86_32/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/x86_32/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/x86_32/include/isc/Makefile.in deleted file mode 100644 index ac008f6e1e2..00000000000 --- a/usr.sbin/bind/lib/isc/x86_32/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/x86_32/include/isc/atomic.h b/usr.sbin/bind/lib/isc/x86_32/include/isc/atomic.h deleted file mode 100644 index a3e944519fa..00000000000 --- a/usr.sbin/bind/lib/isc/x86_32/include/isc/atomic.h +++ /dev/null @@ -1,164 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.4 2020/01/07 19:08:10 florian Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#ifdef ISC_PLATFORM_USEGCCASM -/* - * This routine atomically increments the value stored in 'p' by 'val', and - * returns the previous value. - */ -static __inline__ isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - isc_int32_t prev = val; - - __asm__ volatile( - "xadd %0, %1" - :"=q"(prev) - :"m"(*p), "0"(prev) - :"memory", "cc"); - - return (prev); -} - -#ifdef ISC_PLATFORM_HAVEXADDQ -static __inline__ isc_int64_t -isc_atomic_xaddq(isc_int64_t *p, isc_int64_t val) { - isc_int64_t prev = val; - - __asm__ volatile( - "xaddq %0, %1" - :"=q"(prev) - :"m"(*p), "0"(prev) - :"memory", "cc"); - - return (prev); -} -#endif /* ISC_PLATFORM_HAVEXADDQ */ - -/* - * This routine atomically stores the value 'val' in 'p' (32-bit version). - */ -static __inline__ void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - __asm__ volatile( - - "xchgl %1, %0" - : - : "r"(val), "m"(*p) - : "memory"); -} - -#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ -/* - * This routine atomically stores the value 'val' in 'p' (64-bit version). - */ -static __inline__ void -isc_atomic_storeq(isc_int64_t *p, isc_int64_t val) { - __asm__ volatile( - - "xchgq %1, %0" - : - : "r"(val), "m"(*p) - : "memory"); -} -#endif /* ISC_PLATFORM_HAVEATOMICSTOREQ */ - -/* - * This routine atomically replaces the value in 'p' with 'val', if the - * original value is equal to 'cmpval'. The original value is returned in any - * case. - */ -static __inline__ isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - __asm__ volatile( - "cmpxchgl %1, %2" - : "=a"(cmpval) - : "r"(val), "m"(*p), "a"(cmpval) - : "memory"); - - return (cmpval); -} - -#elif defined(ISC_PLATFORM_USESTDASM) -/* - * The followings are "generic" assembly code which implements the same - * functionality in case the gcc extension cannot be used. It should be - * better to avoid inlining below, since we directly refer to specific - * positions of the stack frame, which would not actually point to the - * intended address in the embedded mnemonic. - */ -static isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %edx\n" - "xadd %edx, (%ecx)\n" - - /* - * set the return value directly in the register so that we - * can avoid guessing the correct position in the stack for a - * local variable. - */ - "movl %edx, %eax" - ); -} - -static void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %edx\n" - "xchgl (%ecx), %edx\n" - ); -} - -static isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - (void)(p); - (void)(cmpval); - (void)(val); - - __asm ( - "movl 8(%ebp), %ecx\n" - "movl 12(%ebp), %eax\n" /* must be %eax for cmpxchgl */ - "movl 16(%ebp), %edx\n" - - /* - * If (%ecx) == %eax then (%ecx) := %edx. - % %eax is set to old (%ecx), which will be the return value. - */ - "cmpxchgl %edx, (%ecx)" - ); -} -#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/lib/isc/x86_64/Makefile.in b/usr.sbin/bind/lib/isc/x86_64/Makefile.in deleted file mode 100644 index 7689722b50a..00000000000 --- a/usr.sbin/bind/lib/isc/x86_64/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = include -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/x86_64/include/Makefile.in b/usr.sbin/bind/lib/isc/x86_64/include/Makefile.in deleted file mode 100644 index 056586b4787..00000000000 --- a/usr.sbin/bind/lib/isc/x86_64/include/Makefile.in +++ /dev/null @@ -1,24 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -SUBDIRS = isc -TARGETS = - -@BIND9_MAKE_RULES@ diff --git a/usr.sbin/bind/lib/isc/x86_64/include/isc/Makefile.in b/usr.sbin/bind/lib/isc/x86_64/include/isc/Makefile.in deleted file mode 100644 index ac008f6e1e2..00000000000 --- a/usr.sbin/bind/lib/isc/x86_64/include/isc/Makefile.in +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (C) Internet Systems Consortium, Inc. ("ISC") -# -# Permission to use, copy, modify, and/or distribute this software for any -# purpose with or without fee is hereby granted, provided that the above -# copyright notice and this permission notice appear in all copies. -# -# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -# PERFORMANCE OF THIS SOFTWARE. - -# $Id: Makefile.in,v 1.3 2019/12/17 01:46:37 sthen Exp $ - -srcdir = @srcdir@ -VPATH = @srcdir@ -top_srcdir = @top_srcdir@ - -VERSION=@BIND9_VERSION@ - -HEADERS = atomic.h - -SUBDIRS = -TARGETS = - -@BIND9_MAKE_RULES@ - -installdirs: - $(SHELL) ${top_srcdir}/mkinstalldirs ${DESTDIR}${includedir}/isc - -install:: installdirs - for i in ${HEADERS}; do \ - ${INSTALL_DATA} $(srcdir)/$$i ${DESTDIR}${includedir}/isc ; \ - done - -uninstall:: - for i in ${HEADERS}; do \ - rm -f ${DESTDIR}${includedir}/isc/$$i ; \ - done diff --git a/usr.sbin/bind/lib/isc/x86_64/include/isc/atomic.h b/usr.sbin/bind/lib/isc/x86_64/include/isc/atomic.h deleted file mode 100644 index 3d6cdc8cef5..00000000000 --- a/usr.sbin/bind/lib/isc/x86_64/include/isc/atomic.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* $Id: atomic.h,v 1.4 2020/01/07 19:08:10 florian Exp $ */ - -#ifndef ISC_ATOMIC_H -#define ISC_ATOMIC_H 1 - -#include <isc/platform.h> -#include <isc/types.h> - -#ifdef ISC_PLATFORM_USEGCCASM - -/* We share the gcc-version with x86_32 */ -#error "impossible case. check build configuration" - -#elif defined(ISC_PLATFORM_USESTDASM) -/* - * The followings are "generic" assembly code which implements the same - * functionality in case the gcc extension cannot be used. It should be - * better to avoid inlining below, since we directly refer to specific - * registers for arguments, which would not actually correspond to the - * intended address or value in the embedded mnemonic. - */ - -static isc_int32_t -isc_atomic_xadd(isc_int32_t *p, isc_int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rdx\n" - "movl %esi, %eax\n" - "xadd %eax, (%rdx)\n" - /* - * XXX: assume %eax will be used as the return value. - */ - ); -} - -#ifdef ISC_PLATFORM_HAVEXADDQ -static isc_int64_t -isc_atomic_xaddq(isc_int64_t *p, isc_int64_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rdx\n" - "movq %rsi, %rax\n" - "xaddq %rax, (%rdx)\n" - /* - * XXX: assume %rax will be used as the return value. - */ - ); -} -#endif - -static void -isc_atomic_store(isc_int32_t *p, isc_int32_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rax\n" - "movl %esi, %edx\n" - "xchgl (%rax), %edx\n" - ); -} - -#ifdef ISC_PLATFORM_HAVEATOMICSTOREQ -static void -isc_atomic_storeq(isc_int64_t *p, isc_int64_t val) { - (void)(p); - (void)(val); - - __asm ( - "movq %rdi, %rax\n" - "movq %rsi, %rdx\n" - "xchgq (%rax), %rdx\n" - ); -} -#endif - -static isc_int32_t -isc_atomic_cmpxchg(isc_int32_t *p, isc_int32_t cmpval, isc_int32_t val) { - (void)(p); - (void)(cmpval); - (void)(val); - - __asm ( - /* - * p is %rdi, cmpval is %esi, val is %edx. - */ - "movl %edx, %ecx\n" - "movl %esi, %eax\n" - "movq %rdi, %rdx\n" - - /* - * If [%rdi] == %eax then [%rdi] := %ecx (equal to %edx - * from above), and %eax is untouched (equal to %esi) - * from above. - * - * Else if [%rdi] != %eax then [%rdi] := [%rdi] - * (rewritten in write cycle) and %eax := [%rdi]. - */ - "cmpxchgl %ecx, (%rdx)" - ); -} - -#else /* !ISC_PLATFORM_USEGCCASM && !ISC_PLATFORM_USESTDASM */ - -#error "unsupported compiler. disable atomic ops by --disable-atomic" - -#endif -#endif /* ISC_ATOMIC_H */ diff --git a/usr.sbin/bind/make/includes.in b/usr.sbin/bind/make/includes.in index abd33c080f8..2f04071b5ee 100644 --- a/usr.sbin/bind/make/includes.in +++ b/usr.sbin/bind/make/includes.in @@ -13,7 +13,7 @@ # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR # PERFORMANCE OF THIS SOFTWARE. -# $Id: includes.in,v 1.6 2020/01/07 19:08:10 florian Exp $ +# $Id: includes.in,v 1.7 2020/01/09 18:14:49 florian Exp $ # Search for machine-generated header files in the build tree, # and for normal headers in the source tree (${top_srcdir}). @@ -25,8 +25,7 @@ ISC_INCLUDES = @BIND9_ISC_BUILDINCLUDE@ \ -I${top_srcdir}/lib/isc \ -I${top_srcdir}/lib/isc/include \ -I${top_srcdir}/lib/isc/unix/include \ - -I${top_srcdir}/lib/isc/nothreads/include \ - -I${top_srcdir}/lib/isc/@ISC_ARCH_DIR@/include + -I${top_srcdir}/lib/isc/nothreads/include ISCCFG_INCLUDES = @BIND9_ISCCFG_BUILDINCLUDE@ \ -I${top_srcdir}/lib/isccfg/include |
