]> git.ipfire.org Git - thirdparty/knot-resolver.git/log
thirdparty/knot-resolver.git
6 years agomodules/http: added handlers for DNS over HTTPS cloudflare
Marek Vavruša [Thu, 14 Mar 2019 02:26:29 +0000 (19:26 -0700)] 
modules/http: added handlers for DNS over HTTPS

6 years agodaemon/worker: in some circumstances task can be finalized twice, fixed
Grigorii Demidov [Fri, 31 Aug 2018 14:02:44 +0000 (16:02 +0200)] 
daemon/worker: in some circumstances task can be finalized twice, fixed

6 years agolib/cache: reflect cache scope change when found answer from wider scope
Marek Vavruša [Fri, 7 Sep 2018 00:38:43 +0000 (17:38 -0700)] 
lib/cache: reflect cache scope change when found answer from wider scope

This prevents situation when part of a CNAME chain is cached, but the
cached answers never update the scope length.

6 years agofixed typos from the last rebase
Marek Vavruša [Thu, 6 Sep 2018 21:50:05 +0000 (14:50 -0700)] 
fixed typos from the last rebase

6 years agomodules/http: allow listening on UNIX sockets
Marek Vavruša [Wed, 29 Aug 2018 22:35:20 +0000 (15:35 -0700)] 
modules/http: allow listening on UNIX sockets

6 years agodaemon/tls: fix compilation when session tickets are enabled
Marek Vavruša [Wed, 29 Aug 2018 06:00:46 +0000 (23:00 -0700)] 
daemon/tls: fix compilation when session tickets are enabled

6 years agoallow the delegation change if NS has both zones and child is in bailiwick
Marek Vavruša [Tue, 28 Aug 2018 17:32:45 +0000 (10:32 -0700)] 
allow the delegation change if NS has both zones and child is in bailiwick

Previous change required the new delegation to contain QNAME, but
that's not always the case with chasing CNAME chains. This relaxes
the requirement to QNAME from the response packet, so it always
follows the next chased name.

6 years agoRevert "cache: cache RRSIGs in packet cache"
Marek Vavruša [Thu, 23 Aug 2018 18:29:45 +0000 (11:29 -0700)] 
Revert "cache: cache RRSIGs in packet cache"

This reverts commit bb95021cc8a14082139e795ed500ff4dc22c459c.

6 years agolib/defines: added configurable SRTT limits and lowered probing rate
Marek Vavruša [Thu, 23 Aug 2018 00:37:01 +0000 (17:37 -0700)] 
lib/defines: added configurable SRTT limits and lowered probing rate

This adds configurable SRTT limits for various network environments.
The probing rate is reduced from 10% to 1%, so that badly connected
nameservers are not selected as often. This is apparent on zone cuts
with a lot of nameservers, e.g. .com. With the probing rate set to
1% the average response time for 300 queries is almost 50% better:

6 years agolib/cache: add LMDB_NO_DROP to always unlink file without mdb_drop
Marek Vavruša [Thu, 23 Aug 2018 00:34:57 +0000 (17:34 -0700)] 
lib/cache: add LMDB_NO_DROP to always unlink file without mdb_drop

The mdb_drop() can get slow when the cache size is several GB,
so that the init daemon times out when waiting for the daemon to start,
and keeps restarting it in a loop.

6 years agodaemon: add -n / --dry-run mode
Marek Vavruša [Thu, 23 Aug 2018 00:34:09 +0000 (17:34 -0700)] 
daemon: add -n / --dry-run mode

In this mode the daemon will parse configuration and initialize,
but then exit immediately without serving queries.

6 years agocache/api: prevent deadlock on kr_cache_remove with multiple processes
Marek Vavruša [Tue, 21 Aug 2018 06:59:24 +0000 (23:59 -0700)] 
cache/api: prevent deadlock on kr_cache_remove with multiple processes

Only the `kr_cache_remove_subtree` called `kr_cache_sync` to commit
the write transaction after cache removal operation. This wasn't
done in the `kr_cache_remove` so the write transaction could be
long-lived.

With two or more processes, if one help the write transaction open,
no other process could open it. If the process holding the transaction
would call IPC to other processes and wait, it would never release
it and the other processes could never acquire it, and deadlock
would occur.

6 years agodaemon/worker: this fixes connect bug, and error handling from TLS writes
Marek Vavruša [Fri, 17 Aug 2018 07:43:36 +0000 (00:43 -0700)] 
daemon/worker: this fixes connect bug, and error handling from TLS writes

Previously, when the chosen protocol for the next message was SOCK_STREAM,
the TLS upgrade checked next selected address instead of retry address.

The error handling loop for uncorking TLS data was wrong, as the
underlying push function is asynchronous and there's no relationship
between completed DNS packet writes and number of TLS message writes.
In case of the asynchronous function, the buffered data must be valid
until the write is complete, currently this is not guaranteed and
loading the resolver with pipelined requests results in memory errors:

```
$ getdns_query @127.0.0.1#853 -s -a -s -l L -B -F queries -q
...
==47111==ERROR: AddressSanitizer: heap-use-after-free on address 0x6290040a1253 at pc 0x00010da960d3 bp 0x7ffee2628b30 sp 0x7ffee26282e0
READ of size 499 at 0x6290040a1253 thread T0
    #0 0x10da960d2 in wrap_write (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x1f0d2)
    #1 0x10d855971 in uv__write (libuv.1.dylib:x86_64+0xf971)
    #2 0x10d85422e in uv__stream_io (libuv.1.dylib:x86_64+0xe22e)
    #3 0x10d85b35a in uv__io_poll (libuv.1.dylib:x86_64+0x1535a)
    #4 0x10d84c644 in uv_run (libuv.1.dylib:x86_64+0x6644)
    #5 0x10d602ddf in main main.c:422
    #6 0x7fff6a28a014 in start (libdyld.dylib:x86_64+0x1014)

0x6290040a1253 is located 83 bytes inside of 16895-byte region [0x6290040a1200,0x6290040a53ff)
freed by thread T0 here:
    #0 0x10dacdfdd in wrap_free (libclang_rt.asan_osx_dynamic.dylib:x86_64h+0x56fdd)
    #1 0x10d913c2e in _mbuffer_head_remove_bytes (libgnutls.30.dylib:x86_64+0xbc2e)
    #2 0x10d915080 in _gnutls_io_write_flush (libgnutls.30.dylib:x86_64+0xd080)
    #3 0x10d90ca18 in _gnutls_send_tlen_int (libgnutls.30.dylib:x86_64+0x4a18)
    #4 0x10d90edde in gnutls_record_send2 (libgnutls.30.dylib:x86_64+0x6dde)
    #5 0x10d90f085 in gnutls_record_uncork (libgnutls.30.dylib:x86_64+0x7085)
    #6 0x10d5f6569 in tls_push tls.c:238
    #7 0x10d5e5b2a in qr_task_send worker.c:1002
    #8 0x10d5e2ea6 in qr_task_finalize worker.c:1562
    #9 0x10d5dab99 in qr_task_step worker.c
    #10 0x10d5e12fe in worker_process_tcp worker.c:2410
```

The current implementation adds opportunistic uv_try_write which
either writes the requested data, or returns UV_EAGAIN or an error,
which then falls back to slower asynchronous write that copies the buffered data.

The function signature is changed from simple write to vectorized write.

This also enables TLS False Start to save 1RTT when possible.

6 years agosupport multiple addresses in daf src/dst filter
Anbang Wen [Tue, 14 Aug 2018 23:10:10 +0000 (16:10 -0700)] 
support multiple addresses in daf src/dst filter

This enables using syntax like "src { CIDR-a CIDR-b } deny" to specify
multiple addresses to filter. All the conditions are ORed together
like qname/ns.

6 years agolib/nsrep: flag nameservers not supporting TCP
Marek Vavruša [Wed, 15 Aug 2018 22:12:37 +0000 (15:12 -0700)] 
lib/nsrep: flag nameservers not supporting TCP

The previous behavior was to flag nameserver that doesn't respond
over TCP as dead, but this doesn't work in case when nameserver
only supports UDP (e.g. duckdns.org).

The new behavior flags nameservers that don't support TCP separately
in reputation cache. The effect of that is that when UDP times out,
another nameserver is elected instead of retrying over TCP and blacklisting
the nameserver.

6 years agodaemon/tls: implement client-side rehandshake request
Marek Vavruša [Thu, 9 Aug 2018 18:56:51 +0000 (11:56 -0700)] 
daemon/tls: implement client-side rehandshake request

When the server asks for a rehandshake, the client side should
perform it to avoid service interruptions.

6 years agodaemon/tls: TLS parameters are refcounted by client sessions
Marek Vavruša [Thu, 9 Aug 2018 18:54:45 +0000 (11:54 -0700)] 
daemon/tls: TLS parameters are refcounted by client sessions

The TLS parameters are shared between client sessions, but they
can be removed from the server during runtime, so a care must be
taken so that the parameters are not freed while sessions use them.

This commit adds reference counting to TLS parameters, so that they
remain valid until the last session using them is closed.

6 years agodaemon/worker: fixes for handling of some non-fatal TLS errors, metrics
Marek Vavruša [Fri, 3 Aug 2018 22:04:45 +0000 (15:04 -0700)] 
daemon/worker: fixes for handling of some non-fatal TLS errors, metrics

The handshake now properly deals with GNUTLS_E_INTERRUPTED to retry,
and GNUTLS_E_WARNING_ALERT_RECEIVED and GNUTLS_E_GOT_APPLICATION_DATA
during session resumption.

Added a metric for monitoring TLS handshake errors.

Added `net.tls_handshake_timeout([milliseconds])` for configurable
TLS handshake timeout (default is 6000ms), and documentation for
`net.tcp_in_idle([milliseconds])`.

6 years agodaemon: add concurrent requests and request limiting to metrics
Marek Vavruša [Wed, 8 Aug 2018 20:15:41 +0000 (13:15 -0700)] 
daemon: add concurrent requests and request limiting to metrics

6 years agocache: make expiring TTL threshold compile time configurable
Marek Vavruša [Tue, 7 Aug 2018 00:08:13 +0000 (17:08 -0700)] 
cache: make expiring TTL threshold compile time configurable

By default the decayed TTL is considered as 'expiring' when it
is in the last 1% of its lifetime, or  shorter than 5 seconds.

6 years agocache: cache RRSIGs in packet cache
Marek Vavruša [Sun, 5 Aug 2018 02:38:18 +0000 (19:38 -0700)] 
cache: cache RRSIGs in packet cache

This will enable caching of RRSIG queries in packet cache.
The RRSIGs are cached as insecure as they don't have a signature.
Bogus RRSIGs won't be cached as they have to first pass the validator.

6 years agolayer/iterate: do not change delegation on qname minimization failure
Marek Vavruša [Wed, 1 Aug 2018 23:16:30 +0000 (16:16 -0700)] 
layer/iterate: do not change delegation on qname minimization failure

Before a server could change delegation when there was an NS record
for different name in the answer section. e.g.:

```
QNAME: test.example.com
ANSWER: else.example.com NS somewhere
```

The zone cut would change to else.example.com.

6 years agodaemon/worker: always invalidate upstream address list
Marek Vavruša [Wed, 1 Aug 2018 20:38:10 +0000 (13:38 -0700)] 
daemon/worker: always invalidate upstream address list

This makes sure that the whole upstream address list is invalidated
on address selection, and retransmit doesn't send query to invalid
upstream in case all other choices are exhausted.

6 years agodaemon: allow opportunistic DNS over TLS to origins
Marek Vavruša [Tue, 31 Jul 2018 22:12:25 +0000 (15:12 -0700)] 
daemon: allow opportunistic DNS over TLS to origins

This commit allows opportunistic DNS over TLS to origins configured
as supporting DoT on port 853. It also adds interface for clearing
configured TLS clients to allow runtime reconfiguration.

The general mode of operation is as follows:

1. Produce a new outgoing query
2. Check if the selected upstream address has configured TLS support on port 853
 2a. If it does: upgrade to DNS over TLS, it cannot be downgraded from this point
 2b. If not: continue with preferred protocol

This allows further automatic discovery as in [1], but right now it has to be configured
manually.

[1]: https://tools.ietf.org/id/draft-bortzmeyer-dprive-resolver-to-auth-00.html

6 years agodaemon/worker: don't include connection setup for TCP and TLS in RTT
Marek Vavruša [Tue, 31 Jul 2018 22:07:58 +0000 (15:07 -0700)] 
daemon/worker: don't include connection setup for TCP and TLS in RTT

Currently the handshake time is included in the RTT, so TCP and TLS
retries/forwards makes upstreams look bad compared to UDP, and
discourage connection reuse as other "faster" origins end up
with lower score, so they would be preferred.

This commit excludes wait and handshake time, so only the actual
message exchange time is included in the RTT calculation.

6 years agodaemon: make idle timeout for incoming connection configurable
Grigorii Demidov [Tue, 26 Jun 2018 08:49:23 +0000 (10:49 +0200)] 
daemon: make idle timeout for incoming connection configurable

6 years agocache/api: pass memory context in kr_cache_insert_rr
Marek Vavruša [Sat, 14 Jul 2018 00:11:04 +0000 (17:11 -0700)] 
cache/api: pass memory context in kr_cache_insert_rr

The cache changes in 2.4.0 require query to be present with a memory
context initialized for splicing records.

6 years agokr_rank_test*: avoid code duplication
Vladimír Čunát [Mon, 11 Jun 2018 08:14:47 +0000 (10:14 +0200)] 
kr_rank_test*: avoid code duplication

6 years agohttp: run prometheus metrics collector on leader only
Anbang Wen [Tue, 10 Jul 2018 08:02:59 +0000 (01:02 -0700)] 
http: run prometheus metrics collector on leader only

Metrics are collected and merged in http.prometheus, no need to be run
on every worker.

6 years agopolicy: fix incompatibility with default (nil) phase
Marek Vavruša [Tue, 19 Jun 2018 21:50:20 +0000 (14:50 -0700)] 
policy: fix incompatibility with default (nil) phase

The `{ nil }` would otherwise get interpreted as an empty table.

6 years agomodules/http: allow passing server options to http configuration
Marek Vavruša [Tue, 6 Mar 2018 22:29:45 +0000 (14:29 -0800)] 
modules/http: allow passing server options to http configuration

This allows HTTP server to start with reuseport, reuseaddr or v6only.
The reuseport allows running HTTP module on all forks, not just the main one.

6 years agoEnable fork mode under systemd
Anbang Wen [Mon, 18 Jun 2018 22:48:22 +0000 (15:48 -0700)] 
Enable fork mode under systemd

Although the sockets are still shared, multiple process mode has the
ability to use more CPUs. It should be splitted later.

6 years agovalidate: fix when NS is both parent and child and child is insecure
Marek Vavruša [Mon, 18 Jun 2018 23:17:53 +0000 (16:17 -0700)] 
validate: fix when NS is both parent and child and child is insecure

When NS is both parent and child, it would respond to the final query
without signature and resolver is supposed to ask for DS to prove the
transition to insecure. Previously, this was only checked for NS queries
(made during referral chasing), so it would work for intermediate
nameservers, but not for final.

6 years agodaemon/lua: add support for resizing packets
Marek Vavruša [Mon, 18 Jun 2018 19:09:51 +0000 (12:09 -0700)] 
daemon/lua: add support for resizing packets

6 years agopolicy: apply filters on outgoing queries as well
Marek Vavruša [Fri, 15 Jun 2018 22:28:54 +0000 (15:28 -0700)] 
policy: apply filters on outgoing queries as well

This allows blocking names with intermediate CNAMEs, e.g.

```
example.com CNAME invalid
```

Before, the policies were only applied on query name,
which can be circumvented by a layer of indirection like this.

6 years agocache/api: make sure the found cache scope is wider than requested
Marek Vavruša [Mon, 11 Jun 2018 03:45:07 +0000 (20:45 -0700)] 
cache/api: make sure the found cache scope is wider than requested

6 years agolib/cache/api: generalize ECS code to support longest prefix match
Marek Vavruša [Mon, 11 Jun 2018 00:12:00 +0000 (17:12 -0700)] 
lib/cache/api: generalize ECS code to support longest prefix match

The current semantics is to try to look up an exact match, or
look into global scope. This commit changes that to longest prefix
match, so that wider cache scopes can be used to match against
multiple prefixes. In order to do this, the key scope format needs to
be changed from:

```
u8[] address
u8   scope_len
```

To:

```
u8[4 or 16] address
u8          scope_len
```

The fixed address length is necessary to be able to use lexicographic
lesser-or-equal scan supported by the database. For example, if the
search key is 192.168.0/24 (`\192\168\0\0\24'), any wider prefix
must be lexicographically smaller. The `\192\168\16` wouldn't be,
but the `\192\168\0\0\16` is, hence the key format change.

The fixed key size is also necessary to separate IPv4 scopes from
IPv6 scopes and vice versa. This is checked by comparing the
length of the found lesser-or-equal key - if the length is the same,
and key (without the scope part) is equal, the scope must be the same address
family.

6 years agoiterate: follow CNAMEs in stub mode
Marek Vavruša [Sat, 9 Jun 2018 04:06:01 +0000 (21:06 -0700)] 
iterate: follow CNAMEs in stub mode

There are two forwarder modes in the resolver - full forwarder,
and a stub mode. The full forwarder expects upstream to fully
solve the request (so the upstream must be a recursive resolver).

The stub forwarder mode is primarily useful for directing traffic
to a trusted resolver or authoritative (e.g. forward queries for
an internal zone). The upstream may not know the full answer to
the query, and may answer only from its authority. In that case
the resolver should follow the partially solved CNAME instead
of serving the partial answer.

6 years agolib/utils: added flags field to ranked_rr_array_entry
Marek Vavruša [Sat, 9 Jun 2018 02:13:19 +0000 (19:13 -0700)] 
lib/utils: added flags field to ranked_rr_array_entry

This uses 4 bits of space that were lost for alignment.
It doesn't have any direct use, but modules can use it to tag
entries.

6 years agopolicy: set NS set, support insecure forward in stub
Marek Vavruša [Wed, 6 Jun 2018 05:23:43 +0000 (22:23 -0700)] 
policy: set NS set, support insecure forward in stub

This allows policy filter to modify NS set in the checkout layer.
It also fixes a bug in which invalid peer address would be used
if the first UDP retransmit fails (`choice` would be set to memory
past the `task->addrlist` in `qr_task_step`).

6 years agomodules/policy: fixed NYIs (vararg function call)
Marek Vavruša [Thu, 31 May 2018 02:06:22 +0000 (19:06 -0700)] 
modules/policy: fixed NYIs (vararg function call)

* fixed NYI with vararg calls in policy filter
* fixed NYI with nil returns (incompatible with type pointer returned otherwise)
* fixed tail call returns exceeding trace loop counts

6 years agoremoved invalid assert from e51864e98f951a1d22808410d42751b0d1bb6772
Marek Vavruša [Wed, 30 May 2018 04:38:56 +0000 (21:38 -0700)] 
removed invalid assert from e51864e98f951a1d22808410d42751b0d1bb6772

6 years agoRevert "iterate: fix minimisation downgrade when encountering authoritative referrals"
Marek Vavruša [Wed, 30 May 2018 04:37:50 +0000 (21:37 -0700)] 
Revert "iterate: fix minimisation downgrade when encountering authoritative referrals"

This reverts commit e51864e98f951a1d22808410d42751b0d1bb6772.

6 years agoRevert "validate: don't turn all NS records insecure on non-existent DS"
Marek Vavruša [Wed, 30 May 2018 04:34:32 +0000 (21:34 -0700)] 
Revert "validate: don't turn all NS records insecure on non-existent DS"

This reverts commit f522436b62cdfd972f603809a367859c4576445b.

6 years agocache/api: implement cache scope for kr_cache_insert()
Marek Vavruša [Tue, 29 May 2018 06:31:55 +0000 (23:31 -0700)] 
cache/api: implement cache scope for kr_cache_insert()

6 years agoresolve: write EDNS to wire after the finish layer
Marek Vavruša [Thu, 24 May 2018 23:57:59 +0000 (16:57 -0700)] 
resolve: write EDNS to wire after the finish layer

This allows the finish layer to add/update OPT RR in the answer.

6 years agonsrep: verbose probe message, cap timeout value, less aggressive retry
Marek Vavruša [Thu, 24 May 2018 23:08:07 +0000 (16:08 -0700)] 
nsrep: verbose probe message, cap timeout value, less aggressive retry

The timeouted NS retry probed is now logged when tracing
Long response RTT is capped to KR_NS_TIMEOUT to smooth out transient errors.
The retry timer minimum interval is increased from 250ms to 500ms, as NSs taking
typically longer than 1s would just waste time retrying.

6 years agolru: fix case when inserting value with larger size than allocated
Marek Vavruša [Wed, 16 May 2018 04:34:00 +0000 (21:34 -0700)] 
lru: fix case when inserting value with larger size than allocated

This fixes a case when inserting into LRU, and the entry for given
key exists, but has allocated smaller value than what's requested.

6 years agoiterate: remove NO_MINIMIZE from transitive flags
Marek Vavruša [Wed, 16 May 2018 00:34:10 +0000 (17:34 -0700)] 
iterate: remove NO_MINIMIZE from transitive flags

The NO_MINIMIZE may be set when encountering an ENT, but it should
be retried on subsequent query.

6 years agodaf: bugfix for rule deletion, hint for duplicated rule
Anbang Wen [Mon, 14 May 2018 23:19:57 +0000 (16:19 -0700)] 
daf: bugfix for rule deletion, hint for duplicated rule

6 years agodon't rewrite cached SOA records from negative answers
Marek Vavruša [Sat, 12 May 2018 01:39:12 +0000 (18:39 -0700)] 
don't rewrite cached SOA records from negative answers

Currently there's only exception to avoid rewriting secure NS records.
Most of the negative answers provide SOA record, so it's undesirable
to keep rewriting it for every negative answer.

6 years agomodules/policy: check whether query is defined
Marek Vavruša [Wed, 2 May 2018 23:27:41 +0000 (16:27 -0700)] 
modules/policy: check whether query is defined

6 years agoremoved invalid assertion
Marek Vavruša [Wed, 2 May 2018 23:26:57 +0000 (16:26 -0700)] 
removed invalid assertion

6 years agodaemon/worker: always try multiple upstreams even if sending fails
Marek Vavruša [Tue, 1 May 2018 06:20:27 +0000 (23:20 -0700)] 
daemon/worker: always try multiple upstreams even if sending fails

Before no other upstreams were tried if qr_task_send or kr_resolve_checkout
failed, which isn't correct, as it doesn't allow blocking of outbound requests.

6 years agomodules/daf: allow multiple argument matching in filter
Marek Vavruša [Tue, 1 May 2018 03:17:42 +0000 (20:17 -0700)] 
modules/daf: allow multiple argument matching in filter

This looks like in nftables, e.g. `src { 127.0.0.1 192.168.1.1 }`

6 years agoRevert "nsrep: respect NO_THROTTLE for timeouted nameservers"
Marek Vavruša [Mon, 30 Apr 2018 19:33:50 +0000 (12:33 -0700)] 
Revert "nsrep: respect NO_THROTTLE for timeouted nameservers"

This reverts commit 573e552094f065471f34ebe26573095e47012050.

6 years agomodules/daf: case insensitive feature flags
Marek Vavruša [Sat, 28 Apr 2018 22:20:48 +0000 (15:20 -0700)] 
modules/daf: case insensitive feature flags

6 years agomodules/daf,renumber: fixed the modules and added tests
Marek Vavruša [Fri, 27 Apr 2018 06:27:33 +0000 (23:27 -0700)] 
modules/daf,renumber: fixed the modules and added tests

This fixes most of the rules in DAF that were broken in 2.0 and adds tests.
It also allows policy filter to evaluate policies in the checkout layer,
before the subrequest is sent to authoritative. This is used primarily for
negotiating features between resolver and authoritatives, or disabling transports.

The policy filter can now match on:
* NS suffix - to apply policies on any zone on given nameservers
* Query type

New actions:
* REFUSE - block query with an RCODE=REFUSED, fixes #337

The DAF can now toggle features between resolver and authoritatives.

fixes #322

6 years agolib/resolve: randomize qname in checkout layer when secret changes
Marek Vavruša [Fri, 27 Apr 2018 06:23:40 +0000 (23:23 -0700)] 
lib/resolve: randomize qname in checkout layer when secret changes

This allows changing of secret in the checkout layer.

6 years agodaemon/worker: move checkout layer before connect, catch checkout errors
Marek Vavruša [Fri, 27 Apr 2018 06:21:31 +0000 (23:21 -0700)] 
daemon/worker: move checkout layer before connect, catch checkout errors

The checkout layer was moved to where upstream address is known, but
before outbound message is sent (or connected to upstream).
The reason is to allow checkout layer to block outbound queries
without wasting time waiting for connect.

6 years agolib/utils: removed obsoleted functions
Marek Vavruša [Fri, 27 Apr 2018 06:20:14 +0000 (23:20 -0700)] 
lib/utils: removed obsoleted functions

Header flags can now be set from Lua, as well as packet payload clearing.

6 years agonsrep: respect NO_THROTTLE for timeouted nameservers
Marek Vavruša [Tue, 24 Apr 2018 23:11:16 +0000 (16:11 -0700)] 
nsrep: respect NO_THROTTLE for timeouted nameservers

6 years agoworker: fixed a mistakenly used pkt_buf instead of pkt
Marek Vavruša [Sat, 21 Apr 2018 07:12:03 +0000 (00:12 -0700)] 
worker: fixed a mistakenly used pkt_buf instead of pkt

The `pkt` is set to NULL above, but it's not used and `pkt_buf` is used instead,
it may point to an invalid packet and cause problems further down.

6 years agolib/generic/pack: fix operations on empty pack
Marek Vavruša [Fri, 20 Apr 2018 03:15:19 +0000 (20:15 -0700)] 
lib/generic/pack: fix operations on empty pack

Several operations were not safe to call on empty pack and would
return invalid memory. If the pack would have reserved space, but
would be empty (length = 0), it's head would be NULL but tail would
be array address (pack->at + 0). This is mostly checked by caller,
but it wasn't in several places (object deletion).

6 years agodefines: make retry limits compile time configurable
Marek Vavruša [Wed, 18 Apr 2018 22:51:05 +0000 (15:51 -0700)] 
defines: make retry limits compile time configurable

6 years agozonecut: fix kr_zonecut_find_nsname with the trie implementation
Marek Vavruša [Wed, 18 Apr 2018 22:43:06 +0000 (15:43 -0700)] 
zonecut: fix kr_zonecut_find_nsname with the trie implementation

6 years agolib/cache: removed assertion that causes server to crash on partial writes
Marek Vavruša [Fri, 13 Apr 2018 20:45:30 +0000 (13:45 -0700)] 
lib/cache: removed assertion that causes server to crash on partial writes

6 years agoiterate: fix minimisation downgrade when encountering authoritative referrals
Marek Vavruša [Thu, 12 Apr 2018 17:35:57 +0000 (10:35 -0700)] 
iterate: fix minimisation downgrade when encountering authoritative referrals

This fixes turning off minimisation when there's an authoritative referral
answer on the resolution path. This happens when there's a nameserver,
which is authoritative for both parent and child side of the delegation,
so it answers from the child side with AA=1. Such answer will be mistakenly
processed as authoritative, and QNAME minimisation will be turned off
(assuming this is the final zone cut).

6 years agonsrep: never blacklist NSs because of SERVFAIL/REFUSED
Marek Vavruša [Thu, 12 Apr 2018 08:35:50 +0000 (01:35 -0700)] 
nsrep: never blacklist NSs because of SERVFAIL/REFUSED

The SERVFAIL is a soft-failure, and REFUSED isn't something the server
is really in control of. It is easy to trick the resolver into blacklisting
a NS by creating a bad delegation and pointing it at the victim NS.

This changes the scoring function to degrade server score on these rcodes,
but cap it to a really bad score. It should be treated as timed out only
if it really times out or is unreachable.

6 years agoiterate: do not treat REFUSED as soft fail with retries
Marek Vavruša [Thu, 12 Apr 2018 08:32:34 +0000 (01:32 -0700)] 
iterate: do not treat REFUSED as soft fail with retries

REFUSED means the NS isn't authoritative for given zone, so it
shouldn't be treated like SERVFAIL. This fixes when a server is not
authoritative for given zone (failed transfer, bad delegation), and the
resolver enters into a retry loop and eventually runs out of time,
instead of trying different servers.

6 years agoupdated cache:insert_rr() interface with cache scope changes
Marek Vavruša [Thu, 12 Apr 2018 08:31:46 +0000 (01:31 -0700)] 
updated cache:insert_rr() interface with cache scope changes

6 years agoimplement basic infrastructure for scoped cache
Marek Vavruša [Tue, 10 Apr 2018 06:11:16 +0000 (23:11 -0700)] 
implement basic infrastructure for scoped cache

This commit adds support for scoped cache, e.g. keys can be tagged
with a scope, so that the same key can exist in multiple scope and
returns the value based on the scope set.

This is practically requires for scoping by subnet in ECS, but
it doesn't implement ECS completely. This is just a framework
to make something like ECS possible in a module.

The scope search is currently non-exhaustive, it either returns
a value bound to given scope or look into global scope, nothing
in between.

6 years agonetwork: make TCP_BACKLOG_DEFAULT a compile time define and set to default
Marek Vavruša [Fri, 6 Apr 2018 16:32:17 +0000 (09:32 -0700)] 
network: make TCP_BACKLOG_DEFAULT a compile time define and set to default

This was previously hardcoded to 16. This makes it at least a compile time
define, with a default of 511 (as that's what Redis and Apache use).

6 years agocheck per-query flags instead of global options, getter for NS name
Marek Vavruša [Fri, 6 Apr 2018 05:43:57 +0000 (22:43 -0700)] 
check per-query flags instead of global options, getter for NS name

Checking query flags instead of global context option allows setting
overrides on individual queries. The effect is the same as query flags
start by copying request flags which start by copying context options.

6 years agoadd bindings for the checkout layer
Marek Vavruša [Fri, 6 Apr 2018 05:48:51 +0000 (22:48 -0700)] 
add bindings for the checkout layer

This one was missing from the current bindings. The checkout layer
runs when the worker attempts to send a DNS query to given upstream
when the address is already determined. The layer can add EDNS options
or update outbound query, or block particular addresses / protocol.

6 years agolib/resolve: don't append EDNS to garbage packets
Marek Vavruša [Tue, 3 Apr 2018 21:04:32 +0000 (14:04 -0700)] 
lib/resolve: don't append EDNS to garbage packets

The current handler will try to construct the compression table
starting with query name in question. If there's no query name,
it's going to construct it with garbage bytes.

6 years agomodules/http: added an error handler to HTTP streams
Marek Vavruša [Mon, 2 Apr 2018 23:42:42 +0000 (16:42 -0700)] 
modules/http: added an error handler to HTTP streams

Instead of throwing an error in the HTTP handler, server should log it.
This covers errors like client disconnecting before reading the response
body etc.

6 years agoresolve: always update QNAME after zone cut update
Marek Vavruša [Sat, 24 Mar 2018 04:00:37 +0000 (21:00 -0700)] 
resolve: always update QNAME after zone cut update

Previously the code didn't update query if the minimization was turned off,
but that broke resolution for deep zones (like in-addr.arpa) when part of
the chain fell out of cache, and nearest zone cut was longer than
current query name. The condition is not necessary, since kr_make_query
already checks for query name minimisation flag.

6 years agohttp: allow loading custom endpoints to http
Marek Vavruša [Wed, 21 Mar 2018 22:57:19 +0000 (15:57 -0700)] 
http: allow loading custom endpoints to http

Previously the module was created on configuration time, so it wasn't
possible to inject custom endpoints to the default interface.

6 years agoRestore visibility for cache stats
anb [Mon, 5 Mar 2018 23:20:53 +0000 (15:20 -0800)] 
Restore visibility for cache stats

Add the missing stats for cache module, on RR entry level.

6 years agocache: changed get_new_ttl private API to allow custom timestamp
Marek Vavruša [Wed, 14 Mar 2018 19:10:46 +0000 (12:10 -0700)] 
cache: changed get_new_ttl private API to allow custom timestamp

Before the API depended on the qry object which only makes sense during
resolution of requests, not when manipulating cache out of it.

6 years agocache: restored kr_cache_insert_rr API
Marek Vavruša [Mon, 12 Mar 2018 04:04:19 +0000 (21:04 -0700)] 
cache: restored kr_cache_insert_rr API

This commit abstracts out stash_rrset from stash_rrarray_entry,
and fixes incrementing metrics on actual record insertion.
It then resurfaces kr_cache_insert_rr that was deleted in 2.0
using the extracted function.

6 years agoMerge !664: KNOT_MINVER: 2.7.1 -> 2.7.2
Vladimír Čunát [Tue, 4 Sep 2018 11:34:36 +0000 (11:34 +0000)] 
Merge !664: KNOT_MINVER: 2.7.1 -> 2.7.2

6 years agoRe-revert "kr_nsec_bitmap_contains_type(): moved to libdnssec"
Vladimír Čunát [Mon, 3 Sep 2018 12:43:02 +0000 (14:43 +0200)] 
Re-revert "kr_nsec_bitmap_contains_type(): moved to libdnssec"

This reverts commit 512f4aee63cbad71639d7865a8b9f5a3c32ffed2.
knot-dns-2.7.2 fixed this.

6 years agoMakefile: KNOT_MINVER 2.7.1 -> 2.7.2
Vladimír Čunát [Mon, 3 Sep 2018 12:44:28 +0000 (14:44 +0200)] 
Makefile: KNOT_MINVER 2.7.1 -> 2.7.2

6 years agoMerge branch 'ci-fix' into 'master'
Tomas Krizek [Mon, 3 Sep 2018 18:11:24 +0000 (18:11 +0000)] 
Merge branch 'ci-fix' into 'master'

ci: fixes

See merge request knot/knot-resolver!666

6 years agoci: docker/fedora - add knot-resolver-testing OBS repos to mock
Tomas Krizek [Mon, 3 Sep 2018 17:52:10 +0000 (19:52 +0200)] 
ci: docker/fedora - add knot-resolver-testing OBS repos to mock

6 years agoci: update respdiff configs
Tomas Krizek [Mon, 3 Sep 2018 16:53:25 +0000 (18:53 +0200)] 
ci: update respdiff configs

6 years agoMerge branch 'ci-rpm-builds' into 'master'
Tomas Krizek [Mon, 3 Sep 2018 15:15:32 +0000 (15:15 +0000)] 
Merge branch 'ci-rpm-builds' into 'master'

ci: rpm builds

See merge request knot/knot-resolver!665

6 years agoci: docker/fedora - add OBS to EPEL7 mock
Tomas Krizek [Mon, 3 Sep 2018 14:59:37 +0000 (16:59 +0200)] 
ci: docker/fedora - add OBS to EPEL7 mock

6 years agoci: docker/fedora update to F29
Tomas Krizek [Mon, 3 Sep 2018 14:58:54 +0000 (16:58 +0200)] 
ci: docker/fedora update to F29

6 years agoMerge !663: ci: optimize respdiff
Vladimír Čunát [Mon, 3 Sep 2018 10:25:55 +0000 (10:25 +0000)] 
Merge !663: ci: optimize respdiff

6 years agoci: optimize respdiff
Tomas Krizek [Mon, 3 Sep 2018 10:25:55 +0000 (10:25 +0000)] 
ci: optimize respdiff

6 years agoMerge !650: misc nitpicks (see commits)
Vladimír Čunát [Mon, 3 Sep 2018 10:12:51 +0000 (10:12 +0000)] 
Merge !650: misc nitpicks (see commits)

6 years agomisc nitpicks (see commits)
Vladimír Čunát [Mon, 3 Sep 2018 10:12:51 +0000 (10:12 +0000)] 
misc nitpicks (see commits)

6 years agoMerge branch 'ci-update-respdiff-jobs' into 'master'
Tomas Krizek [Tue, 28 Aug 2018 12:50:43 +0000 (12:50 +0000)] 
Merge branch 'ci-update-respdiff-jobs' into 'master'

ci: update respdiff jobs

See merge request knot/knot-resolver!661

6 years agoci: update respdiff jobs
Tomas Krizek [Tue, 28 Aug 2018 11:21:53 +0000 (13:21 +0200)] 
ci: update respdiff jobs

6 years agoMerge branch 'ci-respdiff-stats' into 'master'
Tomas Krizek [Mon, 27 Aug 2018 11:11:23 +0000 (11:11 +0000)] 
Merge branch 'ci-respdiff-stats' into 'master'

ci: improve respdiff jobs

See merge request knot/knot-resolver!659

6 years agoci: respdiff - add option to force respdiff execution
Tomas Krizek [Thu, 23 Aug 2018 15:33:58 +0000 (17:33 +0200)] 
ci: respdiff - add option to force respdiff execution

6 years agoci: respdiff - use statcmp to plot graphs
Tomas Krizek [Wed, 22 Aug 2018 15:38:54 +0000 (17:38 +0200)] 
ci: respdiff - use statcmp to plot graphs