Remi Gacogne [Mon, 8 Feb 2016 11:38:59 +0000 (12:38 +0100)]
dnsdist: Add an optional reuseport param to {add,set}Local()
If set to true, this parameter sets SO_REUSEPORT on platforms
supporting for this option, allowing multiple servers to
bind to the same port.
The same parameter is also added to addDNSCryptBind().
Remi Gacogne [Thu, 25 Feb 2016 17:58:46 +0000 (18:58 +0100)]
dnsdist: Fix str-only server not being added to the default pool
As reported by @pieterlexis, server defined with the "string-only"
syntax were not correctly added to the default pool. This should
fix #3456.
In addition to that, this commit adds some Lua bindings for server
objects:
- member functions `getName()` and `getNameWithAddr()`
- member data `name`
Remi Gacogne [Thu, 25 Feb 2016 16:51:24 +0000 (17:51 +0100)]
dnsdist: Fix cache tests. Clean tests backends.
Several issues:
- the cache tests used a vey small cache, not large enough for the
number of responses we expected to cache during the test suite
- this was hidden by the default response from the backends
matching what the test expected
- and by the backends not counting properly what looked like a
health check but wasn't.
Remi Gacogne [Thu, 25 Feb 2016 14:46:22 +0000 (15:46 +0100)]
dnsdist: Prevent the cache ptr from being altered under our feet
Make sure we hold the Lua mutex before getting the packet cache
shared_ptr, so that we don't have a thread reading it at the
exact same time it is altered by another.
We could have used atomic_load/atomic_store but libstdc++ uses
a pool of mutex for that anyway.
This might fix #3396.
bert hubert [Thu, 25 Feb 2016 12:03:29 +0000 (13:03 +0100)]
this commit uglifies DNSName escaped representation parsing for tremendous speedup (2x) during bulk zone loading from disk or database.
Part of the uglification is that we now special case unescaped names, which are the vast majority of cases.
Simultaneously, this moves us back to DNSName boost::container::string on non-Apple platforms, which delivered another 15% speedup on general operations
Finally, an additional unit test is added.
Remi Gacogne [Wed, 24 Feb 2016 16:13:14 +0000 (17:13 +0100)]
recursor: Move replaced cached entries to the back
When we replace an existing entry, it keeps its existing place in
the expunge queue, while new entries are inserted to the back and
hits are moved to the back.
Moving replaced entries to the back of the queue is more fair and
so probably more efficient, as it would increase the likelihood of
expunging unused expired entries from the cache.
bert hubert [Wed, 24 Feb 2016 15:36:44 +0000 (16:36 +0100)]
we were inconsistent in comparing ComboAddresses with sin_family==0. Removed possibility for inconsistency, plus surrounded this bug with unit tests. Added similar test for DNSName.
Andrew Nelless [Wed, 24 Feb 2016 15:10:22 +0000 (15:10 +0000)]
Switch from std::function to boost::function
GNUs implementation of std::function can't eat 3 pointers without allocating,
(24 bytes) whereas both LLVM libc++ and boost::function can. boost::function
has been move enabled since 1.52 (Nov 2012).
Remi Gacogne [Mon, 22 Feb 2016 18:22:55 +0000 (19:22 +0100)]
dnsdist: Check that the answer matches the initial query over UDP
If we wrap around our maxOutstanding counter too fast, we need
to check that the answer we get is for the right query.
In order to do that, we now parse the question section in the
response and compare it to the one we expect (type, class and
name).
Andrew Nelless [Fri, 19 Feb 2016 15:25:03 +0000 (15:25 +0000)]
Massage System V context switching out of MTasker
Let's yank all the System-V ucontext switching out of MTasker, massaging it
in to a an implementation neutral, hopefully trivial, pdns_* API.
Stack management and context chaining (similar to ucontexts 'uc_link') are
left exposed, but the implementation is type-erased (void*'d), to force a
clean break. This currently introduces an extra allocation, which hopefully
won't matter once an alternative backend is in place, but means all the
threadWrapper guff can be hidden away.
At the same time, all manual memory management has been removed, with
MThread stacks now being allocated via std::vector with a "lazy_allocator"
which eliminates needless zero-initialization. (Which, compared to a context
switch, is actually quite expensive: diddling 8192 bytes takes ~500ns over
~15 GB/s of memory bandwidth).
pdns_makecontext now takes a std::function object by reference, which must
live until the MThread is started with pdns_swapcontext, at which point it is
std::move'd on to the MThreads stack and can go away. This means a task can
never be started twice (because std::function be empty and throw). I think using
std::function could simplify recursor code, but atm the MTasker makeThread() API
has been left as-is. In MTasker, the MThread start routine is stashed in
ThreadInfo, which also owns the context jointly (via std::shared_ptr) with
any waiters. std::function shouldn't introduce any allocations when used with
trivial function pointers.
In addition, exceptions can hopefully now propagate safely from MThreads
back up to, and through, schedule(), thanks to C++11s exception_ptr.
splitPointer/joinPtr, required to deal with SysVss hairy API, has also been
reimplemented, because master currently still passes one pointer, which only
works on 64-bit thanks to a GNU extension. The new implementation, despite
using memcpy and looking verbose, still compiles down to 2-4 CPU instructions
on each side under GCC -O2, and doesn't depend on any undefined behaviour.