]> git.ipfire.org Git - thirdparty/bind9.git/log
thirdparty/bind9.git
5 years agoAdded system test for stale-refresh-time
Diego Fronza [Tue, 20 Oct 2020 00:25:34 +0000 (21:25 -0300)] 
Added system test for stale-refresh-time

This test works as follow:
- Query for data.example rrset.
- Sleep until its TTL expires (2 secs).
- Disable authoritative server.
- Query for data.example again.
- Since server is down, answer come from stale cache, which has
  a configured stale-answer-ttl of 3 seconds.
- Enable authoritative server.
- Query for data.example again
- Since last query before activating authoritative server failed, and
  since 'stale-refresh-time' seconds hasn't elapsed yet, answer should
  come from stale cache and not from the authoritative server.

5 years agoAdjusted ancient rrset system test
Diego Fronza [Tue, 20 Oct 2020 00:24:38 +0000 (21:24 -0300)] 
Adjusted ancient rrset system test

Before the stale-refresh-time feature, the system test for ancient rrset
was somewhat based on the average time the previous tests and queries
were taking, thus not very precise.

After the addition of stale-refresh-time the system test for ancient
rrset started to fail since the queries for stale records (low
max-stale-ttl) were not taking the time to do a full resolution
anymore, since the answers now were coming from the cache (because the
rrset were stale and within stale-refresh-time window after the
previous resolution failure).

To handle this, the correct time to wait before rrset become ancient is
calculated from max-stale-ttl configuration plus the TTL set in the
rrset used in the tests (ans2/ans.pl).

Then before sending queries for ancient rrset, we check if we need to
sleep enough to ensure those rrset will be marked as ancient.

5 years agoWarn if 'stale-refresh-time' < 30 (default)
Diego Fronza [Thu, 5 Nov 2020 16:07:47 +0000 (13:07 -0300)] 
Warn if 'stale-refresh-time' < 30 (default)

RFC 8767 recommends that attempts to refresh to be done no more
frequently than every 30 seconds.

Added check into named-checkconf, which will warn if values below the
default are found in configuration.

BIND will also log the warning during loading of configuration in the
same fashion.

5 years agoAdd stale-refresh-time option
Diego Fronza [Mon, 19 Oct 2020 20:02:03 +0000 (17:02 -0300)] 
Add stale-refresh-time option

Before this update, BIND would attempt to do a full recursive resolution
process for each query received if the requested rrset had its ttl
expired. If the resolution fails for any reason, only then BIND would
check for stale rrset in cache (if 'stale-cache-enable' and
'stale-answer-enable' is on).

The problem with this approach is that if an authoritative server is
unreachable or is failing to respond, it is very unlikely that the
problem will be fixed in the next seconds.

A better approach to improve performance in those cases, is to mark the
moment in which a resolution failed, and if new queries arrive for that
same rrset, try to respond directly from the stale cache, and do that
for a window of time configured via 'stale-refresh-time'.

Only when this interval expires we then try to do a normal refresh of
the rrset.

The logic behind this commit is as following:

- In query.c / query_gotanswer(), if the test of 'result' variable falls
  to the default case, an error is assumed to have happened, and a call
  to 'query_usestale()' is made to check if serving of stale rrset is
  enabled in configuration.

- If serving of stale answers is enabled, a flag will be turned on in
  the query context to look for stale records:
  query.c:6839
  qctx->client->query.dboptions |= DNS_DBFIND_STALEOK;

- A call to query_lookup() will be made again, inside it a call to
  'dns_db_findext()' is made, which in turn will invoke rbdb.c /
  cache_find().

- In rbtdb.c / cache_find() the important bits of this change is the
  call to 'check_stale_header()', which is a function that yields true
  if we should skip the stale entry, or false if we should consider it.

- In check_stale_header() we now check if the DNS_DBFIND_STALEOK option
  is set, if that is the case we know that this new search for stale
  records was made due to a failure in a normal resolution, so we keep
  track of the time in which the failured occured in rbtdb.c:4559:
  header->last_refresh_fail_ts = search->now;

- In check_stale_header(), if DNS_DBFIND_STALEOK is not set, then we
  know this is a normal lookup, if the record is stale and the query
  time is between last failure time + stale-refresh-time window, then
  we return false so cache_find() knows it can consider this stale
  rrset entry to return as a response.

The last additions are two new methods to the database interface:
- setservestale_refresh
- getservestale_refresh

Those were added so rbtdb can be aware of the value set in configuration
option, since in that level we have no access to the view object.

5 years agoMerge branch '1913-remove-unused-leftovers' into 'main'
Michal Nowak [Wed, 11 Nov 2020 09:26:09 +0000 (09:26 +0000)] 
Merge branch '1913-remove-unused-leftovers' into 'main'

Resolve "Remove unused leftovers"

Closes #1913

See merge request isc-projects/bind9!4366

5 years agoAdd CHANGES entry
Michal Nowak [Fri, 6 Nov 2020 13:42:20 +0000 (14:42 +0100)] 
Add CHANGES entry

5 years agoAdd unused headers check to CI
Michal Nowak [Fri, 6 Nov 2020 11:28:26 +0000 (12:28 +0100)] 
Add unused headers check to CI

5 years agoDrop unused headers
Michal Nowak [Fri, 6 Nov 2020 11:27:41 +0000 (12:27 +0100)] 
Drop unused headers

5 years agoMerge branch 'mnowak/drop-OPENSSL_LIB' into 'main'
Michal Nowak [Wed, 11 Nov 2020 08:52:01 +0000 (08:52 +0000)] 
Merge branch 'mnowak/drop-OPENSSL_LIB' into 'main'

Drop @OPENSSL_LIB@ in bigkey

See merge request isc-projects/bind9!4383

5 years agoDrop @OPENSSL_LIB@ in bigkey
Michal Nowak [Tue, 10 Nov 2020 19:17:41 +0000 (20:17 +0100)] 
Drop @OPENSSL_LIB@ in bigkey

@OPENSSL_LIB@ was brought back with the
2f9f6f1fac6047afe93c4a9e89b8ed2fe3fefdde revert.

5 years agoMerge branch '2211-tsan-error-previous_closest_nsec-dns_rbt_findnode-vs-subtractrdata...
Mark Andrews [Tue, 10 Nov 2020 21:16:05 +0000 (21:16 +0000)] 
Merge branch '2211-tsan-error-previous_closest_nsec-dns_rbt_findnode-vs-subtractrdataset' into 'main'

Resolve "tsan error previous_closest_nsec(dns_rbt_findnode) vs subtractrdataset"

Closes #2211

See merge request isc-projects/bind9!4259

5 years agoAddress TSAN error between dns_rbt_findnode() and subtractrdataset().
Mark Andrews [Tue, 13 Oct 2020 02:00:36 +0000 (13:00 +1100)] 
Address TSAN error between dns_rbt_findnode() and subtractrdataset().

Having dns_rbt_findnode() in previous_closest_nsec() check of
node->data is a optimisation that triggers a TSAN error with
subtractrdataset().  find_closest_nsec() still needs to check if
the NSEC record are active or not and look for a earlier NSEC records
if it isn't.  Set DNS_RBTFIND_EMPTYDATA so node->data isn't referenced
without the node lock being held.

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1 (mutexes: read M1, read M2):
    #0 dns_rbt_findnode lib/dns/rbt.c:1708
    #1 previous_closest_nsec lib/dns/rbtdb.c:3760
    #2 find_closest_nsec lib/dns/rbtdb.c:3942
    #3 zone_find lib/dns/rbtdb.c:4091
    #4 dns_db_findext lib/dns/db.c:536
    #5 query_lookup lib/ns/query.c:5582
    #6 ns__query_start lib/ns/query.c:5505
    #7 query_setup lib/ns/query.c:5229
    #8 ns_query_start lib/ns/query.c:11380
    #9 ns__client_request lib/ns/client.c:2166
    #10 processbuffer netmgr/tcpdns.c:230
    #11 dnslisten_readcb netmgr/tcpdns.c:309
    #12 read_cb netmgr/tcp.c:832
    #13 <null> <null>
    #14 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M3):
    #0 subtractrdataset lib/dns/rbtdb.c:7133
    #1 dns_db_subtractrdataset lib/dns/db.c:742
    #2 diff_apply lib/dns/diff.c:368
    #3 dns_diff_apply lib/dns/diff.c:459
    #4 do_one_tuple lib/dns/update.c:247
    #5 update_one_rr lib/dns/update.c:275
    #6 delete_if_action lib/dns/update.c:689
    #7 foreach_rr lib/dns/update.c:471
    #8 delete_if lib/dns/update.c:716
    #9 dns_update_signaturesinc lib/dns/update.c:1948
    #10 receive_secure_serial lib/dns/zone.c:15637
    #11 dispatch lib/isc/task.c:1152
    #12 run lib/isc/task.c:1344
    #13 <null> <null>

    Location is heap block of size 130 at 0x000000000028 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 create_node lib/dns/rbt.c:2239
    #9 dns_rbt_addnode lib/dns/rbt.c:1202
    #10 dns_rbtdb_create lib/dns/rbtdb.c:8668
    #11 dns_db_create lib/dns/db.c:118
    #12 receive_secure_db lib/dns/zone.c:16154
    #13 dispatch lib/isc/task.c:1152
    #14 run lib/isc/task.c:1344
    #15 <null> <null>

    Mutex M1 (0x000000000040) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8527
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M2 (0x000000000044) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Mutex M3 (0x000000000046) created at:
    #0 pthread_rwlock_init <null>
    #1 isc_rwlock_init lib/isc/rwlock.c:39
    #2 dns_rbtdb_create lib/dns/rbtdb.c:8600
    #3 dns_db_create lib/dns/db.c:118
    #4 receive_secure_db lib/dns/zone.c:16154
    #5 dispatch lib/isc/task.c:1152
    #6 run lib/isc/task.c:1344
    #7 <null> <null>

    Thread T1 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_nm_start netmgr/netmgr.c:232
    #3 create_managers bin/named/main.c:909
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T2 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    Thread T3 (running) created by main thread at:
    #0 pthread_create <null>
    #1 isc_thread_create pthreads/thread.c:73
    #2 isc_taskmgr_create lib/isc/task.c:1434
    #3 create_managers bin/named/main.c:915
    #4 setup bin/named/main.c:1223
    #5 main bin/named/main.c:1523

    SUMMARY: ThreadSanitizer: data race lib/dns/rbt.c:1708 in dns_rbt_findnode

5 years agoMerge branch 'mnowak/revert-4350' into 'main'
Michal Nowak [Tue, 10 Nov 2020 16:51:47 +0000 (16:51 +0000)] 
Merge branch 'mnowak/revert-4350' into 'main'

Revert "Drop bigkey"

See merge request isc-projects/bind9!4369

5 years agoRevert "Drop bigkey"
Michal Nowak [Mon, 9 Nov 2020 10:49:05 +0000 (11:49 +0100)] 
Revert "Drop bigkey"

This reverts commit ef6703351a726eb9a8d8305075f1ee0f5be83516.

It is believed that the bigkey test is still useful.

5 years agoMerge branch 'matthijs-query-header-cleanup' into 'main'
Matthijs Mekking [Tue, 10 Nov 2020 15:01:42 +0000 (15:01 +0000)] 
Merge branch 'matthijs-query-header-cleanup' into 'main'

Cleanup query.h duplicate definitions

See merge request isc-projects/bind9!4381

5 years agoCleanup duplicate definitions in query.h
Matthijs Mekking [Tue, 10 Nov 2020 14:23:12 +0000 (15:23 +0100)] 
Cleanup duplicate definitions in query.h

5 years agoMerge branch '1840-netmgr-tls-layer' into 'main'
Ondřej Surý [Tue, 10 Nov 2020 14:12:53 +0000 (14:12 +0000)] 
Merge branch '1840-netmgr-tls-layer' into 'main'

Server-side TLS support in netmgr

Closes #1840

See merge request isc-projects/bind9!3532

5 years agoCHANGES note
Witold Kręcicki [Wed, 13 May 2020 09:43:46 +0000 (11:43 +0200)] 
CHANGES note

5 years agonetmgr: Add additional safeguards to netmgr/tls.c
Ondřej Surý [Tue, 10 Nov 2020 10:23:05 +0000 (11:23 +0100)] 
netmgr: Add additional safeguards to netmgr/tls.c

This commit adds couple of additional safeguards against running
sends/reads on inactive sockets.  The changes was modeled after the
changes we made to netmgr/tcpdns.c

5 years agoDoT test
Witold Kręcicki [Mon, 12 Oct 2020 21:06:55 +0000 (23:06 +0200)] 
DoT test

Preliminary test for DNSoverTLS - add the dot-port template to system
tests, test a simple query to an authoritative.

5 years agoAdd 'ephemeral' keyword to 'tls' option in listen-on directive.
Witold Kręcicki [Fri, 9 Oct 2020 20:13:45 +0000 (22:13 +0200)] 
Add 'ephemeral' keyword to 'tls' option in listen-on directive.

listen-on tls ephemeral will cause named to create an ephemeral
TLS self-signed certificate and key, stored only in memory.

5 years agoShutdown interface if we can't listen on it to avoid shutdown hang
Witold Kręcicki [Fri, 9 Oct 2020 20:06:41 +0000 (22:06 +0200)] 
Shutdown interface if we can't listen on it to avoid shutdown hang

5 years agoFix a startup/shutdown crash in ns_clientmgr_create
Witold Kręcicki [Fri, 9 Oct 2020 19:24:03 +0000 (21:24 +0200)] 
Fix a startup/shutdown crash in ns_clientmgr_create

5 years agoisc_nm_tls_create_server_ctx can create ephemeral certs
Witold Kręcicki [Fri, 9 Oct 2020 18:57:51 +0000 (20:57 +0200)] 
isc_nm_tls_create_server_ctx can create ephemeral certs

In-memory ephemeral certs creation for easy DoT/DoH deployment.

5 years agoAdd DoT support to bind
Witold Kręcicki [Thu, 1 Oct 2020 11:18:47 +0000 (13:18 +0200)] 
Add DoT support to bind

Parse the configuration of tls objects into SSL_CTX* objects.  Listen on
DoT if 'tls' option is setup in listen-on directive.  Use DoT/DoH ports
for DoT/DoH.

5 years agoadd parser support for TLS configuration options
Evan Hunt [Wed, 16 Sep 2020 19:21:32 +0000 (12:21 -0700)] 
add parser support for TLS configuration options

This commit adds stub parser support and tests for:
- "tls" statement, specifying key and cert.
- an optional "tls" keyvalue in listen-on statements for DoT
  configuration.

Documentation for these options has also been added to the ARM, but
needs further work.

5 years agoreport peer address in TLS mode, and specify protocol
Evan Hunt [Fri, 18 Sep 2020 01:28:37 +0000 (18:28 -0700)] 
report peer address in TLS mode, and specify protocol

- peer address was not being reported correctly by "dig +tls"
- the protocol used is now reported in the dig output: UDP, TCP, or TLS.

5 years agoadd "dig +tls"
Witold Kręcicki [Wed, 22 Jul 2020 06:59:42 +0000 (08:59 +0200)] 
add "dig +tls"

- add "+[no]tls" option to dig to enable TLS mode
- override the default port number in dig from 53 to 853 when using TLS

5 years agonetmgr: server-side TLS support
Witold Kręcicki [Wed, 13 May 2020 15:37:51 +0000 (17:37 +0200)] 
netmgr: server-side TLS support

Add server-side TLS support to netmgr - that includes moving some of the
isc_nm_ functions from tcp.c to a wrapper in netmgr.c calling a proper
tcp or tls function, and a new isc_nm_listentls() function.

Add DoT support to tcpdns - isc_nm_listentlsdns().

5 years agoMerge branch '2252-ns_client_sendraw-is-missing-dnstap-support' into 'main'
Mark Andrews [Tue, 10 Nov 2020 06:41:08 +0000 (06:41 +0000)] 
Merge branch '2252-ns_client_sendraw-is-missing-dnstap-support' into 'main'

Resolve "ns_client_sendraw() is missing DNSTAP support."

Closes #2252

See merge request isc-projects/bind9!4368

5 years agoAdd CHANGES not for [GL #2252]
Mark Andrews [Mon, 9 Nov 2020 05:32:42 +0000 (16:32 +1100)] 
Add CHANGES not for [GL #2252]

5 years agoCheck that DNSTAP captures forwarded UPDATE responses
Mark Andrews [Mon, 9 Nov 2020 05:26:56 +0000 (16:26 +1100)] 
Check that DNSTAP captures forwarded UPDATE responses

5 years agoImplement DNSTAP support in ns_client_sendraw()
Mark Andrews [Mon, 9 Nov 2020 02:44:22 +0000 (13:44 +1100)] 
Implement DNSTAP support in ns_client_sendraw()

ns_client_sendraw() is currently only used to relay UPDATE
responses back to the client.  dns_dt_send() is called with
this assumption.

5 years agoMerge branch '2259-zone_namerd_tostr-called-w-o-lock-being-held' into 'main'
Mark Andrews [Tue, 10 Nov 2020 06:14:21 +0000 (06:14 +0000)] 
Merge branch '2259-zone_namerd_tostr-called-w-o-lock-being-held' into 'main'

Resolve "zone_namerd_tostr called w/o lock being held"

Closes #2259

See merge request isc-projects/bind9!4376

5 years agoLock zone before calling zone_namerd_tostr()
Mark Andrews [Tue, 10 Nov 2020 04:53:06 +0000 (15:53 +1100)] 
Lock zone before calling zone_namerd_tostr()

    WARNING: ThreadSanitizer: data race
    Read of size 8 at 0x000000000001 by thread T1:
    #0 inline_raw lib/dns/zone.c:1375
    #1 zone_namerd_tostr lib/dns/zone.c:15316
    #2 dns_zone_name lib/dns/zone.c:15391
    #3 xfrin_log lib/dns/xfrin.c:1605
    #4 xfrin_destroy lib/dns/xfrin.c:1477
    #5 dns_xfrin_detach lib/dns/xfrin.c:739
    #6 xfrin_connect_done lib/dns/xfrin.c:970
    #7 tcpdnsconnect_cb netmgr/tcpdns.c:786
    #8 tcp_connect_cb netmgr/tcp.c:292
    #9 <null> <null>
    #10 <null> <null>

    Previous write of size 8 at 0x000000000001 by thread T2 (mutexes: write M1):
    #0 zone_shutdown lib/dns/zone.c:14462
    #1 dispatch lib/isc/task.c:1152
    #2 run lib/isc/task.c:1344
    #3 <null> <null>

    Location is heap block of size 2769 at 0x000000000013 allocated by thread T3:
    #0 malloc <null>
    #1 default_memalloc lib/isc/mem.c:713
    #2 mem_get lib/isc/mem.c:622
    #3 mem_allocateunlocked lib/isc/mem.c:1268
    #4 isc___mem_allocate lib/isc/mem.c:1288
    #5 isc__mem_allocate lib/isc/mem.c:2453
    #6 isc___mem_get lib/isc/mem.c:1037
    #7 isc__mem_get lib/isc/mem.c:2432
    #8 dns_zone_create lib/dns/zone.c:984
    #9 configure_zone bin/named/server.c:6502
    #10 do_addzone bin/named/server.c:13391
    #11 named_server_changezone bin/named/server.c:13788
    #12 named_control_docommand bin/named/control.c:207
    #13 control_command bin/named/controlconf.c:392
    #14 dispatch lib/isc/task.c:1152
    #15 run lib/isc/task.c:1344
    #16 <null> <null>

5 years agoMerge branch '2230-legacy-system-test-fails-intermittently' into 'main'
Mark Andrews [Mon, 9 Nov 2020 22:18:29 +0000 (22:18 +0000)] 
Merge branch '2230-legacy-system-test-fails-intermittently' into 'main'

Resolve "legacy system test fails intermittently"

Closes #2207

See merge request isc-projects/bind9!4295

5 years agoRetry edns512 multiple times to trigger fallback to edns at 512
Mark Andrews [Fri, 23 Oct 2020 22:36:33 +0000 (09:36 +1100)] 
Retry edns512 multiple times to trigger fallback to edns at 512

We want named to have slow resolving (multiple retries) when
there is a very small working MTU

5 years agoFixup legacy test to account for not falling back to EDNS 512 lookups.
Mark Andrews [Fri, 23 Oct 2020 02:33:34 +0000 (13:33 +1100)] 
Fixup legacy test to account for not falling back to EDNS 512 lookups.

The SOA lookup for edns512 could succeed if the negative response
for ns.edns512/AAAA completed before all the edns512/SOA query
attempts are made.  The ns.edns512/AAAA lookup returns tc=1 and
the SOA record is cached after processing the NODATA response.
Lookup a TXT record at edns512 and look it up instead of the
SOA record.

Removed 'checking that TCP failures do not influence EDNS statistics
in the ADB' as it is no longer appropriate.

5 years agoMerge branch '2258-xfrin-shutdown-race' into 'main'
Evan Hunt [Mon, 9 Nov 2020 21:45:14 +0000 (21:45 +0000)] 
Merge branch '2258-xfrin-shutdown-race' into 'main'

address some possible shutdown races in xfrin

Closes #2258

See merge request isc-projects/bind9!4374

5 years agoaddress some possible shutdown races in xfrin
Evan Hunt [Mon, 9 Nov 2020 20:33:37 +0000 (12:33 -0800)] 
address some possible shutdown races in xfrin

there were two failures during observed in testing, both occurring
when 'rndc halt' was run rather than 'rndc stop' - the latter dumps
zone contents to disk and presumably introduced enough delay to
prevent the races:

- a failure when the zone was shut down and called dns_xfrin_detach()
  before the xfrin had finished connecting; the connect timeout
  terminated without detaching its handle
- a failure when the tcpdns socket timer fired after the outerhandle
  had already been cleared.

this commit incidentally addresses a failure observed in mutexatomic
due to a variable having been initialized incorrectly.

5 years agoMerge branch '1840-netmgr-tls-layer-link-with-libssl' into 'main'
Ondřej Surý [Mon, 9 Nov 2020 15:38:22 +0000 (15:38 +0000)] 
Merge branch '1840-netmgr-tls-layer-link-with-libssl' into 'main'

Add support to link with libssl

See merge request isc-projects/bind9!4373

5 years agoAdd libssl libraries to Windows build
Ondřej Surý [Sat, 10 Oct 2020 05:26:18 +0000 (07:26 +0200)] 
Add libssl libraries to Windows build

This commit extends the perl Configure script to also check for libssl
in addition to libcrypto and change the vcxproj source files to link
with both libcrypto and libssl.

5 years agoautoconf: link with libssl
Witold Kręcicki [Wed, 13 May 2020 15:37:51 +0000 (17:37 +0200)] 
autoconf: link with libssl

This is prerequisite to adding DoT and DoH support to BIND 9.

5 years agoMerge branch '2016-xfrin-netmgr' into 'main'
Ondřej Surý [Mon, 9 Nov 2020 14:45:17 +0000 (14:45 +0000)] 
Merge branch '2016-xfrin-netmgr' into 'main'

use netmgr for xfrin

Closes #2016

See merge request isc-projects/bind9!4246

5 years agoCHANGES and release notes
Evan Hunt [Wed, 7 Oct 2020 21:07:36 +0000 (14:07 -0700)] 
CHANGES and release notes

5 years agoRefactor the xfrin reference counting
Ondřej Surý [Mon, 9 Nov 2020 10:32:55 +0000 (11:32 +0100)] 
Refactor the xfrin reference counting

Previously, the xfrin object relied on four different reference counters
(`refs`, `connects`, `sends`, `recvs`) and destroyed the xfrin object
only if all of them were zero.  This commit reduces the reference
counting only to the `references` (renamed from `refs`) counter.  We
keep the existing `connects`, `sends` and `recvs` as safe guards, but
they are not formally needed.

5 years agoremove isc_task from xfrin
Evan Hunt [Fri, 9 Oct 2020 23:38:30 +0000 (16:38 -0700)] 
remove isc_task from xfrin

since the network manager is now handling timeouts, xfrin doesn't
need an isc_task object.

it may be necessary to revert this later if we find that it's
important for zone_xfrdone() to be executed in the zone task context.
currently things seem to be working well without that, though.

5 years agoremove isc_timer from xfrin
Evan Hunt [Fri, 9 Oct 2020 23:34:22 +0000 (16:34 -0700)] 
remove isc_timer from xfrin

the network manager can now handle timeouts, so it isn't
necessary for xfrin to use isc_timer for the purpose any
longer.

5 years agouse netmgr for xfrin
Evan Hunt [Sun, 6 Sep 2020 07:38:50 +0000 (00:38 -0700)] 
use netmgr for xfrin

Use isc_nm_tcpdnsconnect() in xfrin.c for zone transfers.

5 years agoMerge branch 'mnowak/test-with-DDEBUG' into 'main'
Michal Nowak [Mon, 9 Nov 2020 12:36:24 +0000 (12:36 +0000)] 
Merge branch 'mnowak/test-with-DDEBUG' into 'main'

Enable debug build on Tumbleweed in CI

See merge request isc-projects/bind9!4367

5 years agoEnable debug build on Tumbleweed in CI
Michal Nowak [Fri, 6 Nov 2020 14:41:33 +0000 (15:41 +0100)] 
Enable debug build on Tumbleweed in CI

5 years agoMerge branch '2140-dig-netmgr' into 'main'
Evan Hunt [Sun, 8 Nov 2020 22:06:04 +0000 (22:06 +0000)] 
Merge branch '2140-dig-netmgr' into 'main'

Resolve "convert dig and friends to use the netmgr"

Closes #2140

See merge request isc-projects/bind9!4115

5 years agoCHANGES and release note
Evan Hunt [Fri, 11 Sep 2020 20:47:27 +0000 (13:47 -0700)] 
CHANGES and release note

5 years agonetmgr: Don't crash if socket() returns an error in udpconnect
Ondřej Surý [Sat, 7 Nov 2020 19:48:37 +0000 (20:48 +0100)] 
netmgr: Don't crash if socket() returns an error in udpconnect

socket() call can return an error - e.g. EMFILE, so we need to handle
this nicely and not crash.

Additionally wrap the socket() call inside a platform independent helper
function as the Socket data type on Windows is unsigned integer:

> This means, for example, that checking for errors when the socket and
> accept functions return should not be done by comparing the return
> value with –1, or seeing if the value is negative (both common and
> legal approaches in UNIX). Instead, an application should use the
> manifest constant INVALID_SOCKET as defined in the Winsock2.h header
> file.

5 years agodig: Refactor recv_done, so there's less exit paths
Ondřej Surý [Fri, 6 Nov 2020 15:12:17 +0000 (16:12 +0100)] 
dig: Refactor recv_done, so there's less exit paths

The recv_done() callback had many exit paths with different conditions,
and every path had it's own set of destructors.  The refactored code now
has unified exit path with descriptive goto labels matching the intent:

 - cancel_lookup
 - next_lookup
 - detach_query
 - keep_query

The only exception to the rule is check_for_more_data() path, where the
part of the query gets reused, so the query->readhandle and query gets
detached on it's own, and by going to the keep_query, we are just
skipping calling the destructors again.

5 years agonetmgr: Always load the result from async socket
Ondřej Surý [Fri, 6 Nov 2020 12:11:08 +0000 (13:11 +0100)] 
netmgr: Always load the result from async socket

Because we use result earlier for setting the loadbalancing on the
socket, we could be left with a ISC_R_NOTIMPLEMENTED value stored in the
variable and when the UDP connection would succeed, we would
errorneously return this value instead of ISC_R_SUCCESS.

5 years agodig: prevent query from being detached if udpconnect fails on first attempt
Evan Hunt [Thu, 5 Nov 2020 22:15:14 +0000 (14:15 -0800)] 
dig: prevent query from being detached if udpconnect fails on first attempt

FreeBSD sometimes returns spurious errors in UDP connect() attempts,
so we try a few times before giving up. However, each failed attempt
triggers a call to udp_ready() in dighost.c, and that was causing
the query object to be detached prematurely.

5 years agodig: add reference counter to the dig_lookup_t object
Ondřej Surý [Thu, 5 Nov 2020 14:22:38 +0000 (15:22 +0100)] 
dig: add reference counter to the dig_lookup_t object

Sometimes, the dig_lookup_t could be destroyed before the final
send_done() callback was be called, leading to dereferencing an
already freed dig_lookup_t object.  By making the dig_lookup_t
reference counted, we are ensuring that it won't be freed until
the last reference (from dig_query_t .lookup) is released.

5 years agodig: add new debugging output
Ondřej Surý [Wed, 4 Nov 2020 11:40:13 +0000 (12:40 +0100)] 
dig: add new debugging output

track creation, attachment and detachment of dig_query objects.

5 years agodig: add reference counting to dig_query_t
Ondřej Surý [Wed, 4 Nov 2020 11:40:13 +0000 (12:40 +0100)] 
dig: add reference counting to dig_query_t

add a reference counter to the dig_query object to ensure
it isn't freed until the last caller releases it.

5 years agoreduce timing dependencies in system tests
Evan Hunt [Sun, 27 Sep 2020 06:27:24 +0000 (23:27 -0700)] 
reduce timing dependencies in system tests

one of the tests in the resolver system test depends on dig
getting no response to its first two query attempts, and SERVFAIL
on the third after resolution times out.

using a 5-second retry timer in dig means the SERVFAIL response
could occur while dig is discarding the second query and preparing
to send the third. in this case the server's response could be
missed.  shortening the retry interval to 4 seconds ensures that
dig has already sent the third query when the SERVFAIL response
arrives.

also, the serve-stale system test could fail due to a race in which
it timed out after waiting ten seconds for a file to be written, and
the dig timeout was just a bit longer. this is addressed by extending
the dig timeout to 11 seconds for this test.

5 years agodig: use new netmgr timeout mechanism
Evan Hunt [Tue, 3 Nov 2020 05:38:56 +0000 (21:38 -0800)] 
dig: use new netmgr timeout mechanism

use isc_nmhandle_settimeout() to set read/recv timeouts, and get rid
of connect_timeout() and related functions in dighost.c.

5 years agoadd isc_nmhandle_settimeout() function
Evan Hunt [Tue, 3 Nov 2020 03:58:05 +0000 (19:58 -0800)] 
add isc_nmhandle_settimeout() function

this function sets the read timeout for the socket associated
with a netmgr handle and, if the timer is running, resets it.
for TCPDNS sockets it also sets the read timeout and resets the
timer on the outer TCP socket.

5 years agodig: setup IDN whenever printing a message
Evan Hunt [Sat, 12 Sep 2020 20:23:52 +0000 (13:23 -0700)] 
dig: setup IDN whenever printing a message

because dig now uses the netmgr, printing of response messages
happens in a different thread than setup. the IDN output filtering
procedure, which set using dns_name_settotextfilter(), is stored as
thread-local data, and so if it's set during setup, it won't be
accessible when printing. we now set it immediately before printing,
in the same thread, and clear it immedately afterward.

5 years agodig: remove "+unexpected" option
Evan Hunt [Tue, 8 Sep 2020 22:58:09 +0000 (15:58 -0700)] 
dig: remove "+unexpected" option

The network manager does not support returning UDP datagrams to
clients from unexpected sources; it is therefore not possible for
dig to accept them.  The "+[no]unexpected" option has therefore
been removed from the dig command and its documentation.

5 years agoconvert dig/host/nslookup to use the netmgr
Evan Hunt [Sat, 5 Sep 2020 23:37:24 +0000 (16:37 -0700)] 
convert dig/host/nslookup to use the netmgr

use netmgr functions instead of isc_socket for dig, host, and
nslookup. note that `dig +unexpected` is not working.

5 years agofix nmhandle attach/detach errors in tcpdnsconnect_cb()
Ondřej Surý [Wed, 4 Nov 2020 19:59:31 +0000 (20:59 +0100)] 
fix nmhandle attach/detach errors in tcpdnsconnect_cb()

we need to attach to the statichandle when connecting TCPDNS sockets,
same as with UDP.

5 years agoMerge branch 'artem/fix-build-with-DEBUG-defined' into 'main'
Artem Boldariev [Fri, 6 Nov 2020 10:40:33 +0000 (10:40 +0000)] 
Merge branch 'artem/fix-build-with-DEBUG-defined' into 'main'

Fix build with DEBUG defined (-DDEBUG)

See merge request isc-projects/bind9!4351

5 years agoFix build with DEBUG defined (-DDEBUG)
Artem Boldariev [Tue, 3 Nov 2020 11:27:35 +0000 (13:27 +0200)] 
Fix build with DEBUG defined (-DDEBUG)

The problem was introduced by commit 98b55eb4.

5 years agoMerge branch '2239-fctx-id-is-uninitialized-and-effectively-unused' into 'main'
Mark Andrews [Fri, 6 Nov 2020 02:26:11 +0000 (02:26 +0000)] 
Merge branch '2239-fctx-id-is-uninitialized-and-effectively-unused' into 'main'

Resolve "fctx:id is uninitialized and effectively unused"

Closes #2239

See merge request isc-projects/bind9!4346

5 years agoremove fctx:id field
Mark Andrews [Tue, 3 Nov 2020 03:46:49 +0000 (14:46 +1100)] 
remove fctx:id field

5 years agoMerge branch '1728-drop-big-key' into 'main'
Michal Nowak [Thu, 5 Nov 2020 16:25:32 +0000 (16:25 +0000)] 
Merge branch '1728-drop-big-key' into 'main'

Drop bigkey

Closes #1728

See merge request isc-projects/bind9!4350

5 years agoDrop bigkey
Michal Nowak [Mon, 2 Nov 2020 15:52:14 +0000 (16:52 +0100)] 
Drop bigkey

The 'bigkey' binary is not used anywhere, therefor it's sources should
be removed.

5 years agoMerge branch 'michal/miscellaneous-windows-tweaks' into 'main'
Michał Kępień [Thu, 5 Nov 2020 14:06:43 +0000 (14:06 +0000)] 
Merge branch 'michal/miscellaneous-windows-tweaks' into 'main'

Miscellaneous Windows tweaks

Closes images#10

See merge request isc-projects/bind9!4354

5 years agoFix detection of CMake-built libuv on Windows
Michał Kępień [Thu, 5 Nov 2020 10:45:19 +0000 (11:45 +0100)] 
Fix detection of CMake-built libuv on Windows

As of libuv 1.36.0, CMake is the only supported build method for libuv
on Windows.  Account for that fact by adjusting the relevant paths and
DLL file names used in the win32utils/Configure script.  Update
Windows-specific documentation accordingly.

5 years agoUse "image" key in Windows GitLab CI job templates
Michał Kępień [Thu, 5 Nov 2020 10:45:19 +0000 (11:45 +0100)] 
Use "image" key in Windows GitLab CI job templates

Our GitLab Runner Custom executor scripts now use the "image" key for
determining the Windows Docker image to use for a given CI job.  Update
.gitlab-ci.yml to reflect that change.

5 years agoMerge branch 'michal/rpz-system-test-fix-fast-expire' into 'main'
Michał Kępień [Thu, 5 Nov 2020 07:03:30 +0000 (07:03 +0000)] 
Merge branch 'michal/rpz-system-test-fix-fast-expire' into 'main'

"rpz" system test: fix intermittent false positive (expired RPZ zone)

See merge request isc-projects/bind9!4357

5 years agoWait for the "fast-expire" zone to be transferred
Michał Kępień [Thu, 5 Nov 2020 06:53:43 +0000 (07:53 +0100)] 
Wait for the "fast-expire" zone to be transferred

In order for a "fast-expire/IN: response-policy zone expired" message to
be logged in ns3/named.run, the "fast-expire" zone must first be
transferred in by that server.  However, with unfavorable timing, ns3
may be stopped before it manages to fetch the "fast-expire" zone from
ns5 and after the latter has been reconfigured to no longer serve that
zone.  In such a case, the "rpz" system test will report a false
positive for the relevant check.  Prevent that from happening by
ensuring ns3 manages to transfer the "fast-expire" zone before getting
shut down.

5 years agoMerge branch '2243-cid-312970-incorrect-expression-copy_paste_error-in-tcp-c' into...
Mark Andrews [Thu, 5 Nov 2020 00:32:06 +0000 (00:32 +0000)] 
Merge branch '2243-cid-312970-incorrect-expression-copy_paste_error-in-tcp-c' into 'main'

Resolve "CID 312970: Incorrect expression (COPY_PASTE_ERROR) in tcp.c"

Closes #2243

See merge request isc-projects/bind9!4355

5 years agoIncorrect result code passed to failed_connect_cb
Mark Andrews [Wed, 4 Nov 2020 04:20:13 +0000 (15:20 +1100)] 
Incorrect result code passed to failed_connect_cb

    *** CID 312970:  Incorrect expression  (COPY_PASTE_ERROR) /lib/isc/netmgr/tcp.c: 282 in tcp_connect_cb()
    276      }
    277
    278      isc__nm_incstats(sock->mgr, sock->statsindex[STATID_CONNECT]);
    279      r = uv_tcp_getpeername(&sock->uv_handle.tcp, (struct sockaddr *)&ss,
    280             &(int){ sizeof(ss) });
    281      if (r != 0) {
    >>>     CID 312970:  Incorrect expression  (COPY_PASTE_ERROR)
    >>>     "status" in "isc___nm_uverr2result(status, true, "netmgr/tcp.c", 282U)" looks like a copy-paste error.
    282      failed_connect_cb(sock, req, isc__nm_uverr2result(status));
    283      return;
    284      }
    285
    286      atomic_store(&sock->connecting, false);
    287

5 years agoMerge branch 'matthijs-test-multi-signer-model' into 'main'
Matthijs Mekking [Wed, 4 Nov 2020 13:27:22 +0000 (13:27 +0000)] 
Merge branch 'matthijs-test-multi-signer-model' into 'main'

Add a test for RFC 8901 signer model 2

See merge request isc-projects/bind9!4306

5 years agokasp test: Use DEFAULT_ALGORITHM in tests.sh
Matthijs Mekking [Mon, 2 Nov 2020 10:04:07 +0000 (11:04 +0100)] 
kasp test: Use DEFAULT_ALGORITHM in tests.sh

Some setup scripts uses DEFAULT_ALGORITHM in their dnssec-policy
and/or initial signing. The tests still used the literal values
13, ECDSAP256SHA256, and 256. Replace those occurrences where
appropriate.

5 years agoAdd a test for RFC 8901 signer model 2
Matthijs Mekking [Mon, 26 Oct 2020 16:42:31 +0000 (17:42 +0100)] 
Add a test for RFC 8901 signer model 2

The new 'dnssec-policy' was already compatible with multi-signer
model 2, now we also have a test for it.

5 years agoMerge branch '2244-nta-related-crash-after-reconfiguring-views' into 'main'
Mark Andrews [Tue, 3 Nov 2020 12:47:43 +0000 (12:47 +0000)] 
Merge branch '2244-nta-related-crash-after-reconfiguring-views' into 'main'

Resolve "NTA-related crash after reconfiguring views"

Closes #2244

See merge request isc-projects/bind9!4345

5 years agoAdd CHANGES for [GL #2244]
Mark Andrews [Tue, 3 Nov 2020 00:30:05 +0000 (11:30 +1100)] 
Add CHANGES for [GL #2244]

5 years agoCall nta_detach() before dns_view_weakdetach() so view is available.
Mark Andrews [Tue, 3 Nov 2020 00:25:55 +0000 (11:25 +1100)] 
Call nta_detach() before dns_view_weakdetach() so view is available.

5 years agoMerge branch 'marka-fixup-dnssec' into 'main'
Mark Andrews [Tue, 3 Nov 2020 00:48:58 +0000 (00:48 +0000)] 
Merge branch 'marka-fixup-dnssec' into 'main'

dnssec system test needs python and perl

See merge request isc-projects/bind9!4342

5 years agodnssec system test needs python and perl
Mark Andrews [Mon, 2 Nov 2020 03:58:59 +0000 (14:58 +1100)] 
dnssec system test needs python and perl

5 years agoMerge branch '2227-tcp-connection-closed-second-fix' into 'main'
Ondřej Surý [Mon, 2 Nov 2020 22:52:01 +0000 (22:52 +0000)] 
Merge branch '2227-tcp-connection-closed-second-fix' into 'main'

Fix improper closed connection handling in tcpdns.

Closes #2227

See merge request isc-projects/bind9!4341

5 years agoPut up additional safe guards to not use inactive/closed tcpdns socket
Ondřej Surý [Mon, 2 Nov 2020 14:55:12 +0000 (15:55 +0100)] 
Put up additional safe guards to not use inactive/closed tcpdns socket

When we are operating on the tcpdns socket, we need to double check
whether the socket or its outerhandle or its listener or its mgr is
still active and when not, bail out early.

5 years agoAdd CHANGES note for [GL #2227]
Ondřej Surý [Mon, 2 Nov 2020 14:00:49 +0000 (15:00 +0100)] 
Add CHANGES note for [GL #2227]

5 years agoFix improper closed connection handling in tcpdns.
Witold Kręcicki [Sat, 31 Oct 2020 20:08:53 +0000 (21:08 +0100)] 
Fix improper closed connection handling in tcpdns.

If dnslisten_readcb gets a read callback it needs to verify that the
outer socket wasn't closed in the meantime, and issue a CANCELED callback
if it was.

5 years agoMerge branch '2237-placeholder' into 'main'
Michał Kępień [Mon, 2 Nov 2020 11:25:30 +0000 (11:25 +0000)] 
Merge branch '2237-placeholder' into 'main'

Add placeholder for #2237

See merge request isc-projects/bind9!4343

5 years agoAdd placeholder for #2237
Michał Kępień [Mon, 2 Nov 2020 11:24:11 +0000 (12:24 +0100)] 
Add placeholder for #2237

5 years agoMerge branch '2235-add-netmgr-functions-to-support-outgoing-dns-queries' into 'main'
Ondřej Surý [Fri, 30 Oct 2020 13:40:18 +0000 (13:40 +0000)] 
Merge branch '2235-add-netmgr-functions-to-support-outgoing-dns-queries' into 'main'

Resolve "Add netmgr functions to support outgoing DNS queries"

Closes #2235

See merge request isc-projects/bind9!4318

5 years agoCHANGES
Evan Hunt [Thu, 29 Oct 2020 01:00:20 +0000 (18:00 -0700)] 
CHANGES

5 years agocheck return value from uv_tcp_getpeername() when connecting
Evan Hunt [Thu, 29 Oct 2020 22:42:09 +0000 (15:42 -0700)] 
check return value from uv_tcp_getpeername() when connecting

if we can't determine the peer, the connect should fail.

5 years agoadd a netmgr unit test
Ondřej Surý [Tue, 27 Oct 2020 16:12:41 +0000 (17:12 +0100)] 
add a netmgr unit test

tests of UDP and TCP cases including:
- sending and receiving
- closure sockets without reading or sending
- closure of sockets at various points while sending and receiving
- since the teste is multithreaded, cmocka now aborts tests on the
  first failure, so that failures in subthreads are caught and
  reported correctly.

5 years agoset REUSEPORT and REUSEADDR on TCP sockets if needed
Evan Hunt [Thu, 29 Oct 2020 18:15:26 +0000 (11:15 -0700)] 
set REUSEPORT and REUSEADDR on TCP sockets if needed

When binding a TCP socket, if bind() fails with EADDRINUSE,
try again with REUSEPORT/REUSEADDR (or the equivalent options).

5 years agoFix more races between connect and shutdown
Ondřej Surý [Thu, 29 Oct 2020 11:04:00 +0000 (12:04 +0100)] 
Fix more races between connect and shutdown

There were more races that could happen while connecting to a
socket while closing or shutting down the same socket.  This
commit introduces a .closing flag to guard the socket from
being closed twice.