Commit Graph
290 Commits
Author SHA1 Message Date
Ondřej Surý 773f429626 Update the whitespaces 2019-09-11 10:31:48 +02:00
Witold KręcickiandOndřej Surý 086de03aa7 netmgr: checkpoint: isc_task_pause/unpause - we want to pause client->task when we're processing it outside taskmgr (directly from network thread) 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý ba28f8c96a netmgr: proper closing of TCP/TCPDNS connections, TCP quota support 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý 7c86ba8131 fixup! nm: first xfrout support 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý 24751997c4 netmgr: stop DNS listening, pt 1 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý e34d47b651 netmgr: pause/resume netmgr when going exclusive 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý facf3af6df netmgr: client mctxs divided by thread 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý d42de0c290 nm: WiP: proper udp shutdown procedure 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý 46778e475f nm: first xfrout support 2019-09-10 17:06:47 +02:00
Witold KręcickiandOndřej Surý fa74784835 nm: some style nits, better handling of UDP shutdown 2019-09-10 17:06:46 +02:00
Witold KręcickiandOndřej Surý a83be985b4 netmgr: a big WiP on TCP/DNS 2019-09-10 17:06:46 +02:00
Witold KręcickiandOndřej Surý dac01af74f clientmgr has a taskpool, clients attach to it 2019-09-10 17:06:46 +02:00
Witold KręcickiandOndřej Surý a5392d83c6 Netmgr - work in progress (squashed)
Make a copy of ns__client_request as ns__client_request_old

The 'old' one will be used by not-yet-reworked parts, while we
keep history of ns__client_request.

Start netmgr with named, shutdown at the end

- udplistener in interfacemgr uses netmgr
- use per-client buffer for udp send
- first steps at making ns_client_request use netmgr for UDP
- uncrustify

Make interfacemgr and interface references isc_refcount_t instead of locked ints

Use clock_gettime instead of gettimeofday

Cleanup get_client, use one interface for clientmgr instead of attaching it to each client

'extra' field at the end of handle - for client data

WiP: no TCP, UDP works, no resolver
2019-09-10 17:06:46 +02:00
Ondřej Surý 50e109d659 isc_event_allocate() cannot fail, remove the fail handling blocks
isc_event_allocate() calls isc_mem_get() to allocate the event structure.  As
isc_mem_get() cannot fail softly (e.g. it never returns NULL), the
isc_event_allocate() cannot return NULL, hence we remove the (ret == NULL)
handling blocks using the semantic patch from the previous commit.
2019-08-30 08:55:34 +02:00
Tinderbox User d6a9407908 prep 9.15.3 2019-08-12 13:59:41 +00:00
Michał Kępień 3384455659 Tweak buffer sizes to prevent compilation warnings
For some libc implementations, BUFSIZ is small enough (e.g. 1024 for
musl libc) to trigger compilation warnings about insufficient size of
certain buffers.  Since the relevant buffers are used for printing DNS
names, increase their size to '(n + 1) * DNS_NAME_FORMATSIZE', where 'n'
is the number of DNS names which are printed to a given buffer.  This
results in somewhat arbitrary, albeit nicely-aligned and large enough
buffer sizes.
2019-07-30 21:25:18 +02:00
Michał Kępień 5381ac0fcc Unify header ordering in unit tests
Make sure all unit tests include headers in a similar order:

 1. Three headers which must be included before <cmocka.h>.
 2. System headers.
 3. UNIT_TESTING definition, followed by the <cmocka.h> header.
 4. libisc headers.
 5. Headers from other BIND libraries.
 6. Local headers.

Also make sure header file names are sorted alphabetically within each
block of #include directives.
2019-07-30 21:25:15 +02:00
Michał Kępień 59528d0e9d Include <sched.h> where necessary for musl libc
All unit tests define the UNIT_TESTING macro, which causes <cmocka.h> to
replace malloc(), calloc(), realloc(), and free() with its own functions
tracking memory allocations.  In order for this not to break
compilation, the system header declaring the prototypes for these
standard functions must be included before <cmocka.h>.

Normally, these prototypes are only present in <stdlib.h>, so we make
sure it is included before <cmocka.h>.  However, musl libc also defines
the prototypes for calloc() and free() in <sched.h>, which is included
by <pthread.h>, which is included e.g. by <isc/mutex.h>.  Thus, unit
tests including "dnstest.h" (which includes <isc/mem.h>, which includes
<isc/mutex.h>) after <cmocka.h> will not compile with musl libc as for
these programs, <sched.h> will be included after <cmocka.h>.

Always including <cmocka.h> after all other header files is not a
feasible solution as that causes the mock assertion macros defined in
<isc/util.h> to mangle the contents of <cmocka.h>, thus breaking
compilation.  We cannot really use the __noreturn__ or analyzer_noreturn
attributes with cmocka assertion functions because they do return if the
tested condition is true.  The problem is that what BIND unit tests do
is incompatible with Clang Static Analyzer's assumptions: since we use
cmocka, our custom assertion handlers are present in a shared library
(i.e. it is the cmocka library that checks the assertion condition, not
a macro in unit test code).  Redefining cmocka's assertion macros in
<isc/util.h> is an ugly hack to overcome that problem - unfortunately,
this is the only way we can think of to make Clang Static Analyzer
properly process unit test code.  Giving up on Clang Static Analyzer
being able to properly process unit test code is not a satisfactory
solution.

Undefining _GNU_SOURCE for unit test code could work around the problem
(musl libc's <sched.h> only defines the prototypes for calloc() and
free() when _GNU_SOURCE is defined), but doing that could introduce
discrepancies for unit tests including entire *.c files, so it is also
not a good solution.

All in all, including <sched.h> before <cmocka.h> for all affected unit
tests seems to be the most benign way of working around this musl libc
quirk.  While quite an ugly solution, it achieves our goals here, which
are to keep the benefit of proper static analysis of unit test code and
to fix compilation against musl libc.
2019-07-30 21:08:40 +02:00
Ondřej Surý 9bdc24a9fd Use coccinelle to cleanup the failure handling blocks from isc_mem_strdup 2019-07-23 15:32:36 -04:00
Ondřej Surý ae83801e2b Remove blocks checking whether isc_mem_get() failed using the coccinelle 2019-07-23 15:32:35 -04:00
Mark Andrews 1eb640049c Do not attempt to perform a DNS64 rewrite if RPZ returns NODATA. 2019-07-23 04:19:28 +10:00
Ondřej Surý a912f31398 Add new default siphash24 cookie algorithm, but keep AES as legacy
This commit changes the BIND cookie algorithms to match
draft-sury-toorop-dnsop-server-cookies-00.  Namely, it changes the Client Cookie
algorithm to use SipHash 2-4, adds the new Server Cookie algorithm using SipHash
2-4, and changes the default for the Server Cookie algorithm to be siphash24.

Add siphash24 cookie algorithm, and make it keep legacy aes as
2019-07-21 15:16:28 -04:00
Witold KręcickiandOndřej Surý afa81ee4e4 Remove all cookie algorithms but AES, which was used as a default, for legacy purposes. 2019-07-21 10:08:14 -04:00
Ondřej SurýandWitold Kręcicki 81faafd508 lib/ns/stats.c: use isc_refcount_t 2019-07-09 16:11:14 +02:00
Witold Kręcicki de73904d03 lib/ns/client: use refcount_t for reference counting 2019-07-09 16:09:36 +02:00
Witold Kręcicki fc19182e97 lib/ns/lib.c: use isc_refcount_t for reference counting 2019-07-09 16:09:36 +02:00
Witold Kręcicki 92424e23fa Special, for-tests-only, mode with atomics emulated by a mutex-locked variable - useful for finding atomics congestions 2019-07-09 16:09:36 +02:00
Witold Kręcicki 5aeb99786e Properly initialize all atomic variables 2019-07-09 16:09:36 +02:00
Witold Kręcicki 3fcf98c8d3 isc/stats: use isc_refcount_t 2019-07-09 16:09:36 +02:00
Witold Kręcicki c434cc69d7 interfacemgr: use isc_refcount_t for reference counting 2019-07-09 16:09:36 +02:00
Evan Hunt 787f2a7e03 remove all support for legacy GeoIP 2019-07-04 08:56:45 -07:00
Ondřej Surý 723433cbc6 Add rules to make sure subdirs are always built before testdirs 2019-07-02 12:32:22 +02:00
Evan Hunt fe46d5bc34 add HAVE_GEOIP2 #ifdef branches, without implementing yet 2019-06-27 14:58:14 -07:00
Evan Hunt fea6b5bf10 add a search for GeoIP2 libraries in configure
- "--with-geoip" is used to enable the legacy GeoIP library.
- "--with-geoip2" is used to enable the new GeoIP2 library
  (libmaxminddb), and is on by default if the library is found.
- using both "--with-geoip" and "--with-geoip2" at the same time
  is an error.
- an attempt is made to determine the default GeoIP2 database path at
  compile time if pkg-config is able to report the module prefix. if
  this fails, it will be necessary to set the path in named.conf with
  geoip-directory
- Makefiles have been updated, and a stub lib/dns/geoip2.c has been
  added for the eventual GeoIP2 search implementation.
2019-06-27 14:58:13 -07:00
Evan Hunt e7684c7b64 allow glue in authoritative responses to root priming queries
- when processing authoritative queries for ./NS, set 'gluedb' so
  that glue will be included in the response, regardless of how
  'minimal-responses' has been configured.
2019-06-26 08:53:42 -07:00
Ondřej Surý 5d1e7be582 Rename OPENSSL_INCLUDES to OPENSSL_CFLAGS in AX_CHECK_OPENSSL() macro
The ax_check_openssl m4 macro used OPENSSL_INCLUDES.  Rename the
subst variable to OPENSSL_CFLAGS and wrap AX_CHECK_OPENSSL() in
action-if-not-found part of PKG_CHECK_MODULE check for libcrypto.
2019-06-25 12:36:01 +02:00
Ondřej Surý e3e6888946 Make the usage of json-c objects opaque to the caller
The json-c have previously leaked into the global namespace leading
to forced -I<include_path> for every compilation unit using isc/xml.h
header.  This MR fixes the usage making the caller object opaque.
2019-06-25 12:04:20 +02:00
Ondřej Surý 0771dd3be8 Make the usage of libxml2 opaque to the caller
The libxml2 have previously leaked into the global namespace leading
to forced -I<include_path> for every compilation unit using isc/xml.h
header.  This MR fixes the usage making the caller object opaque.
2019-06-25 12:01:32 +02:00
Tinderbox UserandEvan Hunt 9bb0b30bc2 prep 9.15.1 2019-06-19 15:36:28 -07:00
Witold KręcickiandMark Andrews 24cfee942f Make sure that recursclient gauge is calculated correctly.
We increase recursclients when we attach to recursion quota,
decrease when we detach. In some cases, when we hit soft
quota, we might attach to quota without increasing recursclients
gauge. We then decrease the gauge when we detach from quota,
and it causes the statistics to underflow.
Fix makes sure that we increase recursclients always when we
succesfully attach to recursion quota.
2019-06-13 13:35:44 +10:00
Mark Andrews 915af3c950 change mnemonic for IXFR poll response 2019-06-03 15:14:45 +10:00
Mark Andrews 043df1be12 lower ixfr stop messages log level to debug(1) for poll style responses 2019-06-03 15:14:45 +10:00
Witold KręcickiandEvan Hunt ae52c2117e Use experimental "_ A" minimization in relaxed mode.
qname minimization, even in relaxed mode, can fail on
some very broken domains. In relaxed mode, instead of
asking for "foo.bar NS" ask for "_.foo.bar A" to either
get a delegation or NXDOMAIN. It will require more queries
than regular mode for proper NXDOMAINs.
2019-05-30 14:06:55 -07:00
Ondřej Surý 4d2d3b49ce Cleanup the way we detect json-c library to use only pkg-config 2019-05-29 15:08:52 +02:00
Tinderbox User 25e416fb67 prep 9.15.0 2019-05-10 04:39:43 +00:00
Mark Andrews 18c49853e3 only test provideixfr if the transport is TCP 2019-05-07 12:59:35 +10:00
Ondřej Surý 8965a0ba98 Replace atomic operations in bin/named/client.c with isc_refcount reference counting
(cherry picked from commit ef49780d30)
(cherry picked from commit e203d4d65a)
2019-04-26 22:14:26 +02:00
Evan HuntandOndřej Surý d809ec6c14 restore allowance for tcp-clients < interfaces
in the "refactor tcpquota and pipeline refs" commit, the counting
of active interfaces was tightened in such a way that named could
fail to listen on an interface if there were more interfaces than
tcp-clients. when checking the quota to start accepting on an
interface, if the number of active clients was above zero, then
it was presumed that some other client was able to handle accepting
new connections. this, however, ignored the fact that the current client
could be included in that count, so if the quota was already exceeded
before all the interfaces were listening, some interfaces would never
listen.

we now check whether the current client has been marked active; if so,
then the number of active clients on the interface must be greater
than 1, not 0.

(cherry picked from commit 02365b87ea0b1ea5ea8b17376f6734c811c95e61)
(cherry picked from commit cae79e1bab)
2019-04-25 16:32:05 +02:00
Evan HuntandOndřej Surý 2f3876d187 refactor tcpquota and pipeline refs; allow special-case overrun in isc_quota
- if the TCP quota has been exceeded but there are no clients listening
  for new connections on the interface, we can now force attachment to the
  quota using isc_quota_force(), instead of carrying on with the quota not
  attached.
- the TCP client quota is now referenced via a reference-counted
  'ns_tcpconn' object, one of which is created whenever a client begins
  listening for new connections, and attached to by members of that
  client's pipeline group. when the last reference to the tcpconn
  object is detached, it is freed and the TCP quota slot is released.
- reduce code duplication by adding mark_tcp_active() function
- convert counters to stdatomic

(cherry picked from commit a8dd133d270873b736c1be9bf50ebaa074f5b38f)
(cherry picked from commit 4a8fc979c4)
2019-04-25 16:32:05 +02:00
Evan HuntandOndřej Surý a0f4a3fa65 better tcpquota accounting and client mortality checks
- ensure that tcpactive is cleaned up correctly when accept() fails.
- set 'client->tcpattached' when the client is attached to the tcpquota.
  carry this value on to new clients sharing the same pipeline group.
  don't call isc_quota_detach() on the tcpquota unless tcpattached is
  set.  this way clients that were allowed to accept TCP connections
  despite being over quota (and therefore, were never attached to the
  quota) will not inadvertently detach from it and mess up the
  accounting.
- simplify the code for tcpquota disconnection by using a new function
  tcpquota_disconnect().
- before deciding whether to reject a new connection due to quota
  exhaustion, check to see whether there are at least two active
  clients. previously, this was "at least one", but that could be
  insufficient if there was one other client in READING state (waiting
  for messages on an open connection) but none in READY (listening
  for new connections).
- before deciding whether a TCP client object can to go inactive, we
  must ensure there are enough other clients to maintain service
  afterward -- both accepting new connections and reading/processing new
  queries.  A TCP client can't shut down unless at least one
  client is accepting new connections and (in the case of pipelined
  clients) at least one additional client is waiting to read.

(cherry picked from commit 427a2fb4d17bc04ca3262f58a9dcf5c93fc6d33e)
(cherry picked from commit 0896841272)
2019-04-25 16:32:05 +02:00