Compare commits

...
Author SHA1 Message Date
Tony Finch 3f7ec89937 Make qp-trie write transactions more lightweight 2023-04-19 16:01:35 +01:00
Tony Finch 6892e463bf Merge branch '3998-check-countlabels' into 'main'
Check dns_name_countlabels() wrt DNS_NAME_MAXLABELS

Closes #3998

See merge request isc-projects/bind9!7822
2023-04-18 12:58:09 +00:00
Tony Finch 3dcfad81d8 Check dns_name_countlabels() wrt DNS_NAME_MAXLABELS
This test case was omitted from [GL !7803]
2023-04-18 13:32:09 +01:00
Tony Finch 89eeca7981 Merge branch 'fanf-inane' into 'main'
Fix several typoes in name_test

See merge request isc-projects/bind9!7800
2023-04-18 12:22:55 +00:00
Tony Finch 80a153e159 Fix several typos in name_test
`nane` -> `name`
2023-04-18 12:56:29 +01:00
Arаm Sаrgsyаn 2928ab4e5f Merge branch 'aram/xfer-test-bugfix' into 'main'
Fix variable name error in the xfer system test

See merge request isc-projects/bind9!7845
2023-04-18 09:38:12 +00:00
Aram Sargsyan 613a9fc659 Fix variable name error in the xfer system test
There is no 'ret' in this test, and it is obvious that 'ret=1'
should be 'tmp=1' for the check to work correctly, if the string
is not found in the log file.
2023-04-18 09:37:39 +00:00
Mark Andrews b23a3c7729 Merge branch '3996-in-fatal-only-pause-when-running' into 'main'
In fatal only pause loops when they are running.

Closes #3996

See merge request isc-projects/bind9!7825
2023-04-18 01:11:49 +00:00
Mark Andrews be68dd62ea isc_loopmgr_pause was called inappropriately
isc_loopmgr_pause can't be called before isc_loopmgr_run is
called as the thread ids are not yet valid.  If there is a
fatal error before isc_loopmgr_run is run then don't call
isc_loopmgr_pause.
2023-04-18 00:28:36 +00:00
Matthijs Mekking 453aaac2f0 Merge branch '3769-migrate-zsk-ksk-split-tocsk' into 'main'
kasp: Add test case for migrating KSK/ZSK to CSK

See merge request isc-projects/bind9!7306
2023-04-17 09:39:59 +00:00
Matthijs Mekking e752656a38 Add key state init debugging
When debugging an issue it can be useful to see what BIND initially
set the key states to.
2023-04-17 10:56:08 +02:00
Matthijs Mekking c42ec8a56e kasp: Add test case for migrating KSK/ZSK to CSK
Add a test case to cover #3679 where a user migrates from a KSK/ZSK
split using auto-dnssec maintain, to the default dnssec-policy (CSK).

The test actually does not use the default dnssec-policy, but it does
use one that has the same keys clause. For testing convenience, we use
the same propagation time values as other test cases that migrate to
dnssec-policy with mismatching existing key set.
2023-04-17 10:56:08 +02:00
Ondřej Surý 02edb42a0a Merge branch '4015-fix-forward_cancel-from-the-wrong-loop' into 'main'
Run the forward_cancel on the appropriate zone->loop

Closes #4015

See merge request isc-projects/bind9!7835
2023-04-14 15:13:03 +00:00
Ondřej Surý 2423907b87 Add CHANGES note for [GL #4015] 2023-04-14 16:31:48 +02:00
Ondřej Surý 3df3b5efbd Run the forward_cancel on the appropriate zone->loop
If the zone forwards are canceled from dns_zonemgr_shutdown(), the
forward_cancel() would get called from the main loop, which is wrong.
It needs to be called from the matching zone->loop.

Run the dns_request_cancel() via isc_async_run() on the loop associated
with the zone instead of calling the dns_request_cancel() directly from
the main loop.
2023-04-14 16:31:33 +02:00
Ondřej Surý 36a3c87c33 Merge branch 'ondrej/remove-unused-netmgr-worker-sendbuf' into 'main'
Remove unused netmgr->worker->sendbuf

See merge request isc-projects/bind9!7841
2023-04-14 14:20:52 +00:00
Ondřej Surý f677cf6b73 Remove unused netmgr->worker->sendbuf
By inspecting the code, it was discovered that .sendbuf member of the
isc__nm_networker_t was unused and just consuming ~64k per worker.
Remove the member and the association allocation/deallocation.
2023-04-14 16:20:14 +02:00
Arаm Sаrgsyаn 9bd88df624 Merge branch '4000-openssl-attr-malloc-vs-cmocka-define-malloc' into 'main'
unit tests: include an OpenSSL header before including cmocka.h

Closes #4000

See merge request isc-projects/bind9!7820
2023-04-14 12:12:13 +00:00
Aram Sargsyan 786b0689c6 Add a CHANGES note for [GL #4000] 2023-04-14 12:11:52 +00:00
Aram Sargsyan 87db9ea84c unit tests: include an OpenSSL header before including cmocka.h
OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a redefined
malloc in cmocka.h.

As a workaround, include an OpenSSL header file before including
cmocka.h in the unit tests where OpenSSL is used.
2023-04-14 12:11:52 +00:00
Petr Špaček 9e3f7f4d53 Merge branch 'pspacek/set-up-version-and-release-notes-for-bind-9.19.13' into 'main'
Set up version and release notes for BIND 9.19.13

See merge request isc-projects/bind9!7839
2023-04-14 09:03:19 +00:00
Petr Špaček 923eb6667f Update BIND version to 9.19.13-dev 2023-04-14 10:51:44 +02:00
Petr Špaček 0fb1e00469 Set up release notes for BIND 9.19.13 2023-04-14 10:51:23 +02:00
Arаm Sаrgsyаn 546312f06c Merge branch 'aram/dns_xfrin_create-use-after-free' into 'main'
Fix a use-after-free bug in dns_xfrin_create()

See merge request isc-projects/bind9!7832
2023-04-14 07:40:01 +00:00
Aram Sargsyan bf8e93aee5 Add a CHANGES note for [GL !7832] 2023-04-14 07:39:38 +00:00
Aram Sargsyan d8a207bd00 Fix a use-after-free bug in dns_xfrin_create()
'xfr' is used after detaching the only reference, which would
have destroyed the object.

Call dns_xfrin_detach() only after the final use of 'xfr'.
2023-04-14 07:39:38 +00:00
Mark Andrews 172c678f2b Merge branch '3980-add-timeouts-to-unit-tests' into 'main'
Draft: Resolve "Add timeouts to unit tests."

Closes #3980

See merge request isc-projects/bind9!7837
2023-04-14 06:34:36 +00:00
Mark Andrews 21a3d4f762 Use SIGABRT rather than SIGKILL for long running unit test
SIGABRT will produce a core dump which will allow for forensic
analysis of the unit test
2023-04-14 15:40:02 +10:00
Ondřej Surý b6c9ac75ad Merge branch '3980-revert-unit-test-forking' into 'main'
Revert "Kill unit tests that run more than 1200 seconds"

Closes #3980

See merge request isc-projects/bind9!7833
2023-04-14 04:19:40 +00:00
Ondřej Surý c60ce13127 Revert "Kill unit tests that run more than 1200 seconds"
This reverts commit 3d5c7cd46c which
added wrapper around all the unit tests that would run the unit test in
the forked process.

This makes any debugging of the unit tests too hard.  Futures attempts
to fix #3980 should add a custom automake test harness (log driver) that
would kill the unit test after configured timeout.
2023-04-14 06:14:19 +02:00
Mark Andrews 22fb1b115a Merge branch '4003-dump_histo-defined-but-not-used-on-fips-in-bin-named-statschannel-c' into 'main'
Resolve "'dump_histo' defined but not used on FIPS in bin/named/statschannel.c"

Closes #4003

See merge request isc-projects/bind9!7826
2023-04-12 23:49:55 +00:00
Mark Andrews 82d2434ff8 dump_histo is only used with extended stats
Wrap dump_histo with #if defined(EXTENDED_STATS)/#endif.  Reproduce
build failure with "configure --without-libxml2 --without-json-c"
2023-04-13 08:53:27 +10:00
33 changed files with 415 additions and 143 deletions
+14
View File
@@ -1,3 +1,17 @@
6150. [bug] If the zones have active upstream forwards, the
shutting down the server might cause assertion
failures as the forward were all canceled from
the main loop instead from the loops associated
with the zone. [GL #4015]
6149. [test] As a workaround, include an OpenSSL header file before
including cmocka.h in the unit tests, because OpenSSL
3.1.0 uses __attribute__(malloc), conflicting with a
redefined malloc in cmocka.h. [GL #4000]
6148. [bug] Fix a use-after-free bug in dns_xfrin_create().
[GL !7832]
6147. [performance] Fix the TCP server parent quota use. [GL #3985]
6146. [performance] Replace the zone table red-black tree and associated
+1
View File
@@ -53,6 +53,7 @@ EXTERN unsigned int named_g_cpus INIT(0);
EXTERN unsigned int named_g_udpdisp INIT(0);
EXTERN isc_loop_t *named_g_mainloop INIT(NULL);
EXTERN isc_loopmgr_t *named_g_loopmgr INIT(NULL);
EXTERN bool named_g_loopmgr_running INIT(false);
EXTERN dns_dispatchmgr_t *named_g_dispatchmgr INIT(NULL);
EXTERN unsigned int named_g_cpus_detected INIT(1);
+4
View File
@@ -1506,6 +1506,10 @@ main(int argc, char *argv[]) {
*/
isc_signal_start(named_g_server->sighup);
/*
* Pause the loop manager in fatal.
*/
named_g_loopmgr_running = true;
isc_loopmgr_run(named_g_loopmgr);
#ifdef HAVE_LIBSCF
+3 -1
View File
@@ -10286,7 +10286,9 @@ named_server_destroy(named_server_t **serverp) {
static void
fatal(const char *msg, isc_result_t result) {
isc_loopmgr_pause(named_g_loopmgr);
if (named_g_loopmgr_running) {
isc_loopmgr_pause(named_g_loopmgr);
}
isc_log_write(named_g_lctx, NAMED_LOGCATEGORY_GENERAL,
NAMED_LOGMODULE_SERVER, ISC_LOG_CRITICAL, "%s: %s", msg,
isc_result_totext(result));
+2
View File
@@ -848,6 +848,7 @@ dump_stats(isc_stats_t *stats, isc_statsformat_t type, void *arg,
values, options));
}
#if defined(EXTENDED_STATS)
static isc_result_t
dump_histo(isc_histomulti_t *hm, isc_statsformat_t type, void *arg,
const char *category, const char **desc, int ncounters, int *indices,
@@ -863,6 +864,7 @@ dump_histo(isc_histomulti_t *hm, isc_statsformat_t type, void *arg,
return (dump_counters(type, arg, category, desc, ncounters, indices,
values, options));
}
#endif /* defined(EXTENDED_STATS) */
static isc_result_t
dump_counters(isc_statsformat_t type, void *arg, const char *category,
@@ -82,3 +82,23 @@ dnssec-policy "migrate-nomatch-alglen" {
parent-propagation-delay pt1h;
parent-ds-ttl 7200;
};
/*
* This policy tests migration from existing KSK and ZSK to CSK.
* The keys clause matches the default policy.
*/
dnssec-policy "migrate-nomatch-kzc" {
dnskey-ttl 300;
keys {
csk key-directory lifetime unlimited algorithm @DEFAULT_ALGORITHM@;
};
// Together 12h
zone-propagation-delay 3600;
max-zone-ttl 11h;
// Together 3h
parent-propagation-delay pt1h;
parent-ds-ttl 7200;
};
@@ -96,3 +96,10 @@ zone "migrate-nomatch-alglen.kasp" {
dnssec-dnskey-kskonly yes;
update-check-ksk yes;
};
zone "migrate-nomatch-kzc.kasp" {
type primary;
file "migrate-nomatch-kzc.kasp.db";
auto-dnssec maintain;
inline-signing yes;
};
@@ -85,3 +85,10 @@ zone "migrate-nomatch-alglen.kasp" {
allow-update { any; };
dnssec-policy "migrate-nomatch-alglen";
};
zone "migrate-nomatch-kzc.kasp" {
type primary;
file "migrate-nomatch-kzc.kasp.db";
inline-signing yes;
dnssec-policy "migrate-nomatch-kzc";
};
+17
View File
@@ -96,6 +96,23 @@ private_type_record $zone 5 "$KSK" >> "$infile"
private_type_record $zone 5 "$ZSK" >> "$infile"
$SIGNER -S -x -s now-1h -e now+2w -o $zone -O full -f $zonefile $infile > signer.out.$zone.1 2>&1
# Set up a zone with auto-dnssec maintain to migrate to default dnssec-policy.
# The zone is signed with KSK/ZSK split, but the dnssec-policy uses CSK.
setup migrate-nomatch-kzc.kasp
echo "$zone" >> zones
Tds="now-3h" # Time according to dnssec-policy that DS will be OMNIPRESENT
Tkey="now-3900s" # DNSKEY TTL + propagation delay
Tsig="now-12h" # Zone's maximum TTL + propagation delay
ksktimes="-P ${Tkey} -A ${Tkey} -P sync ${Tds}"
zsktimes="-P ${Tkey} -A ${Tsig}"
KSK=$($KEYGEN -a $DEFAULT_ALGORITHM -L 300 -f KSK $ksktimes $zone 2> keygen.out.$zone.1)
ZSK=$($KEYGEN -a $DEFAULT_ALGORITHM -L 300 $zsktimes $zone 2> keygen.out.$zone.2)
cat template.db.in "${KSK}.key" "${ZSK}.key" > "$infile"
cp $infile $zonefile
private_type_record $zone 5 "$KSK" >> "$infile"
private_type_record $zone 5 "$ZSK" >> "$infile"
$SIGNER -PS -x -s now-1h -e now+2w -o $zone -O raw -f "${zonefile}.signed" $infile > signer.out.$zone.1 2>&1
#
# Set up zones to test time metadata correctly sets state.
#
+137
View File
@@ -346,6 +346,43 @@ dnssec_verify
_migratenomatch_alglen_ksk=$(key_get KEY1 ID)
_migratenomatch_alglen_zsk=$(key_get KEY2 ID)
#
# Testing migration with unmatched existing keys (different roles KSK/ZSK -> CSK).
#
set_zone "migrate-nomatch-kzc.kasp"
set_policy "none" "2" "300"
set_server "ns3" "10.53.0.3"
init_migration_keys "$DEFAULT_ALGORITHM_NUMBER" "$DEFAULT_ALGORITHM" "$DEFAULT_BITS" "$DEFAULT_BITS"
init_migration_states "omnipresent" "omnipresent"
# Make sure the zone is signed with legacy keys.
check_keys
check_dnssecstatus "$SERVER" "$POLICY" "$ZONE"
# Set expected key times:
# - The KSK is immediately published and activated.
# P : now-3900s
# P sync: now-3h
# A : now-3900s
created=$(key_get KEY1 CREATED)
set_addkeytime "KEY1" "PUBLISHED" "${created}" -3900
set_addkeytime "KEY1" "ACTIVE" "${created}" -3900
set_addkeytime "KEY1" "SYNCPUBLISH" "${created}" -10800
# - The ZSK is immediately published and activated.
# P: now-3900s
# A: now-12h
created=$(key_get KEY2 CREATED)
set_addkeytime "KEY2" "PUBLISHED" "${created}" -3900
set_addkeytime "KEY2" "ACTIVE" "${created}" -43200
check_keytimes
check_apex
check_subdomain
dnssec_verify
# Remember legacy key tags.
_migratenomatch_kzc_ksk=$(key_get KEY1 ID)
_migratenomatch_kzc_zsk=$(key_get KEY2 ID)
#############
# Reconfig. #
@@ -791,6 +828,106 @@ ret=0
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
#
# Test migration to dnssec-policy, existing keys do not match role (KSK/ZSK -> CSK).
#
set_zone "migrate-nomatch-kzc.kasp"
set_policy "migrate-nomatch-kzc" "3" "300"
set_server "ns3" "10.53.0.3"
# The legacy keys need to be retired, but otherwise stay present until the
# new keys are omnipresent, and can be used to construct a chain of trust.
init_migration_keys "$DEFAULT_ALGORITHM_NUMBER" "$DEFAULT_ALGORITHM" "$DEFAULT_BITS" "$DEFAULT_BITS"
init_migration_states "hidden" "omnipresent"
key_set "KEY1" "LEGACY" "no"
key_set "KEY2" "LEGACY" "no"
set_keyrole "KEY3" "csk"
set_keylifetime "KEY3" "0"
set_keyalgorithm "KEY3" "$DEFAULT_ALGORITHM_NUMBER" "$DEFAULT_ALGORITHM" "$DEFAULT_BITS"
set_keysigning "KEY3" "yes"
set_zonesigning "KEY3" "no"
set_keystate "KEY3" "GOAL" "omnipresent"
set_keystate "KEY3" "STATE_DNSKEY" "rumoured"
set_keystate "KEY3" "STATE_KRRSIG" "rumoured"
# This key is considered to be prepublished, so it is not yet signing.
set_keystate "KEY3" "STATE_ZRRSIG" "hidden"
set_keystate "KEY3" "STATE_DS" "hidden"
# Various signing policy checks.
check_keys
wait_for_done_signing
check_dnssecstatus "$SERVER" "$POLICY" "$ZONE"
# Set expected key times:
# - KSK must be retired since it no longer matches the policy.
# P : now-3900s
# P sync: now-3h
# A : now-3900s
# - The key is removed after the retire interval:
# IretKSK = TTLds + DprpP + retire_safety.
# TTLds: 2h (7200 seconds)
# Dprp: 1h (3600 seconds)
# retire-safety: 1h (3600 seconds)
# IretKSK: 4h (14400 seconds)
IretKSK=14400
created=$(key_get KEY1 CREATED)
set_addkeytime "KEY1" "PUBLISHED" "${created}" -3900
set_addkeytime "KEY1" "ACTIVE" "${created}" -3900
set_addkeytime "KEY1" "SYNCPUBLISH" "${created}" -10800
keyfile=$(key_get KEY1 BASEFILE)
grep "; Inactive:" "${keyfile}.key" > retired.test${n}.ksk
retired=$(awk '{print $3}' < retired.test${n}.ksk)
set_keytime "KEY1" "RETIRED" "${retired}"
set_addkeytime "KEY1" "REMOVED" "${retired}" "${IretKSK}"
# - ZSK must be retired since it no longer matches the policy.
# P: now-3900s
# A: now-12h
# - The key is removed after the retire interval:
# IretZSK = TTLsig + Dprp + Dsgn + retire-safety.
# TTLsig: 11h (39600 seconds)
# Dprp: 1h (3600 seconds)
# Dsgn: 9d (777600 seconds)
# publish-safety: 1h (3600 seconds)
# IretZSK: 9d13h (824400 seconds)
IretZSK=824400
Lzsk=5184000
created=$(key_get KEY2 CREATED)
set_addkeytime "KEY2" "PUBLISHED" "${created}" -3900
set_addkeytime "KEY2" "ACTIVE" "${created}" -43200
keyfile=$(key_get KEY2 BASEFILE)
grep "; Inactive:" "${keyfile}.key" > retired.test${n}.zsk
retired=$(awk '{print $3}' < retired.test${n}.zsk)
set_keytime "KEY2" "RETIRED" "${retired}"
set_addkeytime "KEY2" "REMOVED" "${retired}" "${IretZSK}"
# - The new KSK is immediately published and activated.
created=$(key_get KEY3 CREATED)
set_keytime "KEY3" "PUBLISHED" "${created}"
set_keytime "KEY3" "ACTIVE" "${created}"
# - It takes TTLsig + Dprp + publish-safety hours to propagate the zone.
# TTLsig: 11h (39600 seconds)
# Dprp: 1h (3600 seconds)
# publish-safety: 1h (3600 seconds)
# Ipub: 13h (46800 seconds)
Ipub=46800
set_addkeytime "KEY3" "SYNCPUBLISH" "${created}" "${Ipub}"
# Continue signing policy checks.
check_keytimes
check_apex
check_subdomain
dnssec_verify
# Check key tags, should be the same.
n=$((n+1))
echo_i "check that of zone ${ZONE} migration to dnssec-policy keeps existing keys ($n)"
ret=0
[ $_migratenomatch_kzc_ksk = $(key_get KEY1 ID) ] || log_error "mismatch ksk tag"
[ $_migratenomatch_kzc_zsk = $(key_get KEY2 ID) ] || log_error "mismatch zsk tag"
test "$ret" -eq 0 || echo_i "failed"
status=$((status+ret))
########################################################
# Testing key states derived from key timing metadata. #
########################################################
+1 -1
View File
@@ -576,7 +576,7 @@ status=$((status+tmp))
n=$((n+1))
echo_i "test that transfer-source uses port option correctly ($n)"
tmp=0
grep "10.53.0.3#${EXTRAPORT1} (primary): query 'primary/SOA/IN' approved" ns6/named.run > /dev/null || ret=1
grep "10.53.0.3#${EXTRAPORT1} (primary): query 'primary/SOA/IN' approved" ns6/named.run > /dev/null || tmp=1
if test $tmp != 0 ; then echo_i "failed"; fi
status=$((status+tmp))
+1 -1
View File
@@ -16,7 +16,7 @@
#
m4_define([bind_VERSION_MAJOR], 9)dnl
m4_define([bind_VERSION_MINOR], 19)dnl
m4_define([bind_VERSION_PATCH], 12)dnl
m4_define([bind_VERSION_PATCH], 13)dnl
m4_define([bind_VERSION_EXTRA], -dev)dnl
m4_define([bind_DESCRIPTION], [(Development Release)])dnl
m4_define([bind_SRCID], [m4_esyscmd_s([git rev-parse --short HEAD | cut -b1-7])])dnl
+4 -34
View File
@@ -9,7 +9,7 @@
.. See the COPYRIGHT file distributed with this work for additional
.. information regarding copyright ownership.
Notes for BIND 9.19.12
Notes for BIND 9.19.13
----------------------
Security Fixes
@@ -20,41 +20,12 @@ Security Fixes
New Features
~~~~~~~~~~~~
- BIND now depends on ``liburcu``, Userspace RCU, for lock-free data
structures. :gl:`#3934`
- The new ``delv +ns`` option activates name server mode, in which ``delv``
sets up an internal recursive resolver and uses that, rather than an
external server, to look up the requested query name and type. All messages
sent and received during the resolution and validation process are logged.
This can be used in place of ``dig +trace``: it more accurately
reproduces the behavior of ``named`` when resolving a query.
The log message ``resolver priming query complete`` was moved from the
INFO log level to the DEBUG(1) log level, to prevent ``delv`` from
emitting that message when setting up its internal resolver. :gl:`#3842`
- A new configuration option :any:`checkds` is introduced that when set to
``yes`` will detect :any:`parental-agents` automatically by resolving the
parent NS records. These name servers will be used to check the DS RRset
during a KSK rollover initiated by :any:`dnssec-policy`. :gl:`#3901`
- None.
Removed Features
~~~~~~~~~~~~~~~~
- The TKEY Mode 2 (Diffie-Hellman Exchanged Keying Mode) has been removed and
using TKEY Mode 2 is now a fatal error. Users are advised to switch to TKEY
Mode 3 (GSS-API). :gl:`#3905`
- Zone type ``delegation-only``, and the ``delegation-only`` and
``root-delegation-only`` options, have been removed. Using them
is a configuration error.
These options were created to address the SiteFinder controversy, in
which certain top-level domains redirected misspelled queries to other
sites instead of returning NXDOMAIN responses. Since top-level domains are
now DNSSEC signed, and DNSSEC validation is active by default, the
options are no longer needed. :gl:`#3953`
- None.
Feature Changes
~~~~~~~~~~~~~~~
@@ -64,8 +35,7 @@ Feature Changes
Bug Fixes
~~~~~~~~~
- Performance of DNSSEC validation in zones with many DNSKEY records
has been improved. :gl:`#3981`
- None.
Known Issues
~~~~~~~~~~~~
+22 -7
View File
@@ -44,13 +44,28 @@
* Set key state to `target` state and change last changed
* to `time`, only if key state has not been set before.
*/
#define INITIALIZE_STATE(key, state, timing, target, time) \
do { \
dst_key_state_t s; \
if (dst_key_getstate((key), (state), &s) == ISC_R_NOTFOUND) { \
dst_key_setstate((key), (state), (target)); \
dst_key_settime((key), (timing), time); \
} \
#define INITIALIZE_STATE(key, state, timing, target, time) \
do { \
dst_key_state_t s; \
char keystr[DST_KEY_FORMATSIZE]; \
if (dst_key_getstate((key), (state), &s) == ISC_R_NOTFOUND) { \
dst_key_setstate((key), (state), (target)); \
dst_key_settime((key), (timing), time); \
\
if (isc_log_wouldlog(dns_lctx, ISC_LOG_DEBUG(1))) { \
dst_key_format((key), keystr, sizeof(keystr)); \
isc_log_write( \
dns_lctx, DNS_LOGCATEGORY_DNSSEC, \
DNS_LOGMODULE_DNSSEC, \
ISC_LOG_DEBUG(3), \
"keymgr: DNSKEY %s (%s) initialize " \
"%s state to %s (policy %s)", \
keystr, keymgr_keyrole((key)), \
keystatetags[state], \
keystatestrings[target], \
dns_kasp_getname(kasp)); \
} \
} \
} while (0)
/* Shorter keywords for better readability. */
+54 -33
View File
@@ -73,8 +73,15 @@ static atomic_uint_fast64_t rollback_time;
#define LOG_STATS(...) \
isc_log_write(dns_lctx, DNS_LOGCATEGORY_DATABASE, DNS_LOGMODULE_QP, \
ISC_LOG_DEBUG(1), __VA_ARGS__)
#define LOG_SIZES(qp, time) \
LOG_STATS("%s(%" PRIu64 " ns) chunk %u max %u leaf %u" \
" live %u used %u free %u hold %u", \
__func__, time, (qp)->chunk_count, (qp)->chunk_max, \
(qp)->leaf_count, (qp)->used_count - (qp)->free_count, \
(qp)->used_count, (qp)->free_count, (qp)->hold_count)
#else
#define LOG_STATS(...)
#define LOG_SIZES(...)
#endif
#if DNS_QP_TRACE
@@ -406,6 +413,7 @@ chunk_alloc(dns_qp_t *qp, qp_chunk_t chunk, qp_weight_t size) {
qp->base->ptr[chunk] = chunk_get_raw(qp);
qp->usage[chunk] = (qp_usage_t){ .exists = true, .used = size };
qp->used_count += size;
qp->chunk_count += 1;
qp->bump = chunk;
qp->fender = 0;
@@ -560,6 +568,7 @@ chunk_discount(dns_qp_t *qp, qp_chunk_t chunk) {
INSIST(qp->free_count >= qp->usage[chunk].free);
qp->used_count -= qp->usage[chunk].used;
qp->free_count -= qp->usage[chunk].free;
qp->chunk_count -= 1;
}
}
@@ -615,9 +624,7 @@ recycle(dns_qp_t *qp) {
if (free > 0) {
LOG_STATS("qp recycle" PRItime "free %u chunks", time, free);
LOG_STATS("qp recycle leaf %u live %u used %u free %u hold %u",
qp->leaf_count, qp->used_count - qp->free_count,
qp->used_count, qp->free_count, qp->hold_count);
LOG_SIZES(qp, time);
}
}
@@ -628,21 +635,42 @@ recycle(dns_qp_t *qp) {
static bool
defer_chunk_reclamation(dns_qp_t *qp, isc_qsbr_phase_t phase) {
unsigned int reclaim = 0;
unsigned int free = 0;
isc_nanosecs_t start = isc_time_monotonic();
for (qp_chunk_t chunk = 0; chunk < qp->chunk_max; chunk++) {
if (chunk != qp->bump && chunk_usage(qp, chunk) == 0 &&
qp->usage[chunk].exists && qp->usage[chunk].immutable &&
qp->usage[chunk].phase == 0)
qp->usage[chunk].exists)
{
chunk_discount(qp, chunk);
qp->usage[chunk].phase = phase;
reclaim++;
if (!qp->usage[chunk].immutable) {
/* clean up empty mutable chunks right now */
chunk_free(qp, chunk);
free++;
} else if (qp->usage[chunk].phase == 0) {
/*
* defer cleanup of empty immutable chunks
* that are not already scheduled for cleanup
*/
chunk_discount(qp, chunk);
qp->usage[chunk].phase = phase;
reclaim++;
}
}
}
isc_nanosecs_t time = isc_time_monotonic() - start;
atomic_fetch_add_relaxed(&recycle_time, time);
if (free > 0) {
LOG_STATS("qp defer" PRItime "free %u chunks", time, free);
}
if (reclaim > 0) {
LOG_STATS("qp will reclaim %u chunks in phase %u", reclaim,
phase);
LOG_STATS("qp defer" PRItime "%u chunks in phase %u", time,
reclaim, phase);
}
if (free > 0 || reclaim > 0) {
LOG_SIZES(qp, time);
}
return (reclaim > 0);
@@ -679,9 +707,7 @@ reclaim_chunks(dns_qp_t *qp, isc_qsbr_phase_t phase) {
if (free > 0) {
LOG_STATS("qp reclaim" PRItime "phase %u free %u chunks", time,
phase, free);
LOG_STATS("qp reclaim leaf %u live %u used %u free %u hold %u",
qp->leaf_count, qp->used_count - qp->free_count,
qp->used_count, qp->free_count, qp->hold_count);
LOG_SIZES(qp, time);
}
return (more);
@@ -765,10 +791,7 @@ marksweep_chunks(dns_qpmulti_t *multi) {
if (free > 0) {
LOG_STATS("qp marksweep" PRItime "free %u chunks", time, free);
LOG_STATS(
"qp marksweep leaf %u live %u used %u free %u hold %u",
qpw->leaf_count, qpw->used_count - qpw->free_count,
qpw->used_count, qpw->free_count, qpw->hold_count);
LOG_SIZES(qpw, time);
}
}
@@ -874,9 +897,7 @@ compact_recursive(dns_qp_t *qp, qp_node_t *parent) {
static void
compact(dns_qp_t *qp) {
LOG_STATS("qp compact before leaf %u live %u used %u free %u hold %u",
qp->leaf_count, qp->used_count - qp->free_count,
qp->used_count, qp->free_count, qp->hold_count);
LOG_SIZES(qp, 0LU);
isc_nanosecs_t start = isc_time_monotonic();
@@ -892,10 +913,7 @@ compact(dns_qp_t *qp) {
isc_nanosecs_t time = isc_time_monotonic() - start;
atomic_fetch_add_relaxed(&compact_time, time);
LOG_STATS("qp compact" PRItime
"leaf %u live %u used %u free %u hold %u",
time, qp->leaf_count, qp->used_count - qp->free_count,
qp->used_count, qp->free_count, qp->hold_count);
LOG_SIZES(qp, time);
}
void
@@ -1182,16 +1200,19 @@ dns_qpmulti_commit(dns_qpmulti_t *multi, dns_qp_t **qptp) {
/* reader_open() below has the matching atomic_load_acquire() */
atomic_store_release(&multi->reader, reader); /* COMMIT */
/* clean up what we can right now */
/*
* We don't use AUTOGC here because it is for use when we can only
* recycle mutable chunks; in this case we are (or, after a grace
* period, we will be) able to recycle immutable chunks, and NEEDGC
* takes account of immutable as well as mutable chunks.
*/
if (qp->transaction_mode == QP_UPDATE || QP_NEEDGC(qp)) {
recycle(qp);
}
/* the reclamation phase must be sampled after the commit */
isc_qsbr_phase_t phase = isc_qsbr_phase(multi->loopmgr);
if (defer_chunk_reclamation(qp, phase)) {
ISC_ASTACK_ADD(qsbr_work, multi, cleanup);
isc_qsbr_activate(multi->loopmgr, phase);
/* the reclamation phase must be sampled after the commit */
isc_qsbr_phase_t phase = isc_qsbr_phase(multi->loopmgr);
if (defer_chunk_reclamation(qp, phase)) {
ISC_ASTACK_ADD(qsbr_work, multi, cleanup);
isc_qsbr_activate(multi->loopmgr, phase);
}
}
*qptp = NULL;
+1 -1
View File
@@ -489,7 +489,7 @@ struct dns_qp {
/*% array of per-chunk allocation counters */
qp_usage_t *usage;
/*% number of slots in `chunk` and `usage` arrays */
qp_chunk_t chunk_max;
qp_chunk_t chunk_max, chunk_count;
/*% which chunk is used for allocations */
qp_chunk_t bump;
/*% nodes in the `bump` chunk below `fender` are read only [MT] */
+1 -4
View File
@@ -723,6 +723,7 @@ dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype,
if (result != ISC_R_SUCCESS) {
atomic_store(&xfr->shuttingdown, true);
xfr->shutdown_result = result;
xfrin_log(xfr, ISC_LOG_ERROR, "zone transfer setup failed");
dns_xfrin_detach(xfrp);
}
@@ -730,10 +731,6 @@ dns_xfrin_create(dns_zone_t *zone, dns_rdatatype_t xfrtype,
dns_db_detach(&db);
}
if (result != ISC_R_SUCCESS) {
xfrin_log(xfr, ISC_LOG_ERROR, "zone transfer setup failed");
}
return (result);
}
+10 -1
View File
@@ -11845,6 +11845,13 @@ checkds_cancel(dns_zone_t *zone) {
}
}
static void
forward_cancel_cb(void *arg) {
dns_request_t *request = arg;
dns_request_cancel(request);
dns_request_detach(&request);
}
static void
forward_cancel(dns_zone_t *zone) {
dns_forward_t *forward;
@@ -11859,7 +11866,9 @@ forward_cancel(dns_zone_t *zone) {
forward = ISC_LIST_NEXT(forward, link))
{
if (forward->request != NULL) {
dns_request_cancel(forward->request);
dns_request_t *request = NULL;
dns_request_attach(forward->request, &request);
isc_async_run(zone->loop, forward_cancel_cb, request);
}
}
}
-6
View File
@@ -71,11 +71,6 @@
? ISC_NETMGR_UDP_RECVBUF_SIZE \
: ISC_NETMGR_TCP_RECVBUF_SIZE)
/*
* Send buffer
*/
#define ISC_NETMGR_SENDBUF_SIZE (sizeof(uint16_t) + UINT16_MAX)
/*
* Make sure our RECVBUF size is large enough
*/
@@ -193,7 +188,6 @@ typedef struct isc__networker {
bool shuttingdown;
char *recvbuf;
char *sendbuf;
bool recvbuf_inuse;
ISC_LIST(isc_nmsocket_t) active_sockets;
-3
View File
@@ -230,8 +230,6 @@ isc_netmgr_create(isc_mem_t *mctx, isc_loopmgr_t *loopmgr, isc_nm_t **netmgrp) {
*worker = (isc__networker_t){
.recvbuf = isc_mem_get(loop->mctx,
ISC_NETMGR_RECVBUF_SIZE),
.sendbuf = isc_mem_get(loop->mctx,
ISC_NETMGR_SENDBUF_SIZE),
.active_sockets = ISC_LIST_INITIALIZER,
};
@@ -2320,7 +2318,6 @@ isc__networker_destroy(isc__networker_t *worker) {
isc_mempool_destroy(&worker->uvreq_pool);
isc_mem_put(worker->mctx, worker->sendbuf, ISC_NETMGR_SENDBUF_SIZE);
isc_mem_putanddetach(&worker->mctx, worker->recvbuf,
ISC_NETMGR_RECVBUF_SIZE);
isc_nm_detach(&netmgr);
+7
View File
@@ -19,6 +19,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+23 -11
View File
@@ -509,7 +509,7 @@ name_attr_zero(struct dns_name_attrs attributes) {
attributes.update | attributes.hasupdaterec));
}
/* dns_nane_init */
/* dns_name_init */
ISC_RUN_TEST_IMPL(init) {
dns_name_t name;
unsigned char offsets[1];
@@ -526,7 +526,7 @@ ISC_RUN_TEST_IMPL(init) {
assert_true(name_attr_zero(name.attributes));
}
/* dns_nane_invalidate */
/* dns_name_invalidate */
ISC_RUN_TEST_IMPL(invalidate) {
dns_name_t name;
unsigned char offsets[1];
@@ -544,7 +544,7 @@ ISC_RUN_TEST_IMPL(invalidate) {
assert_true(name_attr_zero(name.attributes));
}
/* dns_nane_setbuffer/hasbuffer */
/* dns_name_setbuffer/hasbuffer */
ISC_RUN_TEST_IMPL(buffer) {
dns_name_t name;
unsigned char buf[BUFSIZ];
@@ -559,7 +559,7 @@ ISC_RUN_TEST_IMPL(buffer) {
assert_true(dns_name_hasbuffer(&name));
}
/* dns_nane_isabsolute */
/* dns_name_isabsolute */
ISC_RUN_TEST_IMPL(isabsolute) {
struct {
const char *namestr;
@@ -593,7 +593,7 @@ ISC_RUN_TEST_IMPL(isabsolute) {
}
}
/* dns_nane_hash */
/* dns_name_hash */
ISC_RUN_TEST_IMPL(hash) {
struct {
const char *name1;
@@ -656,7 +656,7 @@ ISC_RUN_TEST_IMPL(hash) {
}
}
/* dns_nane_issubdomain */
/* dns_name_issubdomain */
ISC_RUN_TEST_IMPL(issubdomain) {
struct {
const char *name1;
@@ -699,14 +699,25 @@ ISC_RUN_TEST_IMPL(issubdomain) {
}
}
/* dns_nane_countlabels */
/* dns_name_countlabels */
ISC_RUN_TEST_IMPL(countlabels) {
struct {
const char *namestr;
unsigned int expect;
} testcases[] = {
{ "c.d", 2 }, { "c.d.", 3 }, { "a.b.c.d.", 5 },
{ "a.b.c.d", 4 }, { "a.b.c", 3 }, { ".", 1 },
{ "c.d", 2 },
{ "c.d.", 3 },
{ "a.b.c.d.", 5 },
{ "a.b.c.d", 4 },
{ "a.b.c", 3 },
{ ".", 1 },
{ "a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y."
"a.b.c.d.e.f.g.h.i.j.k.l.m.n.o.p.q.r.s.t.u.v.w.x.y."
"a.b.",
128 },
};
unsigned int i;
@@ -734,7 +745,7 @@ ISC_RUN_TEST_IMPL(countlabels) {
}
}
/* dns_nane_getlabel */
/* dns_name_getlabel */
ISC_RUN_TEST_IMPL(getlabel) {
struct {
const char *name1;
@@ -777,7 +788,7 @@ ISC_RUN_TEST_IMPL(getlabel) {
}
}
/* dns_nane_getlabelsequence */
/* dns_name_getlabelsequence */
ISC_RUN_TEST_IMPL(getlabelsequence) {
struct {
const char *name1;
@@ -845,6 +856,7 @@ ISC_RUN_TEST_IMPL(maxlabels) {
result = dns_name_fromstring(name, one_too_many + 2, 0, NULL);
assert_int_equal(result, ISC_R_SUCCESS);
assert_true(dns_name_isvalid(name));
assert_int_equal(dns_name_countlabels(name), DNS_NAME_MAXLABELS);
}
#ifdef DNS_BENCHMARK_TESTS
+7
View File
@@ -20,6 +20,13 @@
#include <string.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+14 -38
View File
@@ -17,9 +17,6 @@
#include <inttypes.h>
#include <stdbool.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <isc/buffer.h>
#include <isc/hash.h>
@@ -169,39 +166,18 @@ teardown_managers(void **state);
#define ISC_TEST_MAIN ISC_TEST_MAIN_CUSTOM(NULL, NULL)
#define ISC_TEST_MAIN_CUSTOM(setup, teardown) \
static int __child = 0; \
static void __alarm(int sig ISC_ATTR_UNUSED) { \
kill(__child, SIGABRT); \
} \
int main(void) { \
int r, status; \
\
switch ((__child = fork())) { \
case 0: \
break; \
case -1: \
exit(1); \
default: \
signal(SIGALRM, __alarm); \
alarm(1200); \
if ((r = waitpid(__child, &status, 0)) == __child) { \
/* Pass the exit status to the caller. */ \
if (WIFEXITED(status)) { \
exit(WEXITSTATUS(status)); \
} \
} \
exit(1); \
} \
\
signal(SIGPIPE, SIG_IGN); \
\
isc_mem_debugging |= ISC_MEM_DEBUGRECORD; \
isc_mem_create(&mctx); \
\
r = cmocka_run_group_tests(tests, setup, teardown); \
\
isc_mem_destroy(&mctx); \
\
return (r); \
#define ISC_TEST_MAIN_CUSTOM(setup, teardown) \
int main(void) { \
int r; \
\
signal(SIGPIPE, SIG_IGN); \
\
isc_mem_debugging |= ISC_MEM_DEBUGRECORD; \
isc_mem_create(&mctx); \
\
r = cmocka_run_group_tests(tests, setup, teardown); \
\
isc_mem_destroy(&mctx); \
\
return (r); \
}
+7
View File
@@ -21,6 +21,13 @@
#include <time.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -20,6 +20,13 @@
#include <stdlib.h>
#include <string.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+7
View File
@@ -18,6 +18,13 @@
#include <stdlib.h>
#include <unistd.h>
/*
* As a workaround, include an OpenSSL header file before including cmocka.h,
* because OpenSSL 3.1.0 uses __attribute__(malloc), conflicting with a
* redefined malloc in cmocka.h.
*/
#include <openssl/err.h>
#define UNIT_TESTING
#include <cmocka.h>
+2 -2
View File
@@ -35,8 +35,8 @@ while [ ${TIMEOUT} -gt 0 ]; do
TIMEOUT=$((TIMEOUT - 1))
done
if [ ${TIMEOUT} -eq 0 ]; then
echo "PID ${TEST_PROGRAM_PID} exceeded run time limit, sending SIGKILL" >&2
kill -KILL "${TEST_PROGRAM_PID}" 2>/dev/null
echo "PID ${TEST_PROGRAM_PID} exceeded run time limit, sending SIGABRT" >&2
kill -ABRT "${TEST_PROGRAM_PID}" 2>/dev/null
fi
TEST_PROGRAM_NAME=$(basename "${TEST_PROGRAM}")