Commit graph

12048 commits

Author SHA1 Message Date
Mark Andrews
bed9ad79ba add assertions to silence clang false positive 2019-04-22 23:03:46 -04:00
Evan Hunt
7402615697 force SERVFAIL response in the gotanswer failure case
- named could return FORMERR if parsing iterative responses
  ended with a result code such as DNS_R_OPTERR. instead of
  computing a response code based on the result, in this case
  we now just force the response to be SERVFAIL.
2019-04-22 18:48:19 -07:00
Mark Andrews
da7f683abf using 0 instead of false 2019-04-23 11:08:06 +10:00
Ondřej Surý
2e40cc94dc On non-GNUC systems, use uintmax_t in the ISC_ALIGN macro 2019-04-18 12:55:25 +02:00
Ondřej Surý
4edbb773a1 Refactor the DNS_RDATASET_FIXED code to use constants instead of ifdefs 2019-04-17 10:35:11 +02:00
Evan Hunt
7fff3295f5 if recursion is allowed and minimal-responses is no, search other databases
this restores functionality that was removed in commit 03be5a6b4e,
allowing named to search in authoritative zone databases outside the
current zone for additional data, if and only if recursion is allowed
and minimal-responses is disabled.
2019-04-15 11:05:04 -07:00
Evan Hunt
1f578cdb12 dnstap: if recursion is not available, log queries as AQ instead of CQ 2019-04-11 15:13:13 -07:00
Matthijs Mekking
3cb8c49c73 With update-check-ksk also consider offline keys
The option `update-check-ksk` will look if both KSK and ZSK are
available before signing records.  It will make sure the keys are
active and available.  However, for operational practices keys may
be offline.  This commit relaxes the update-check-ksk check and will
mark a key that is offline to be available when adding signature
tasks.
2019-04-11 15:22:30 +02:00
Matthijs Mekking
2e83e3255a Style: some curly brackets 2019-04-11 15:22:30 +02:00
Mark Andrews
b78e128a2f Add debug printfs 2019-04-11 19:19:46 +10:00
Mark Andrews
e73a5b0ce3 Prevent WIRE_INVALID() being called without a argument 2019-04-11 19:19:46 +10:00
Mark Andrews
b089f43b7a Check multi-line output from dns_rdata_tofmttext()
Check that multi-line output from dns_rdata_tofmttext() can be read
back in by dns_rdata_fromtext().
2019-04-11 19:19:46 +10:00
Mark Andrews
1a75a5cee6 Process master file comments and make input invalid again 2019-04-11 19:19:10 +10:00
Mark Andrews
7941a9554f Set 'specials' to match 'specials' in 'lib/dns/master.c' 2019-04-11 18:13:39 +10:00
Mark Andrews
cc5e16e4d3 Fix whitespace so that the names align 2019-04-11 18:13:39 +10:00
Mark Andrews
36f30f5731 Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire
Add dns_rdata_totext() and dns_rdata_fromtext() to fromwire for
valid inputs to ensure that what we accept in dns_rdata_fromwire()
can be written out and read back in.
2019-04-11 18:13:39 +10:00
Mark Andrews
8fd4308bda Initialise mincachettl and minncachettl to zero in dns_view_create. 2019-04-10 14:48:49 +10:00
Mark Andrews
6eb28eda1e add ds unit test 2019-04-10 13:37:03 +10:00
Mark Andrews
b274f3fad7 enforce DS hash exists 2019-04-10 13:36:08 +10:00
Mark Andrews
7b0a653858 check that from fromtext produces valid towire input 2019-04-10 11:13:52 +10:00
Mark Andrews
82d4931440 for rkey flags MUST be zero 2019-04-09 13:55:30 +10:00
Mark Andrews
2592e91516 check flags for no key in fromwire for *KEY 2019-04-09 13:55:30 +10:00
Mark Andrews
698a6f955e <dns/ecs.h> was missing ISC_LANG_ENDDECLS. 2019-04-09 11:47:26 +10:00
Witold Kręcicki
06021b3529 Fix deadlock in RPZ update code.
In dns_rpz_update_from_db we call setup_update which creates the db
iterator and calls dns_dbiterator_first. This unpauses the iterator and
might cause db->tree_lock to be acquired. We then do isc_task_send(...)
on an event to do quantum_update, which (correctly) after each iteration
calls dns_dbiterator_pause, and re-isc_task_sends itself.

That's an obvious bug, as we're holding a lock over an async task send -
if a task requesting write (e.g. prune_tree) is scheduled on the same
workers queue as update_quantum but before it, it will wait for the
write lock indefinitely, resulting in a deadlock.

To fix it we have to pause dbiterator in setup_update.
2019-04-06 12:22:49 -07:00
Witold Kręcicki
7c960e89ea In resume_qmin check if the fetch context is already shutting down - if so, try to destroy it, don't continue 2019-03-29 14:30:40 +01:00
Witold Kręcicki
51a55ddbb7 Fix assertion failure in nslookup/dig/mdig when message has multiple SIG(0) options.
When parsing message with DNS_MESSAGE_BESTEFFORT (used exclusively in
tools, never in named itself) if we hit an invalid SIG(0) in wrong
place we continue parsing the message, and put the sig0 in msg->sig0.
If we then hit another sig0 in a proper place we see that msg->sig0
is already 'taken' and we don't free name and rdataset, and we don't
set seen_problem. This causes an assertion failure.
This fixes that issue by setting seen_problem if we hit second sig0,
tsig or opt, which causes name and rdataset to be always freed.
2019-03-26 21:15:00 +11:00
Ondřej Surý
8ccce7e24b Make lib/dns/dnstap.pb-c.h private header
This changes dns_dtdata struct to not expose data types from dnstap.pb-c.h to
prevent the need for including this header where not really needed.
2019-03-22 11:38:45 +01:00
Evan Hunt
91dca0f8da don't fail when allow-update{,-forwarding} is used globally 2019-03-21 21:17:49 -07:00
Mark Andrews
473987d8d9 Disallow empty ZONEMD hashes
This change is the result of discussions with the authors of
draft-wessels-dns-zone-digest.
2019-03-22 06:49:01 +11:00
Mark Andrews
40a770b932 add brackets for multi-line output 2019-03-21 19:52:27 +11:00
Evan Hunt
b3ff3bf2e4 remove configuration, syntax checking and implementation of dnssec-enable 2019-03-14 23:29:07 -07:00
Evan Hunt
fd298a2da8 mark "dnssec-enable" as obsolete in the parser 2019-03-14 23:29:07 -07:00
Petr Menšík
71c4fad592 Fix regression in dnstap_test with native pkcs11
Change to cmocka broken initialization of TZ environment. This time,
commit 1cf1254051 is not soon enough. Has
to be moved more forward, before any other tests. It library is not full
reinitialized on each test.
2019-03-15 01:03:53 -04:00
Mark Andrews
1eba2c5b06 force promotion to unsigned int 2019-03-14 13:34:59 -07:00
Mark Andrews
d8d04edfba assert hevent->rdataset is non NULL 2019-03-14 12:47:53 -07:00
Mark Andrews
719b1d7fdc missing #include <isc/lang.h> 2019-03-15 00:24:33 +11:00
Mark Andrews
ff8bf617e7 add missing MAYBE_UNLOCK 2019-03-13 10:51:56 +11:00
Witold Kręcicki
aa3da7a232 Clean up client->ecs when we're done with the request. 2019-03-12 13:35:28 -07:00
Witold Kręcicki
56183a3917 Fix a race in fctx_cancelquery.
When sending an udp query (resquery_send) we first issue an asynchronous
isc_socket_connect and increment query->connects, then isc_socket_sendto2
and increment query->sends.
If we happen to cancel this query (fctx_cancelquery) we need to cancel
all operations we might have issued on this socket. If we are under very high
load the callback from isc_socket_connect (resquery_udpconnected) might have
not yet been fired. In this case we only cancel the CONNECT event on socket,
and ignore the SEND that's waiting there (as there is an `else if`).
Then we call dns_dispatch_removeresponse which kills the dispatcher socket
and calls isc_socket_close - but if system is under very high load, the send
we issued earlier might still not be complete - which triggers an assertion
because we're trying to close a socket that's still in use.

The fix is to always check if we have incomplete sends on the socket and cancel
them if we do.
2019-03-12 18:42:35 +01:00
Mark Andrews
a520662ed4 allow dlz to signal that the view's transfer acl should be used 2019-03-11 14:27:13 +11:00
Ondřej Surý
7eea756858 Restore missing check for flockfile and getc_unlocked 2019-03-08 21:20:20 +01:00
Ondřej Surý
a04a390195 Convert *.vcxproj.user to CRLF line endings 2019-03-08 18:01:48 +01:00
Ondřej Surý
c2637c8429 Use ForcedIncludeFiles directive to include config.h everywhere automatically 2019-03-08 17:14:38 +01:00
Ondřej Surý
1b25d8a0ca Remove explicit '#include <config.h>' from the header files (the include should not have been there in the first place) 2019-03-08 15:15:05 +01:00
Ondřej Surý
78d0cb0a7d Use coccinelle to remove explicit '#include <config.h>' from the source files 2019-03-08 15:15:05 +01:00
Michał Kępień
ada6846a10 Make delv use OS-supplied ephemeral port range
Make delv honor the operating system's preferred ephemeral port range
instead of always using the default 1024-65535 range for outgoing
messages.
2019-03-08 13:13:32 +01:00
Tony Finch
0f219714e1 cleanup: use dns_secalg_t and dns_dsdigest_t where appropriate
Use them in structs for various rdata types where they are missing.
This doesn't change the structs since we are replacing explicit
uint8_t field types with aliases for uint8_t.

Use dns_dsdigest_t in library function arguments.

Improve dnssec-cds with these more specific types.
2019-03-08 18:37:50 +11:00
Mark Andrews
1fc7be36eb #include <limits.h> for PATH_MAX, define if not found 2019-03-08 17:15:01 +11:00
Evan Hunt
7f26cad247 silence a warning about potential snprintf overrun 2019-03-08 00:27:49 -05:00
Mark Andrews
435ae2f29a Handle EDQUOT and ENOSPC errors 2019-03-07 21:02:48 -08:00
Mark Andrews
cb32cd98bd fix the use of dns_wildcardname as an optimisation in DLZ 2019-03-07 19:59:29 -08:00
Mark Andrews
3f2b7e1006 add noreturn attribute 2019-03-07 16:45:04 +11:00
Mark Andrews
d1fa8be611 add the ability to control whether SOA records are added response-policy modified answers 2019-03-06 20:47:28 -08:00
Witold Kręcicki
b57a38ae43 Fix a race in socket code when internal_{accept, send, receive} is called
from event loop on an socket and, in the meantime, someone has closed this
socket.
2019-03-06 12:56:11 -08:00
Michał Kępień
af4b81f944 Log plugin unloading at debug level
During server reconfiguration, plugin instances set up for the old views
are unloaded very close to the end of the whole process, after new
plugin instances are set up.  As the log message announcing plugin
unloading is emitted at the default "info" level, the user might be
misled into thinking that it is the new plugin instances that are being
unloaded for some reason, particularly because all other messages logged
at the "info" level around the same time inform about setting things up
rather than tearing them down.  Since no distinction is currently made
between destroying a view due to reconfiguration and due to a shutdown
in progress, there is no easy way to vary the contents of the log
message depending on circumstances.  Since this message is not a
particularly critical one, demote it to debug level to prevent
confusion.
2019-03-06 15:19:07 -05:00
Michał Kępień
1a9fc624ca Look for named plugins in ${libdir}/named
When the "library" part of a "plugin" configuration stanza does not
contain at least one path separator, treat it as a filename and assume
it is a name of a shared object present in the named plugin installation
directory.  Absolute and relative paths can still be used and will be
used verbatim.  Get the full path to a plugin before attempting to
check/register it so that all relevant log messages include the same
plugin path (apart from the one logged when the full path cannot be
determined).
2019-03-05 16:06:25 -08:00
Michał Kępień
d181c28c60 Add ns_plugin_expandpath()
Implement a helper function which, given an input string:

  - copies it verbatim if it contains at least one path separator,
  - prepends the named plugin installation directory to it otherwise.

This function will allow configuration parsing code to conveniently
determine the full path to a plugin module given either a path or a
filename.

While other, simpler ways exist for making sure filenames passed to
dlopen() cause the latter to look for shared objects in a specific
directory, they are very platform-specific.  Using full paths is thus
likely the most portable and reliable solution.

Also added unit tests for ns_plugin_expandpath() to ensure it behaves
as expected for absolute paths, relative paths, and filenames, for
various target buffer sizes.

(Note: plugins share a directory with named on Windows; there is no
default plugin path. Therefore the source path is copied to the
destination path with no modification.)
2019-03-05 16:06:24 -08:00
Mark Andrews
cb913177ae improve clang / cmocka integration 2019-03-05 10:20:29 -08:00
Evan Hunt
3e74c7e5ff fix crash in query_respond_any() from all records being hidden
in query_respond_any(), the assumption had previously been made that it
was impossible to get past iterating the node with a return value of
ISC_R_NOMORE but not have found any records, unless we were searching
for RRSIG or SIG. however, it is possible for other types to exist but
be hidden, such as when the zone is transitioning from insecure to
secure and DNSSEC types are encountered, and this situation could
trigger an assertion.  removed the assertion and reorganized the code.
2019-02-28 13:55:47 -08:00
Matthijs Mekking
e5565808e4 Update CHANGES 2019-02-22 14:00:01 +01:00
Matthijs Mekking
6ed14eff25 Unregister RPZ CATZ db cbs when zone load fails
In case when a zone fails to load because the file does not exist
or is malformed, we should not run the callback that updates the
zone database when the load is done.  This is achieved by
unregistering the callbacks if at zone load end if the result
indicates something else than success.
2019-02-22 13:59:10 +01:00
Matthijs Mekking
6756280242 Remove rpz->db_registered
As pointed out in !813 db_registered is sort of redundant.  It is
set to `true` only in `dns_zone_rpz_enable_db()` right before the
`dns_rpz_dbupdate_callback()` callback is registered.  It is only
required in that callback and it is the only place that the callback
is registered.  Therefore there is no path that that `REQUIRE` can
fail.

The `db_registered` variable is only set to `false` in
`dns_rpz_new_zone`, so it is not like the variable is unset again
later.

The only other place where `db_registered` is checked is in
`rpz_detach()`.  If `true`, it will call
`dns_db_updatenotify_unregister()`.  However if that happens, the
`db_registered` is not set back to `false` thus this implies that
this may happen multiple times.  If called a second time, most
likely the unregister function will return `ISC_R_NOTFOUND`, but
the return value is not checked anyway.  So it can do without the
`db_registered` check.
2019-02-22 13:59:10 +01:00
Matthijs Mekking
2e5e429644 Add curly brackets on if statements 2019-02-22 13:59:10 +01:00
Matthijs Mekking
a490c09121 named crashes on shutdown after load rpz failed
This may happen when loading an RPZ failed and the code path skips
calling dns_db_endload().  The dns_rpz_zone_t object is still kept
marked as having registered db.  So when this object is finally
destroyed in rpz_detach(), this code will incorrectly call
`dns_db_updatenotify_unregister()`:

   if (rpz->db_registered)
     dns_db_updatenotify_unregister(rpz->db,
                                    dns_rpz_dbupdate_callback, rpz);

and trigger this assertion failure:

   REQUIRE(db != NULL);

To fix this, only call `dns_db_updatenotify_unregister()` when
`rpz->db` is not NULL.
2019-02-22 13:59:10 +01:00
Mark Andrews
8758d36a5e use client->query.qname 2019-02-22 00:04:52 -05:00
Evan Hunt
efb0d1e83d documentation changes setting up 9.15 development branch 2019-02-21 16:42:17 -08:00
Mark Andrews
a9307de85e denied axfr requests were not effective for writable DLZ zones 2019-02-20 19:44:38 -08:00
Mark Andrews
35025b6e88 silently ignore additional keytag options 2019-02-20 19:44:36 -08:00
Matthijs Mekking
f09352d20a Update keyfetch_done compute_tag check
If in keyfetch_done the compute_tag fails (because for example the
algorithm is not supported), don't crash, but instead ignore the
key.
2019-02-20 19:44:33 -08:00
Matthijs Mekking
235a64a5a4 Don't free key in compute_tag in case of failure
If `dns_dnssec_keyfromrdata` failed we don't need to call
`dst_key_free` because no `dstkey` was created.  Doing so
nevertheless will result in an assertion failure.

This can happen if the key uses an unsupported algorithm.
2019-02-20 19:44:32 -08:00
Mark Andrews
c0d4ff5796 teach proto_c to look in the source directory for out of tree builds 2019-02-20 09:27:00 +11:00
Mark Andrews
f475dc75b1 remove redundant assignment 2019-02-18 17:40:56 -05:00
Mark Andrews
9a9dc4072f declarations before assertions 2019-02-18 17:40:56 -05:00
Mark Andrews
63c03cdb2d remove seen_dname 2019-02-18 17:40:56 -05:00
Mark Andrews
4938f97c97 record when querytsig is valid 2019-02-18 17:39:08 -05:00
Mark Andrews
7114d16098 fix memory leak 2019-02-19 09:17:03 +11:00
Mark Andrews
f87b88e520 remove dead assignments 2019-02-19 08:12:09 +11:00
Mark Andrews
76a1c1531a assert result is ISC_R_SUCCESS 2019-02-19 07:57:14 +11:00
Matthijs Mekking
24507abee3 Update to !1427: Make primary's transfer log more detailed 2019-02-18 06:33:15 -05:00
Michał Kępień
72c201733c Do not check SEP bit for mirror zone trust anchors
When a mirror zone is verified, the 'ignore_kskflag' argument passed to
dns_zoneverify_dnssec() is set to false.  This means that in order for
its verification to succeed, a mirror zone needs to have at least one
key with the SEP bit set configured as a trust anchor.  This brings no
security benefit and prevents zones signed only using keys without the
SEP bit set from being mirrored, so change the value of the
'ignore_kskflag' argument passed to dns_zoneverify_dnssec() to true.
2019-02-14 11:03:35 +01:00
Michał Kępień
9c611dd999 Prevent races when waiting for log messages
The "mirror" system test checks whether log messages announcing a mirror
zone coming into effect are emitted properly.  However, the helper
functions responsible for waiting for zone transfers and zone loading to
complete do not wait for these exact log messages, but rather for other
ones preceding them, which introduces a possibility of false positives.

This problem cannot be addressed by just changing the log message to
look for because the test still needs to discern between transferring a
zone and loading a zone.

Add two new log messages at debug level 99 (which is what named
instances used in system tests are configured with) that are to be
emitted after the log messages announcing a mirror zone coming into
effect.  Tweak the aforementioned helper functions to only return once
the log messages they originally looked for are followed by the newly
added log messages.  This reliably prevents races when looking for
"mirror zone is now in use" log messages and also enables a workaround
previously put into place in the "mirror" system test to be reverted.
2019-02-14 10:41:56 +01:00
Michał Kępień
2e4187afd5 Add a comment explaining a mirror zone glitch
Explain why in a certain edge case mirror zone data may not be used for
resolution purposes despite being available.
2019-02-08 05:49:22 -05:00
Mark Andrews
a9fadafecd fix AMTRELAY name 2019-02-08 13:54:13 +11:00
Mark Andrews
8d69e15988 add top of range checks 2019-02-08 09:37:00 +11:00
Evan Hunt
3183663dd4 Add support for ZONEMD 2019-02-07 12:34:14 -08:00
Mark Andrews
66922ee7af Add support for ATMRELAY 2019-02-07 10:28:19 -08:00
Tinderbox User
b4d3f78293 prep 9.13.6 2019-02-06 22:13:05 +00:00
Matthijs Mekking
2c34023a5e Explain hook action calling order in more detail 2019-02-06 10:09:38 +01:00
Tony Finch
2e173bbd24 cleanup: allow building DS directly from CDNSKEY
Relax an assertion in lib/dns/ds.c so that dnssec-cds does
not have to work around it. This will also be useful for
dnssec-dsfromkey.
2019-02-05 22:57:13 -05:00
Evan Hunt
2f13524164 initalize a named_g_defaultbindkeys variable 2019-02-06 13:18:00 +11:00
Michał Kępień
7f52b87227 Maintain and report outgoing transfer statistics
Transfer statistics are currently only reported for incoming transfers,
even though they are equally useful for outgoing transfers.  Define a
separate structure for keeping track of the number of messages, records,
and bytes sent during each outgoing transfer, along with the time each
outgoing transfer took.  Repurpose the 'nmsg' field of the xfrout_ctx_t
structure for tracking the number of messages actually sent, ensuring it
is only increased after isc_socket_send() indicates success.  Report the
statistics gathered when an outgoing transfer completes.
2019-01-31 16:55:01 -05:00
Michał Kępień
c20d81fd06 Track QUESTION section presence using a boolean
The 'nmsg' field of the xfrout_ctx_t structure is an integer, even
though it is only ever compared against 0 (for tracking whether the
QUESTION section has already been sent to the client).  Use a boolean
instead as it is more appropriate and also enables 'nmsg' to be
repurposed.
2019-01-31 16:55:01 -05:00
Evan Hunt
3c75d5d7c5 add more key maintenance event logging
log when a key is:
- published in the DNSKEY rrset
- activated
- deactivated
- unpublished from the DNSKEY rrset
- revoked
2019-01-31 12:18:55 -08:00
Evan Hunt
7fa6b88d9b include the name when logging that a key is being fetched from key repostitory 2019-01-31 12:18:19 -08:00
Evan Hunt
e3fe19df55 increase the log level for some key status and managed-key events
some key-related events were logged at DEBUG(3) but seem likely to
be relevant to a typical operator's interests during key rollovers.
2019-01-31 12:18:19 -08:00
Evan Hunt
a7cadde982 use log category "dnssec" instead of "zone" for DNSSEC-related events
use "dnssec" log category for:
- managed key zone events
- DNSSEC key status changes (activation, deletion, etc)
- zone signing status
2019-01-31 12:18:12 -08:00
Evan Hunt
308ab1b4a5 style cleanups 2019-01-31 11:57:16 -08:00
Evan Hunt
73ba24fb36 Change #4148 wasn't complete
- there was a memory leak when using negotiated TSIG keys.
- TKEY responses could only be signed when using a newly negotiated
  key; if an existent matching TSIG was found in in the keyring it
  would not be used.
2019-01-31 09:01:23 -08:00
Evan Hunt
ff3dace139 Ancient named.conf options are now a fatal configuration error
- options that were flagged as obsolete or not implemented in 9.0.0
  are now flagged as "ancient", and are a fatal error
- the ARM has been updated to remove these, along with other
  obsolete descriptions of BIND 8 behavior
- the log message for obsolete options explicitly recommends removal
2019-01-31 11:54:26 +01:00
Ondřej Surý
3a3e75042d Remove support for compiling without assertions (Both ISC_CHECK_ALL, ISC_CHECK_NONE are now gone) 2019-01-31 11:16:08 +01:00
Matthijs Mekking
a2d115cbfc Add tests for dumpdb stale ttl
This adds a test for rndc dumpdb to ensure the correct "stale
comment" is printed.  It also adds a test for non-stale data to
ensure no "stale comment" is printed for active RRsets.

In addition, the serve-stale tests are hardened with more accurate
grep calls.
2019-01-31 09:35:49 +01:00
Matthijs Mekking
924ebc605d Print in dump-file stale ttl
This change makes rndc dumpdb correctly print the "; stale" line.
It also provides extra information on how long this data may still
be served to clients (in other words how long the stale RRset may
still be used).
2019-01-30 14:11:12 -08:00
Matthijs Mekking
b05a095a3e Harden checks 2019-01-30 11:46:43 -08:00
Evan Hunt
13c799267b remove the 'new_tsigkey' exception, allow TSIG to be set any time
this allows 'dns_message_settsigkey()' to be run any time after
parsing without having to set a special flag in the message object.
2019-01-30 11:46:11 -08:00
Evan Hunt
33ec311332 allow TSIG key to be added to message structure after parsing
up until now, message->tsigkey could only be set during parsing
of the request, but gss-tsig allows one to be created afterward.

this commit adds a new flag to the message structure, `new_tsigkey`,
which indicates that in this case it's okay for `dns_message_settsigkey()`
to be run on a message after parsing, without hitting any assertions due
to the lack of a TSIG in the request. this allows us to keep the current
restriction in place generally, but add an exception for TKEY processing.
it's probably better to just remove the restriction entirely (see next
commit).
2019-01-30 11:46:11 -08:00
Matthijs Mekking
1302dea184 Some thoughts on a solution 2019-01-30 11:45:30 -08:00
Ondřej Surý
27eb6189a8 Fix Centos 6 build by explicitly casting to __typeof__(obj) in atomic_compare_exchange_strong shim function 2019-01-30 15:54:17 +01:00
Witold Kręcicki
9ded5d5193 Cast atomic_load_explicit to proper size 2019-01-30 14:12:06 +01:00
Ondřej Surý
f2d1a88efc Add #pragma intrinsic for intrinsic Windows functions 2019-01-30 13:48:58 +01:00
Ondřej Surý
9539e1c3a1 Fix memory_order_cst_seq -> memory_order_seq_cst typo 2019-01-30 13:48:58 +01:00
Ondřej Surý
d3e0604354 Properly use atomic_compare_exchange instead of load/store 2019-01-30 13:48:58 +01:00
Ondřej Surý
4f5e83b139 Add define for InterlockedExchangeAdd8 intrinsic 2019-01-30 13:48:58 +01:00
Ondřej Surý
7a7a8b0f7b Add atomic_bool implementation to unix and win32 stdatomic.h shim headers 2019-01-30 09:37:38 +01:00
Ondřej Surý
a84e70acd0 Fix copy&paste error in the atomic_fetch_add_explicit{32,64} macros.
- InterlockedExchange was incorrectly used in place where InterlockedExchangeAdd
  should have been used
2019-01-30 09:37:38 +01:00
Evan Hunt
19dd6a409c Fix a typo in the win32 version of the atomic_store macro 2019-01-30 09:37:38 +01:00
Evan Hunt
39527e9c36 Moved the unix version to lib/isc/unix/include/isc so it's more obvious in the future that it isn't the only copy 2019-01-30 09:37:38 +01:00
Witold Kręcicki
a003908af4 Fix a race in access to manager->tasks in taskmgr
Make taskmgr->mode and boolean state flags (exclusive, paused, exiting) atomic.
2019-01-29 03:32:29 -05:00
Evan Hunt
995134ce76 rename struct members to avoid a name collision on BSD 2019-01-28 10:59:48 -08:00
Witold Kręcicki
42d9a536a7 Make isc_counter use atomics instead of locks 2019-01-25 04:26:49 -05:00
Witold Kręcicki
0af500a2c5 - Make isc_quota use atomics instead of locks
- Use getters for isc_quota parameters, make fields private
- Fix a potential data race with recursion clients limits logging
2019-01-25 04:26:49 -05:00
Witold Kręcicki
814bfa23b2 Add atomic_store_relaxed and atomic_load_relaxed macros to isc/atomic.h, fix issues in isc/stdatomic.h 2019-01-25 04:26:49 -05:00
Evan Hunt
cf072d659e cleanup cfg_parse_buffer* functions
cfg_parse_buffer() now has the same signature as the former
cfg_parse_buffer4(). cfg_parse_buffer{2,3,4}() have been removed.
2019-01-24 12:08:54 -08:00
Matthijs Mekking
7c13f1779e Remove dead code 2019-01-24 12:00:09 -08:00
Evan Hunt
c29abd307c set the magic number at the end of dns_dt_create() 2019-01-23 14:12:09 -05:00
Evan Hunt
6c478a3dae removed a debugging fprintf 2019-01-20 17:38:32 -08:00
Witold Kręcicki
b49310ac06 If possible don't use forwarders when priming the resolver.
If we try to fetch a record from cache and need to look into
hints database we assume that the resolver is not primed and
start dns_resolver_prime(). Priming query is supposed to return
NSes for "." in ANSWER section and glue records for them in
ADDITIONAL section, so that we can fill that info in 'regular'
cache and not use hints db anymore.
However, if we're using a forwarder the priming query goes through
it, and if it's configured to return minimal answers we won't get
the addresses of root servers in ADDITIONAL section. Since the
only records for root servers we have are in hints database we'll
try to prime the resolver with every single query.

This patch adds a DNS_FETCHOPT_NOFORWARD flag which avoids using
forwarders if possible (that is if we have forward-first policy).
Using this flag on priming fetch fixes the problem as we get the
proper glue. With forward-only policy the problem is non-existent,
as we'll never ask for root server addresses because we'll never
have a need to query them.

Also added a test to confirm priming queries are not forwarded.
2019-01-16 17:41:13 -05:00
Petr Menšík
fe9ef0d9f5 Make sure null atributes are never used
Add INSIST to pubattr fetching where null might occur in therory. Make
sure null is never dereferenced.
2019-01-16 15:48:37 -05:00
Witold Kręcicki
cfa2804e5a When a forwarder fails and we're not in a forward-only mode we
go back to regular resolution. When this happens the fetch timer is
already running, and we might end up in a situation where we we create
a fetch for qname-minimized query and after that the timer is triggered
and the query is retried (fctx_try) - which causes relaunching of
qname-minimization fetch - and since we already have a qmin fetch
for this fctx - assertion failure.

This fix stops the timer when doing qname minimization - qmin fetch
internal timer should take care of all the possible timeouts.
2019-01-16 11:09:30 -08:00
Michał Kępień
7d6b8f7c12 Log a message when a mirror zone becomes unusable
Log a message if a mirror zone becomes unusable for the resolver (most
usually due to the zone's expiration timer firing).  Ensure that
verification failures do not cause a mirror zone to be unloaded
(instead, its last successfully verified version should be served if it
is available).
2019-01-16 10:38:12 -08:00
Michał Kępień
7665e13206 Log a message when a mirror zone loaded from disk comes into effect
Log a message when a mirror zone is successfully loaded from disk and
subsequently verified.

This could have been implemented in a simpler manner, e.g. by modifying
an earlier code branch inside zone_postload() which checks whether the
zone already has a database attached and calls attachdb() if it does
not, but that would cause the resulting logs to indicate that a mirror
zone comes into effect before the "loaded serial ..." message is logged,
which would be confusing.

Tweak some existing sed commands used in the "mirror" system test to
ensure that separate test cases comprising it do not break each other.
2019-01-16 10:34:15 -08:00
Michał Kępień
1c97ace7dc Log a message when a transferred mirror zone comes into effect
Log a message when a mirror zone is successfully transferred and
verified, but only if no database for that zone was yet loaded at the
time the transfer was initiated.

This could have been implemented in a simpler manner, e.g. by modifying
zone_replacedb(), but (due to the calling order of the functions
involved in finalizing a zone transfer) that would cause the resulting
logs to suggest that a mirror zone comes into effect before its transfer
is finished, which would be confusing given the nature of mirror zones
and the fact that no message is logged upon successful mirror zone
verification.

Once the dns_zone_replacedb() call in axfr_finalize() is made, it
becomes impossible to determine whether the transferred zone had a
database attached before the transfer was started.  Thus, that check is
instead performed when the transfer context is first created and the
result of this check is passed around in a field of the transfer context
structure.  If it turns out to be desired, the relevant log message is
then emitted just before the transfer context is freed.

Taking this approach means that the log message added by this commit is
not timed precisely, i.e. mirror zone data may be used before this
message is logged.  However, that can only be fixed by logging the
message inside zone_replacedb(), which causes arguably more dire issues
discussed above.

dns_zone_isloaded() is not used to double-check that transferred zone
data was correctly loaded since the 'shutdown_result' field of the zone
transfer context will not be set to ISC_R_SUCCESS unless axfr_finalize()
succeeds (and that in turn will not happen unless dns_zone_replacedb()
succeeds).
2019-01-16 10:33:02 -08:00
Evan Hunt
adcc16f2d7 error on allow-update and allow-update-forwarding at options/view level 2019-01-15 23:20:38 -08:00
Mark Andrews
2be55f5c05 use smt_pause instead of pause on sparc 2019-01-15 20:29:27 -05:00
Mark Andrews
dadb924be7 adjust timeout to allow for ECN negotiation failures 2019-01-15 17:10:41 -08:00
Mark Andrews
ac01359871 ensure that WSAStartup is called before getservbyname 2019-01-15 14:19:59 +11:00
Ondřej Surý
482dd7eed3 Fix race condition in cleanup part of dns_dt_create() 2019-01-14 11:28:47 +01:00
Mark Andrews
bd529b1f30 silence coverity issues; move isc_refcount_decrement out of INSIST 2019-01-10 14:42:28 +11:00
Ondřej Surý
e2cdf066ea Remove message catalogs 2019-01-09 23:44:26 +01:00
Mark Andrews
ca977e3976 update refreshkeytime 2019-01-09 19:27:40 +11:00
Mark Andrews
ee23780246 maybe_numeric failed to handle NUL in text region. 2019-01-09 18:33:42 +11:00
Mark Andrews
5e8b772ad1 Ensure base64/base32/hex fields in DNS records that should be non-empty are. 2019-01-09 18:04:21 +11:00
Mark Andrews
604889e627 allow for up 100 records or 64K of data to be in a ncache entry 2019-01-09 15:53:32 +11:00
Mark Andrews
0c42a9c0ab explictly convert ISC_R_NOSPACE from dns_message_parse to DNS_R_FORMERR and remove from dns_result_torcode 2019-01-09 15:19:42 +11:00
Michał Kępień
33350626f9 Track forwarder timeouts in fetch contexts
Since following a delegation resets most fetch context state, address
marks (FCTX_ADDRINFO_MARK) set inside lib/dns/resolver.c are not
preserved when a delegation is followed.  This is fine for full
recursive resolution but when named is configured with "forward first;"
and one of the specified forwarders times out, triggering a fallback to
full recursive resolution, that forwarder should no longer be consulted
at each delegation point subsequently reached within a given fetch
context.

Add a new badnstype_t enum value, badns_forwarder, and use it to mark a
forwarder as bad when it times out in a "forward first;" configuration.
Since the bad server list is not cleaned when a fetch context follows a
delegation, this prevents a forwarder from being queried again after
falling back to full recursive resolution.  Yet, as each fetch context
maintains its own list of bad servers, this change does not cause a
forwarder timeout to prevent that forwarder from being used by other
fetch contexts.
2019-01-08 08:29:54 +01:00
Mark Andrews
b75970efa3 named-checkconf triggered a assertion when a mirror zone had a bad name 2018-12-20 13:19:18 +11:00
Ondřej Surý
ff7c868f25 __SANITIZE_ADDRESS__ needs to be defined to 1 2018-12-19 22:02:37 +01:00
Ondřej Surý
272c065268 Add emacs .dir-locals.el settings for flycheck mode 2018-12-19 17:03:37 +01:00
Matthijs Mekking
5ca649967e Move REQUIRE outside comment unsupported alg 2018-12-19 12:54:57 +01:00
Matthijs Mekking
1dd11fc754 Allow unsupported alg in zone /w dnssec-signzone
dnssec-signzone should sign a zonefile that contains a DNSKEY record
with an unsupported algorithm.  Current behavior is that it will
fail, hitting a fatal error.  The fix detects unsupported algorithms
and will not try to add it to the keylist.

Also when determining the maximum iterations for NSEC3, don't take
into account DNSKEY records in the zonefile with an unsupported
algorithm.
2018-12-19 12:54:31 +01:00
Ondřej Surý
8903d68d69 gcc defines __SANITIZE_ADDRESS__ and not __ADDRESS_SANITIZER__, use the correct #define 2018-12-19 12:24:59 +01:00
Ondřej Surý
cad6b39cab Disable RTLD_DEEPBIND when compiled under AddressSanitizer 2018-12-19 09:59:40 +01:00
Ondřej Surý
e1ce3a3d42 Define __ADDRESS_SANITIZER__ if compiling under clang's AddressSanitizer 2018-12-19 09:54:37 +01:00
Evan Hunt
de13354caf only the debug build was fixed previously; release needs fixing too 2018-12-17 17:10:33 -05:00
Mark Andrews
53a33f7365 pass the correct object to cfg_obj_log 2018-12-14 16:29:02 +11:00
Mark Andrews
f2f7711977 add unit tests for dns_rdatatype_atcname, dns_rdatatype_atparent and iszonecutauth 2018-12-14 13:21:35 +11:00
Mark Andrews
f4ceb12b69 create dns_rdatatype_atcname to split records that can appear along side CNAME from DNSSEC; dns_rdatatype_iszonecutauth allowed too many types 2018-12-14 12:48:55 +11:00
Ondřej Surý
a2e38f758d Add lib/dns/tests/testdata/dnstap/dnstap.file to .gitignore 2018-12-11 11:32:24 +01:00
Ondřej Surý
e69dc0dbc7 Remove RSAMD5 support 2018-12-11 11:32:24 +01:00
Mark Andrews
b108376a10 log a error if we don't explicitly know that a error has been logged in zone_sign 2018-12-10 14:57:11 +11:00
Evan Hunt
c6527aedc7 fix win32 build
- add missing hooks.h and hooks.c to project files
- remove extraneous symbols from libns.def
2018-12-07 10:12:00 -08:00
Tinderbox User
5bd855251c prep 9.13.5 2018-12-07 03:41:19 +00:00
Evan Hunt
ab7356a7de checklibs needs to grep for the cfg_* prefix in lib/isccfg 2018-12-06 21:05:55 -05:00
Mark Andrews
b2aca96c27 move geoip to parser.c 2018-12-07 12:50:03 +11:00
Mark Andrews
9eec02a81f Properly detect bottom of zone when sign_a_node() is not called 2018-12-07 11:20:16 +11:00
Michał Kępień
0e12988dd6 make hook actions return an enum instead of a bool
Use an enum instead of a bool for the return type of hook actions in
order to facilitate adding further hook processing models in the future.
2018-12-06 10:36:50 -08:00
Evan Hunt
f70a84537d revise hooks.h comments 2018-12-06 10:36:50 -08:00
Michał Kępień
4234968798 add a function for processing a list of configured plugins
Add a new libisccfg function, cfg_pluginlist_foreach(), which allows an
arbitrary callback to be invoked for every "plugin" stanza present in a
configuration object.  Use this function for both loading plugins and
checking their configuration in order to reduce duplication of
configuration processing code present in bin/named/server.c and
lib/bind9/check.c.
2018-12-06 10:36:50 -08:00
Evan Hunt
fd20f10d52 name change from "hook modules" to "plugins"
- "hook" is now used only for hook points and hook actions
- the "hook" statement in named.conf is now "plugin"
- ns_module and ns_modlist are now ns_plugin and ns_plugins
- ns_module_load is renamed ns_plugin_register
- the mandatory functions in plugin modules (hook_register,
  hook_check, hook_version, hook_destroy) have been renamed
2018-12-06 10:36:50 -08:00
Evan Hunt
8da0c0e7d5 eliminate ns_hookctx structure, pass mctx/lctx/view directly 2018-12-06 10:36:44 -08:00
Evan Hunt
7a47e4d85f restore filter-aaaa syntax checking
- added functionality to check hook parameters in named-checkconf,
  and restored the checkconf tests that were removed from the
  filter-aaaa test.
2018-12-06 10:29:12 -08:00
Evan Hunt
b94945e606 refactor to support multiple module instances
- use a per-view module list instead of global hook_modules
- create an 'instance' pointer when registering modules, store it in
  the module structure, and use it as action_data when calling
  hook functions - this enables multiple module instances to be set
  up in parallel
- also some nomenclature changes and cleanup
2018-12-06 10:29:12 -08:00
Evan Hunt
9df0bdc99c add additional hook points, plus some minor refactoring
- added some hook points that will be needed for a dns64 module later
- moved some code from the beginning of query_respond() to
  the end of query_prepresponse(); this has no effect on functionality
  but means we can have a hook point at the top of query_respond(),
  which seems nicer
- compressed duplicated code into query_zerottl_refetch() function
- added a qctx->answered flag so that a module can prevent
  query_addrrset() from being called from query_respond() when
  it's already been called from the module.
2018-12-06 10:29:12 -08:00
Evan Hunt
0b988256c7 copy ns_hook objects before adding them to a hook table
- this is necessary because adding the same hook to multiple views
  causes the ISC_LIST link value to become inconsistent; it isn't
  noticeable when only one hook action is ever registered at a
  given hook point, but it will break things when there are two.
2018-12-06 10:29:12 -08:00
Evan Hunt
74683fbc3b use entirely local persistent data in modules
- eliminate qctx->hookdata and client->hookflags.
- use a memory pool to allocate data blobs in the filter-aaaa module,
  and associate them with the client address in a hash table
- instead of detaching the client in query_done(), mark it for deletion
  and then call ns_client_detach() from qctx_destroy(); this ensures
  that it will still exist when the QCTX_DESTROYED hook point is
  reached.
2018-12-06 10:29:12 -08:00
Evan Hunt
8725f57371 refactor to remove dead code in query_respond_any() 2018-12-06 10:29:12 -08:00
Evan Hunt
427e9ca357 clear AD flag when altering response messages
- the AD flag was not being cleared correctly when filtering
- enabled dnssec valdiation in the filter-aaaa test to confirm this
  works correctly now
2018-12-06 10:29:11 -08:00
Evan Hunt
055bf2665c improve hook processing macros
- use a get_hooktab() function to determine the hook table.
- PROCESS_HOOK now jumps to a cleanup tag on failure
- add PROCESS_ALL_HOOKS in query.c, to run all hook functions at
  a specified hook point without stopping. this is to be used for
  intiialization and destruction functions that must run in every
  module.
- 'result' is set in PROCESS_HOOK only when a hook function
  interrupts processing.
- revised terminology: a "callback" is now a "hook action"
- remove unused NS_PROCESS_HOOK and NS_PROCESS_HOOK_VOID macros.
2018-12-06 10:29:11 -08:00
Evan Hunt
81f58e2ea2 enable modules to store data in qctx
- added a 'hookdata' array to qctx to store pointers to up to
  16 blobs of data which are allocated by modules as needed.
  each module is assigned an ID number as it's loaded, and this
  is the index into the hook data array. this is to be used for
  holding persistent state between calls to a hook module for a
  specific query.
- instead of using qctx->filter_aaaa, we now use qctx->hookdata.
  (this was the last piece of filter-aaaa specific code outside the
  module.)
- added hook points for qctx initialization and destruction. we get
  a filter-aaaa data pointer from the mempool when initializing and
  store it in the qctx->hookdata table; return to to the mempool
  when destroying the qctx.
- link the view to the qctx so that detaching the client doesn't cause
  hooks to fail
- added a qctx_destroy() function which must be called after qctx_init;
  this calls the QCTX_DESTROY hook and detaches the view
- general cleanup and comments
2018-12-06 10:29:11 -08:00
Evan Hunt
9911c835d3 add a parser to filter-aaaa.so and pass in the parameters
- make some cfg-parsing functions global so they can be run
  from filter-aaaa.so
- add filter-aaaa options to the hook module's parser
- mark filter-aaaa options in named.conf as obsolete, remove
  from named and checkconf, and update the filter-aaaa test not to
  use checkconf anymore
- remove filter-aaaa-related struct members from dns_view
2018-12-06 10:29:11 -08:00
Evan Hunt
d2f4644388 add hook statement to configuration parser
- allow multiple "hook" statements at global or view level
- add "optional bracketed text" type for optional parameter list
- load hook module from specified path rather than hardcoded path
- add a hooktable pointer (and a callback for freeing it) to the
  view structure
- change the hooktable functions so they no longer update ns__hook_table
  by default, and modify PROCESS_HOOK so it uses the view hooktable, if
  set, rather than ns__hook_table. (ns__hook_table is retained for
  use by unit tests.)
- update the filter-aaaa system test to load filter-aaaa.so
- add a prereq script to check for dlopen support before running
  the filter-aaaa system test

not yet done:
- configuration parameters are not being passed to the filter-aaaa
  module; the filter-aaaa ACL and filter-aaaa-on-{v4,v6} settings are
  still stored in dns_view
2018-12-06 10:29:11 -08:00
Evan Hunt
e2ac439e28 move filter-aaaa.so build from lib/ns to bin/hooks 2018-12-06 10:29:11 -08:00
Evan Hunt
d3f0f71b6b initial implementation of filter-aaaa.so as a shared object
- temporary kluge! in this version, for testing purposes,
  named always searches for a filter-aaaa module at /tmp/filter-aaaa.so.
  this enables the filter-aaaa system test to run even though the
  code to configure hooks in named.conf hasn't been written yet.
- filter-aaaa-on-v4, filter-aaaa-on-v6 and the filter-aaaa ACL are
  still configured in the view as they were before, not in the hook.
2018-12-06 10:29:10 -08:00
Evan Hunt
e4f0a98b4d move several query.c helper functions to client.c and rename
- these formerly static helper functions have been moved into client.c
  and made external so that they can be used in hook modules as well as
  internally in libns: query_newrdataset, query_putrdataset,
  query_newnamebuf, query_newname, query_getnamebuf, query_keepname,
  query_releasename, query_newdbversion, query_findversion
- made query_recurse() and query_done() into public functions
  ns_query_recurse() and ns_query_done() so they can be called from
  modules.
2018-12-06 10:29:10 -08:00
Evan Hunt
0d7ab9bafc move filter-aaaa implementation into hook functions directly 2018-12-06 10:29:10 -08:00
Evan Hunt
d43dcef139 refactor filter-aaaa implementation
- the goal of this change is for AAAA filtering to be fully contained
   in the query logic, and implemented at discrete points that can be
   replaced with hook callouts later on.
 - the new code may be slightly less efficient than the old filter-aaaa
   implementation, but maximum efficiency was never a priority for AAAA
   filtering anyway.
 - we now use the rdataset RENDERED attribute to indicate that an AAAA
   rdataset should not be included when rendering the message. (this
   flag was originally meant to indicate that an rdataset has already
   been rendered and should not be repeated, but it can also be used to
   prevent rendering in the first place.)
 - the DNS_MESSAGERENDER_FILTER_AAAA, NS_CLIENTATTR_FILTER_AAAA,
   and DNS_RDATASETGLUE_FILTERAAAA flags are all now unnecessary and
   have been removed.
2018-12-06 10:29:10 -08:00
Evan Hunt
29897b14dc refactor query.c to make qctx more accessible
- the purpose of this change is allow for more well-defined hook points
  to be available in the query processing logic. some functions that
  formerly didn't have access to 'qctx' do now; this is needed because
  'qctx' is what gets passed when calling a hook function.
- query_addrdataset() has been broken up into three separate functions
  since it used to do three unrelated things, and what was formerly
  query_addadditional() has been renamed query_additional_cb() for
  clarity.
- client->filter_aaaa is now qctx->filter_aaaa. (later, it will be moved
  into opaque storage in the qctx, for use by the filter-aaaa module.)
- cleaned up style and braces
2018-12-06 10:29:10 -08:00
Evan Hunt
70cc3f803e set up hooks.c to enable setting hook points and loading modules
- move hooks.h to public include directory
- ns_hooktable_init() initializes a hook table. if NULL is passed in, it
  initializes the global hook table
- ns_hooktable_save() saves a pointer to the current global hook table.
- ns_hooktable_reset() replaces the global hook table with different
  one
- ns_hook_add() adds hooks at specified hook points in a hook table (or
  the global hook table if the specified table is NULL)
- load and unload functions support dlopen() of hook modules (this is
  adapted from dyndb and not yet functional)
- began adding new hook points to query.c
2018-12-06 10:29:05 -08:00
Ondřej Surý
953a957dfa Just #define isc_refcount_increment0() to isc_refcount_increment() 2018-12-05 14:16:41 +01:00
Ondřej Surý
8537adef4c The isc_refcount_decrement must use memory_order_release and isc_refcount_destroy must run thread barrier with memory_order_require 2018-12-05 14:11:53 +01:00
Witold Kręcicki
ddc1d4d6d4 Fix a race between process_fd and socketclose in unix socket code. [GL #744] 2018-12-05 12:03:52 +00:00
Ondřej Surý
ef87b1e60b Don't check the memory leaks in the libdns tests as they hide the cmocka assertion failures 2018-12-04 09:00:42 +01:00
Mark Andrews
5744415a75 only test for prefixlen <= 63 2018-12-03 16:26:54 +11:00
Ondřej Surý
d13cabd27e fixup! When compiling for fuzzing, ensure the pseudo random number seed is non-zero. 2018-11-30 11:21:55 +00:00
Stephen Morris
77032a4e29 When compiling for fuzzing, ensure the pseudo random number seed is non-zero. 2018-11-30 11:21:55 +00:00
Mark Andrews
a487473fc5 add missing DBC checks for catz and add isc_magic checks; add DBC checks to ht.c 2018-11-29 12:39:20 +11:00
Evan Hunt
b99af25d0f silence compiler warning 2018-11-28 12:00:16 -05:00
Mark Andrews
0708e43d3f update zname with the current zone anme 2018-11-28 15:59:30 +11:00
Ondřej Surý
a688a43faf Move the CMocka include directories from CFLAGS to CINCLUDES where it belongs to not get overriden later by the default CFLAGS rule 2018-11-26 16:16:34 +01:00
Michał Kępień
62ca7743ae Fix compilation on CentOS 6 (i386)
The stock toolchain available on CentOS 6 for i386 is unable to use the
_mm_pause() intrinsic.  Fix by using "rep; nop" assembly instructions on
that platform instead.
2018-11-26 10:57:14 +01:00
Ondřej Surý
e24afa3088 Fix typo __LINE -> __LINE__ 2018-11-24 00:53:24 +01:00
Witold Kręcicki
d5793ecca2 - isc_task_create_bound - create a task bound to specific task queue
If we know that we'll have a task pool doing specific thing it's better
  to use this knowledge and bind tasks to task queues, this behaves better
  than randomly choosing the task queue.

- use bound resolver tasks - we have a pool of tasks doing resolutions,
  we can spread the load evenly using isc_task_create_bound

- quantum set universally to 25
2018-11-23 04:34:02 -05:00
Mark Andrews
509dad8737 handle systems without IPv4 2018-11-23 12:05:53 +11:00
Mark Andrews
6696a40ea9 address resource leak; don't call close() on socket error; 2018-11-23 10:34:59 +11:00
Mark Andrews
2156a5b610 address coverity side effect in assert warning 2018-11-22 17:57:54 -05:00
Ondřej Surý
d1a8a3faed Memory allocations must be fatal even when default_memalloc is not used 2018-11-22 16:46:57 +01:00
Ondřej Surý
2fa857d502 Cleanup lib/isc/mem.c after failed allocations made fatal 2018-11-22 16:46:56 +01:00
Ondřej Surý
3987a146be Remove isc_mem_{set,get}quota unused functions 2018-11-22 16:46:56 +01:00
Håvard Eidnes
f6c4ed94e4 Fix the build on NetBSD due to the differences in pthread implementation.
Signed-off-by: Ondřej Surý <ondrej@sury.org>
2018-11-22 09:43:43 -05:00
Ondřej Surý
2271e77d99 Add couple more ISC_UNREACHABLE(); found thanks to coccinelle 2018-11-22 09:28:00 -05:00
Witold Kręcicki
929ea7c2c4 - Make isc_mutex_destroy return void
- Make isc_mutexblock_init/destroy return void
- Minor cleanups
2018-11-22 11:52:08 +00:00
Ondřej Surý
d940e95206 isc_quota_init now returns 'void' 2018-11-22 11:52:08 +00:00
Ondřej Surý
2f3eee5a4f isc_mutex_init returns 'void' 2018-11-22 11:51:49 +00:00
Ondřej Surý
73a8999d1c isc_condition_init returns 'void' 2018-11-22 11:51:49 +00:00
Witold Kręcicki
0bed9bfc28 isc_mutex_init and isc_condition_init failures are now fatal 2018-11-22 11:51:49 +00:00
Tinderbox User
db1cd0d970 prep 9.13.4 2018-11-22 00:20:22 +00:00
Ondřej Surý
6b65a4f86e Fix typo ISC_SHA256_DIGESTLENGHT -> ISC_SHA256_DIGESTLENGTH 2018-11-21 23:34:44 +01:00
Witold Kręcicki
5f81aa10bc Use proper casting in socket unit test 2018-11-19 17:40:34 +01:00
Ondřej Surý
175f06949f Use strlcpy in place where strncpy(s, ...) + s[sizeof(s)-1] = \0; was used 2018-11-19 07:58:48 +01:00
Ondřej Surý
7a3eb391fa Fix memory leak in lex_test.c 2018-11-19 07:47:05 +01:00
Evan Hunt
8f15219f36 remove (or hide behind a 'verbose' flag) extra output from system tests 2018-11-16 20:46:14 +00:00
Mark Andrews
1ca5920113 2018-11-16 12:24:18 +11:00
Mark Andrews
474fbe88bf add missing tasks argument 2018-11-16 11:51:05 +11:00
Evan Hunt
c2a274cc5d silence "unused return value" warning 2018-11-15 12:54:11 -08:00
Ondřej Surý
8de2451756 Abort on memory allocation failure 2018-11-15 17:24:08 +01:00
Ondřej Surý
de219b8555 Remove embedded atf-src and enforce atf >= 0.20 + kyua as execution engine 2018-11-15 16:28:20 +01:00
Witold Kręcicki
79afbe2966 Some comments 2018-11-15 08:21:40 +00:00
Witold Kręcicki
16d329d55b Work with assumption that isc_mem_get always succeds; Crash if isc_thread_create, isc_mutex_init or isc_condition_init fails 2018-11-15 08:21:40 +00:00
Evan Hunt
1f0cd6606e style: one-line statement braces, line length, etc 2018-11-15 08:21:40 +00:00
Witold Krecicki
e55bbec66e FreeBSD fixes - proper affinity setting, don't use SO_REUSEPORT 2018-11-15 08:21:17 +00:00
Witold Krecicki
3f7d79e574 Don't doublelock fdlock on Solaris 2018-11-15 08:21:17 +00:00
Witold Kręcicki
ca7b5ceee5 Synchronize Windows socket code with API changes. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
c1a4f0e66a Use multiple worker queues (using isc_task_sendto()) in unix socket code 2018-11-15 08:21:17 +00:00
Witold Kręcicki
559ce1e330 use REUSEPORT only for NOLISTEN dispatchers 2018-11-15 08:21:17 +00:00
Witold Kręcicki
b2b210d6d9 Make watching/unwatching sockets saner. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
d652551e86 Use the newly accepted FD in TCP code. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
88edf8fe4d Use isc_refcount_t in socket reference counting. 2018-11-15 08:21:17 +00:00
Witold Krecicki
7223790380 Multiple network event loop threads support for Solarises /dev/poll. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
9c926a5d9b Mangle fdlocks a bit.
Mutexes are slower if they're in the same cache line. Since
fd's come in herds, and usually our listen sockets will have nearby
fd numbers, we mangle fdlocks so that the locks are further away.
2018-11-15 08:21:17 +00:00
Witold Kręcicki
58d75d9d8d Fix a race between socket closing and incoming event. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
f94f4bc1f4 Set network threads CPU affintity. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
bd024eee57 Add runtime detection of SO_REUSEPORT, use it instead of dup() if available. 2018-11-15 08:21:17 +00:00
Witold Krecicki
6feb688f69 Use multiple network event loop threads with separate data structures. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
cbc1b12311 Do IO after event directly in the network thread, don't queue an event in a separate task. 2018-11-15 08:21:17 +00:00
Witold Kręcicki
778ab8158a Remove fdwatch sockets, those are not used anywhere. 2018-11-15 08:21:17 +00:00
Evan Hunt
8c4d50c6bc remove ATF source code and Atffiles 2018-11-14 20:17:04 -08:00
Joey
336d5a5374 convert update_test; remove ATF from lib/dns/tests 2018-11-14 20:17:04 -08:00
Joey
92a3762cb6 convert tsig_test 2018-11-14 20:17:04 -08:00
Joey
2c7e6947fa convert time_test 2018-11-14 20:17:04 -08:00
Joey
eda6281f98 convert sigs_test 2018-11-14 20:17:04 -08:00
Joey
b915cdbf0b convert rsa_test 2018-11-14 20:17:04 -08:00
Joey
2837a821e8 convert resolver_test 2018-11-14 20:17:04 -08:00
Joey
dfd90dbb82 convert rbt_serialize_test 2018-11-14 20:17:04 -08:00
Joey
1b48e710d5 convert name_test 2018-11-14 20:17:04 -08:00
Joey
4ba08bb119 convert master_test 2018-11-14 20:17:04 -08:00
Joey
e38901154d convert keytable_test 2018-11-14 20:17:04 -08:00
Joey
9a464ef869 convert private_test 2018-11-14 20:17:04 -08:00
Evan Hunt
98d5abb73c convert dbversion_test 2018-11-14 20:17:04 -08:00
Joey
ad923f82b1 convert dst_test 2018-11-14 20:17:04 -08:00
Joey
005e19ad3f convert db_test 2018-11-14 20:17:04 -08:00
Evan Hunt
8d347788b0 convert dispatch_test 2018-11-14 20:17:04 -08:00
Evan Hunt
01a193ff6c convert zonemgr_test 2018-11-14 20:17:04 -08:00
Evan Hunt
0a4f6122de convert zt_test 2018-11-14 20:17:04 -08:00
Evan Hunt
bb5ed5a4ac convert rdata_test
- also added code to dnstest.c to optionally suppress printing of errors
  from dns_rdata_fromtxt()
2018-11-14 20:17:04 -08:00
Evan Hunt
55465517c7 convert rbt_test 2018-11-14 20:17:04 -08:00
Evan Hunt
9f83d31e42 convert dnstap_test 2018-11-14 20:17:04 -08:00
Evan Hunt
06b4ff5fe2 convert geoip_test 2018-11-14 20:17:04 -08:00
Evan Hunt
015fda0bb4 convert nsec3_test 2018-11-14 20:17:04 -08:00
Evan Hunt
28121c248e convert rdatasetstats_test 2018-11-14 20:17:04 -08:00
Evan Hunt
79cd093cd7 convert dbiterator_test 2018-11-14 20:17:04 -08:00
Evan Hunt
6dfc868fba convert dbdiff_test 2018-11-14 20:17:04 -08:00
Evan Hunt
db5eece106 convert peer_test 2018-11-14 20:17:04 -08:00
Evan Hunt
cca16eccd7 convert rdataset_test 2018-11-14 20:17:04 -08:00
Evan Hunt
a33bca5d55 convert acl_test 2018-11-14 20:17:04 -08:00
Evan Hunt
dcf65c82ad convert dh_test 2018-11-14 20:17:04 -08:00
Joey
9eea00cd3c convert socket_test; remove ATF from lib/isc/tests 2018-11-14 20:17:04 -08:00
Evan Hunt
bd009b34a6 convert regex_test 2018-11-14 20:17:04 -08:00
Evan Hunt
6ad7acd787 convert random_test 2018-11-14 20:17:04 -08:00
Joey
683094e308 convert mem_test 2018-11-14 20:17:04 -08:00
Evan Hunt
20cef35ece convert timer_test 2018-11-14 20:17:04 -08:00
Evan Hunt
3e52987229 convert task_test 2018-11-14 20:17:04 -08:00
Joey
72f60bdd84 convert hash_test 2018-11-14 20:17:04 -08:00
Evan Hunt
c701f036ea convert ht_test 2018-11-14 20:17:04 -08:00
Evan Hunt
3bf9a1e567 convert time_test 2018-11-14 20:17:04 -08:00
Evan Hunt
c9ff174dce convert taskpool_test 2018-11-14 20:17:04 -08:00
Evan Hunt
4f84acb788 convert pool_test 2018-11-14 20:17:04 -08:00
Evan Hunt
231436039d convert sockaddr_test 2018-11-14 20:17:04 -08:00
Evan Hunt
7ab8c5b583 convert netaddr_test 2018-11-14 20:17:04 -08:00
Evan Hunt
5f377136be convert symtab_test 2018-11-14 20:17:04 -08:00
Evan Hunt
b3db0266cb convert queue_test 2018-11-14 20:17:04 -08:00
Evan Hunt
8161be27db convert file_test 2018-11-14 20:17:04 -08:00
Evan Hunt
4133fd86f1 convert lex_test 2018-11-14 20:17:04 -08:00
Evan Hunt
049a3a7c0e convert errno_test 2018-11-14 20:17:04 -08:00
Evan Hunt
c1c8d8846f convert safe_test 2018-11-14 20:17:04 -08:00
Evan Hunt
718ca3166c convert radix_test 2018-11-14 20:17:04 -08:00
Evan Hunt
cc6ab2416b convert heap_test 2018-11-14 20:17:04 -08:00
Evan Hunt
a7c308df9c convert parse_test 2018-11-14 20:17:04 -08:00
Evan Hunt
52b86f0abe convert counter_test 2018-11-14 20:17:04 -08:00
Evan Hunt
02a5db7631 convert buffer_test 2018-11-14 20:17:04 -08:00
Evan Hunt
dc88db015b convert aes_test 2018-11-14 20:17:04 -08:00
Evan Hunt
79ac715763 convert listenlist_test; remove ATF from lib/ns/tests 2018-11-14 20:17:04 -08:00
Evan Hunt
48dc2831d7 convert notify_test 2018-11-14 20:17:04 -08:00
Evan Hunt
318b340f5e convert query_test
- also fixed a bug in openssldh_link.c that turned up in the process
2018-11-14 20:17:04 -08:00
Evan Hunt
cec8c52cbe convert resconf_test; remove ATF from lib/irs/tests 2018-11-14 20:17:04 -08:00
Evan Hunt
7ec945bd41 convert parser_test; remove ATF from lib/isccfg/tests 2018-11-14 20:17:04 -08:00
Evan Hunt
d8766293ab assert if {isc,dns,ns}_test_begin() is called when a prior test is running 2018-11-14 20:17:04 -08:00
Evan Hunt
b434b0a4b6 remove .NOTPARALLEL so unit tests can build faster 2018-11-14 20:17:04 -08:00
Evan Hunt
2afd18a2ce add cmocka support to remaining unit test makefiles
- also cleaned up some existing test code
2018-11-14 20:17:04 -08:00
Evan Hunt
f456e64736 set HAVE_CMOCKA correctly when using --with-cmocka=yes
(note: this is still broken if using --with-cmocka=path)
2018-11-14 20:17:04 -08:00
Ondřej Surý
c38b145b89 Remove OPENSSL_cleanup() call as we cannot recover from that, it will be called via atexit mechanism automatically 2018-11-14 20:17:04 -08:00
Ondřej Surý
de6f43d071 Use static assertion to check for correct alignment size 2018-11-14 18:18:27 -05:00
Ondřej Surý
5e44a1008f Define STATIC_ASSERT(cond, msg) to be _Static_assert(cond, msg) everywhere but on Windows where it stays to be INSIST(cond) 2018-11-14 18:18:27 -05:00
Mark Andrews
4eadebe2b2 uninitalize memory read on error path 2018-11-14 15:26:27 -05:00
Mark Andrews
93776c4c81 errors initalizing badcaches were not caught or cleaned up on error paths 2018-11-14 15:26:27 -05:00
Witold Kręcicki
9c8fead6d8 qname minimization: issue a warning only if the server is really broken 2018-11-14 19:55:10 +00:00
Mark Andrews
50714a9b35 free tmpzonename and restart_master 2018-11-14 11:23:21 -08:00
Mark Andrews
333f718dd3 don't use 'typename' as it is reserved in C++ 2018-11-14 13:45:20 -05:00
Ondřej Surý
e9a939841d Add min-cache-ttl and min-ncache-ttl keywords
Sometimes it is useful to set a 'floor' on the TTL for records
to be cached.  Some sites like to use ridiculously low TTLs for
some reason, and that often is not compatible with slow links.

Signed-off-by: Michael Milligan <milli@acmeps.com>
Signed-off-by: LaMont Jones <lamont@debian.org>
2018-11-14 18:24:53 +01:00
Mark Andrews
9024cf0c15 remove lib/isc/tests/result_test as it is now cmocka 2018-11-13 07:26:29 +11:00
Mark Andrews
9a59352b4c link in lib/isccc/tests/Kyuafile 2018-11-13 07:23:36 +11:00
Evan Hunt
471110933a convert result tests to use CMocka instead of ATF 2018-11-10 12:29:40 -08:00
Mark Andrews
4f04a79250 check result tables are complete 2018-11-10 10:30:43 +11:00
Mark Andrews
6ead8c7be8 look in windows registry for nameservers, domainname and search list 2018-11-09 16:06:49 +11:00
Mark Andrews
28442f11f0 log RPZ type and class 2018-11-08 22:48:28 -05:00
Ondřej Surý
6f5fe11f5a isc_stdtime_t is always 32-bit now, so remove the always true macro STDTIME_ON_32BITS 2018-11-09 02:27:06 +07:00
Ondřej Surý
68ca987792 Remove dummy ISLOCKED macro 2018-11-08 12:22:26 +07:00
Ondřej Surý
23fff6c569 Hint the compiler with ISC_UNREACHABLE(); that code after INSIST(0); cannot be reached 2018-11-08 12:22:17 +07:00
Ondřej Surý
b992b5b811 Modify the dbversion_test.c to detect disabled assertions 2018-11-08 12:22:17 +07:00
Ondřej Surý
29c45200e7 Add extra return failure after INSIST(0) in default branch 2018-11-08 12:22:17 +07:00
Ondřej Surý
4eaf927571 Use larger buffers on snprintf buffer overflow false positives 2018-11-08 12:21:53 +07:00
Ondřej Surý
e2e138a801 Don't assert on failed getrlimit call to allow called to handle this gracefully as it already does, just abort where we need to know the numbers 2018-11-08 12:21:53 +07:00
Ondřej Surý
a831e0f72d When ISC assertions are disabled, still execute the condition to prevent unused variable warnings/errors from the compiler 2018-11-08 12:21:53 +07:00
Ondřej Surý
b2b43fd235 Turn (int & flag) into (int & flag) != 0 when implicitly typed to bool 2018-11-08 12:21:53 +07:00
Ondřej Surý
fbd2e47f51 Add small tweaks to the code to fix compilation when ISC assertions are disabled
While implementing the new unit testing framework cmocka, it was found that the
BIND 9 code doesn't compile when assertions are disabled or replaced with any
function (such as mock_assert() from cmocka unit testing framework) that's not
directly recognized as assertion by the compiler.

This made the compiler to complain about blocks of code that was recognized as
unreachable before, but now it isn't.

The changes in this commit include:

* assigns default values to couple of local variables,
* moves some return statements around INSIST assertions,
* adds __builtin_unreachable(); annotations after some INSIST assertions,
* fixes one broken assertion (= instead of ==)
2018-11-08 12:21:53 +07:00
Witold Kręcicki
ce478b4fc9 Fix a typo in lib/isc/unix/thread.c 2018-11-07 19:31:06 +00:00
Witold Kręcicki
9a903789ed Use larger quantum for network tasks 2018-11-06 08:19:50 +00:00
Witold Kręcicki
460c8038c1 Use a single wake_all_queues() function to wake all queues 2018-11-06 08:19:50 +00:00
Witold Kręcicki
b3827319e0 Switch from privileged to un-privileged mode under lock 2018-11-06 08:19:50 +00:00
Witold Kręcicki
f166cabcae Document isc_task_sendto properly, make sure that cpu we're sending to is always sane 2018-11-06 08:19:50 +00:00
Witold Kręcicki
025c74adee Use proper memory ordering for tasks_running/tasks_ready 2018-11-06 08:19:50 +00:00
Witold Kręcicki
8fb5bc783f Comment about taskmgr exclusive mode, fix a REQUIRE. 2018-11-06 08:19:50 +00:00
Witold Kręcicki
913856911a Saner exclusive task handling in taskmgr 2018-11-06 08:19:50 +00:00
Witold Kręcicki
17d46fd48b Formatting 2018-11-06 08:19:50 +00:00
Witold Kręcicki
c80e25e482 Get rid of isc_taskmgr_setmode, we only use it to set privileged mode 2018-11-06 08:19:50 +00:00
Witold Kręcicki
64020dd7bc Make sure all priority tasks are done before entering normal execution 2018-11-06 08:19:50 +00:00
Witold Kręcicki
669a694d3b Post shutting down tasks always to manager 0 2018-11-06 08:19:50 +00:00
Witold Kręcicki
c416389d32 Separate structure for each thread/queue; 2-phase-locking for exclusive tasks 2018-11-06 08:19:50 +00:00
Witold Kręcicki
818d63a3a1 Always restart dispatchers on empty readyq 2018-11-06 08:19:50 +00:00
Witold Kręcicki
d7be8afea5 Taskmgr shutdown fixes 2018-11-06 08:19:50 +00:00
Witold Kręcicki
81a85070c5 Multiple worker queues 2018-11-06 08:19:50 +00:00
Witold Krecicki
7b6721b27f isc_thread_setaffinity() 2018-11-06 08:19:50 +00:00