2018-08-07 16:46:53 +02:00
|
|
|
include $(top_srcdir)/Makefile.top
|
|
|
|
|
|
|
|
lib_LTLIBRARIES = libisc.la
|
|
|
|
|
|
|
|
libisc_ladir = $(includedir)/isc
|
|
|
|
libisc_la_HEADERS = \
|
|
|
|
include/isc/aes.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/align.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/app.h \
|
|
|
|
include/isc/assertions.h \
|
|
|
|
include/isc/astack.h \
|
|
|
|
include/isc/atomic.h \
|
|
|
|
include/isc/attributes.h \
|
|
|
|
include/isc/backtrace.h \
|
2021-05-05 11:51:39 +02:00
|
|
|
include/isc/barrier.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/base32.h \
|
|
|
|
include/isc/base64.h \
|
|
|
|
include/isc/bind9.h \
|
|
|
|
include/isc/buffer.h \
|
2020-09-02 18:22:21 +10:00
|
|
|
include/isc/cmocka.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/commandline.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/condition.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/counter.h \
|
|
|
|
include/isc/crc64.h \
|
|
|
|
include/isc/deprecated.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/dir.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/endian.h \
|
|
|
|
include/isc/errno.h \
|
|
|
|
include/isc/error.h \
|
|
|
|
include/isc/event.h \
|
|
|
|
include/isc/eventclass.h \
|
|
|
|
include/isc/file.h \
|
|
|
|
include/isc/formatcheck.h \
|
|
|
|
include/isc/fsaccess.h \
|
|
|
|
include/isc/fuzz.h \
|
|
|
|
include/isc/glob.h \
|
|
|
|
include/isc/hash.h \
|
|
|
|
include/isc/heap.h \
|
|
|
|
include/isc/hex.h \
|
|
|
|
include/isc/hmac.h \
|
|
|
|
include/isc/hp.h \
|
|
|
|
include/isc/ht.h \
|
|
|
|
include/isc/httpd.h \
|
|
|
|
include/isc/interfaceiter.h \
|
|
|
|
include/isc/iterated_hash.h \
|
|
|
|
include/isc/lang.h \
|
|
|
|
include/isc/lex.h \
|
|
|
|
include/isc/likely.h \
|
|
|
|
include/isc/list.h \
|
|
|
|
include/isc/log.h \
|
|
|
|
include/isc/magic.h \
|
2021-04-27 00:07:43 +02:00
|
|
|
include/isc/managers.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/md.h \
|
|
|
|
include/isc/mem.h \
|
|
|
|
include/isc/meminfo.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/mutex.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/mutexblock.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/net.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/netaddr.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/netdb.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/netmgr.h \
|
|
|
|
include/isc/netscope.h \
|
|
|
|
include/isc/nonce.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/offset.h \
|
|
|
|
include/isc/once.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/os.h \
|
|
|
|
include/isc/parseint.h \
|
|
|
|
include/isc/pool.h \
|
|
|
|
include/isc/portset.h \
|
|
|
|
include/isc/print.h \
|
|
|
|
include/isc/queue.h \
|
|
|
|
include/isc/quota.h \
|
|
|
|
include/isc/radix.h \
|
|
|
|
include/isc/random.h \
|
|
|
|
include/isc/ratelimiter.h \
|
|
|
|
include/isc/refcount.h \
|
|
|
|
include/isc/regex.h \
|
|
|
|
include/isc/region.h \
|
|
|
|
include/isc/resource.h \
|
|
|
|
include/isc/result.h \
|
|
|
|
include/isc/rwlock.h \
|
|
|
|
include/isc/safe.h \
|
|
|
|
include/isc/serial.h \
|
|
|
|
include/isc/siphash.h \
|
|
|
|
include/isc/sockaddr.h \
|
|
|
|
include/isc/socket.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/stat.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/stats.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/stdatomic.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/stdio.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/stdtime.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/strerr.h \
|
|
|
|
include/isc/string.h \
|
|
|
|
include/isc/symtab.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/syslog.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/task.h \
|
|
|
|
include/isc/taskpool.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/thread.h \
|
|
|
|
include/isc/time.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/timer.h \
|
2020-12-17 11:40:29 +01:00
|
|
|
include/isc/tls.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
include/isc/tm.h \
|
|
|
|
include/isc/types.h \
|
2020-10-31 20:42:18 +01:00
|
|
|
include/isc/url.h \
|
2020-05-11 14:44:23 +10:00
|
|
|
include/isc/utf8.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
include/isc/util.h
|
2018-08-07 16:46:53 +02:00
|
|
|
|
|
|
|
libisc_la_SOURCES = \
|
|
|
|
$(libisc_la_HEADERS) \
|
|
|
|
netmgr/netmgr-int.h \
|
|
|
|
netmgr/netmgr.c \
|
|
|
|
netmgr/tcp.c \
|
|
|
|
netmgr/tcpdns.c \
|
Refactor netmgr and add more unit tests
This is a part of the works that intends to make the netmgr stable,
testable, maintainable and tested. It contains a numerous changes to
the netmgr code and unfortunately, it was not possible to split this
into smaller chunks as the work here needs to be committed as a complete
works.
NOTE: There's a quite a lot of duplicated code between udp.c, tcp.c and
tcpdns.c and it should be a subject to refactoring in the future.
The changes that are included in this commit are listed here
(extensively, but not exclusively):
* The netmgr_test unit test was split into individual tests (udp_test,
tcp_test, tcpdns_test and newly added tcp_quota_test)
* The udp_test and tcp_test has been extended to allow programatic
failures from the libuv API. Unfortunately, we can't use cmocka
mock() and will_return(), so we emulate the behaviour with #define and
including the netmgr/{udp,tcp}.c source file directly.
* The netievents that we put on the nm queue have variable number of
members, out of these the isc_nmsocket_t and isc_nmhandle_t always
needs to be attached before enqueueing the netievent_<foo> and
detached after we have called the isc_nm_async_<foo> to ensure that
the socket (handle) doesn't disappear between scheduling the event and
actually executing the event.
* Cancelling the in-flight TCP connection using libuv requires to call
uv_close() on the original uv_tcp_t handle which just breaks too many
assumptions we have in the netmgr code. Instead of using uv_timer for
TCP connection timeouts, we use platform specific socket option.
* Fix the synchronization between {nm,async}_{listentcp,tcpconnect}
When isc_nm_listentcp() or isc_nm_tcpconnect() is called it was
waiting for socket to either end up with error (that path was fine) or
to be listening or connected using condition variable and mutex.
Several things could happen:
0. everything is ok
1. the waiting thread would miss the SIGNAL() - because the enqueued
event would be processed faster than we could start WAIT()ing.
In case the operation would end up with error, it would be ok, as
the error variable would be unchanged.
2. the waiting thread miss the sock->{connected,listening} = `true`
would be set to `false` in the tcp_{listen,connect}close_cb() as
the connection would be so short lived that the socket would be
closed before we could even start WAIT()ing
* The tcpdns has been converted to using libuv directly. Previously,
the tcpdns protocol used tcp protocol from netmgr, this proved to be
very complicated to understand, fix and make changes to. The new
tcpdns protocol is modeled in a similar way how tcp netmgr protocol.
Closes: #2194, #2283, #2318, #2266, #2034, #1920
* The tcp and tcpdns is now not using isc_uv_import/isc_uv_export to
pass accepted TCP sockets between netthreads, but instead (similar to
UDP) uses per netthread uv_loop listener. This greatly reduces the
complexity as the socket is always run in the associated nm and uv
loops, and we are also not touching the libuv internals.
There's an unfortunate side effect though, the new code requires
support for load-balanced sockets from the operating system for both
UDP and TCP (see #2137). If the operating system doesn't support the
load balanced sockets (either SO_REUSEPORT on Linux or SO_REUSEPORT_LB
on FreeBSD 12+), the number of netthreads is limited to 1.
* The netmgr has now two debugging #ifdefs:
1. Already existing NETMGR_TRACE prints any dangling nmsockets and
nmhandles before triggering assertion failure. This options would
reduce performance when enabled, but in theory, it could be enabled
on low-performance systems.
2. New NETMGR_TRACE_VERBOSE option has been added that enables
extensive netmgr logging that allows the software engineer to
precisely track any attach/detach operations on the nmsockets and
nmhandles. This is not suitable for any kind of production
machine, only for debugging.
* The tlsdns netmgr protocol has been split from the tcpdns and it still
uses the old method of stacking the netmgr boxes on top of each other.
We will have to refactor the tlsdns netmgr protocol to use the same
approach - build the stack using only libuv and openssl.
* Limit but not assert the tcp buffer size in tcp_alloc_cb
Closes: #2061
2020-11-12 10:32:18 +01:00
|
|
|
netmgr/tlsdns.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
netmgr/udp.c \
|
|
|
|
netmgr/uv-compat.c \
|
|
|
|
netmgr/uv-compat.h \
|
|
|
|
netmgr/uverr2result.c \
|
|
|
|
aes.c \
|
|
|
|
app.c \
|
|
|
|
assertions.c \
|
|
|
|
astack.c \
|
|
|
|
backtrace.c \
|
|
|
|
base32.c \
|
|
|
|
base64.c \
|
|
|
|
bind9.c \
|
|
|
|
buffer.c \
|
|
|
|
commandline.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
condition.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
counter.c \
|
|
|
|
crc64.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
dir.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
entropy.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
entropy_private.h \
|
|
|
|
errno.c \
|
|
|
|
errno2result.c \
|
|
|
|
errno2result.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
error.c \
|
|
|
|
event.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
file.c \
|
|
|
|
fsaccess.c \
|
2020-06-05 13:19:49 +02:00
|
|
|
fsaccess_common.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
fsaccess_common_p.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
glob.c \
|
|
|
|
hash.c \
|
|
|
|
heap.c \
|
|
|
|
hex.c \
|
|
|
|
hmac.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
hp.c \
|
|
|
|
ht.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
httpd.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
interfaceiter.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
iterated_hash.c \
|
Use system allocator when jemalloc is unavailable
This commit adds support for systems where the jemalloc library is not
available as a package, here's the quick summary:
* On Linux - the jemalloc is usually available as a package, if
configured --without-jemalloc, the shim would be used around
malloc(), free(), realloc() and malloc_usable_size()
* On macOS - the jemalloc is available from homebrew or macports, if
configured --without-jemalloc, the shim would be used around
malloc(), free(), realloc() and malloc_size()
* On FreeBSD - the jemalloc is *the* system allocator, we just need
to check for <malloc_np.h> header to get access to non-standard API
* On NetBSD - the jemalloc is *the* system allocator, we just need to
check for <jemalloc/jemalloc.h> header to get access to non-standard
API
* On a system hostile to users and developers (read OpenBSD) - the
jemalloc API is emulated by using ((size_t *)ptr)[-1] field to hold
the size information. The OpenBSD developers care only for
themselves, so why should we care about speed on OpenBSD?
2021-05-25 12:46:00 +02:00
|
|
|
jemalloc_shim.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
lex.c \
|
|
|
|
lib.c \
|
|
|
|
log.c \
|
2021-04-27 00:07:43 +02:00
|
|
|
managers.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
md.c \
|
|
|
|
mem.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
mem_p.h \
|
|
|
|
meminfo.c \
|
|
|
|
mutex.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
mutexblock.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
net.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
netaddr.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
netmgr_p.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
netscope.c \
|
|
|
|
nonce.c \
|
|
|
|
openssl_shim.c \
|
|
|
|
openssl_shim.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
os.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
parseint.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
pool.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
portset.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
queue.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
quota.c \
|
|
|
|
radix.c \
|
|
|
|
random.c \
|
|
|
|
ratelimiter.c \
|
|
|
|
regex.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
region.c \
|
|
|
|
resource.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
result.c \
|
|
|
|
rwlock.c \
|
|
|
|
safe.c \
|
|
|
|
serial.c \
|
|
|
|
siphash.c \
|
|
|
|
sockaddr.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
socket.c \
|
|
|
|
socket_p.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
stats.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
stdio.c \
|
|
|
|
stdtime.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
string.c \
|
|
|
|
symtab.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
syslog.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
task.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
task_p.h \
|
2018-08-07 16:46:53 +02:00
|
|
|
taskpool.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
thread.c \
|
|
|
|
time.c \
|
2018-08-07 16:46:53 +02:00
|
|
|
timer.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
timer_p.h \
|
2020-12-17 11:40:29 +01:00
|
|
|
tls.c \
|
2021-05-20 15:53:50 +02:00
|
|
|
tls_p.h \
|
|
|
|
tm.c \
|
2021-02-16 15:57:39 +01:00
|
|
|
trampoline.c \
|
|
|
|
trampoline_p.h \
|
2021-05-20 15:53:50 +02:00
|
|
|
url.c \
|
|
|
|
utf8.c
|
2018-08-07 16:46:53 +02:00
|
|
|
|
|
|
|
libisc_la_CPPFLAGS = \
|
|
|
|
$(AM_CPPFLAGS) \
|
2021-05-11 12:29:57 +02:00
|
|
|
$(JEMALLOC_CPPFLAGS) \
|
2018-08-07 16:46:53 +02:00
|
|
|
$(LIBISC_CFLAGS) \
|
|
|
|
$(LIBUV_CFLAGS) \
|
|
|
|
$(OPENSSL_CFLAGS) \
|
|
|
|
$(ZLIB_CFLAGS)
|
|
|
|
|
|
|
|
libisc_la_LDFLAGS = \
|
2020-09-28 09:09:21 +02:00
|
|
|
$(AM_LDFLAGS) \
|
2021-01-12 13:38:44 +01:00
|
|
|
-release "$(PACKAGE_VERSION)"
|
2018-08-07 16:46:53 +02:00
|
|
|
|
|
|
|
libisc_la_LIBADD = \
|
2021-05-11 12:29:57 +02:00
|
|
|
$(JEMALLOC_LIBS) \
|
2018-08-07 16:46:53 +02:00
|
|
|
$(LIBUV_LIBS) \
|
|
|
|
$(OPENSSL_LIBS) \
|
|
|
|
$(ZLIB_LIBS)
|
|
|
|
|
2021-04-21 13:52:15 +02:00
|
|
|
if HAVE_LIBNGHTTP2
|
|
|
|
libisc_la_SOURCES += \
|
|
|
|
netmgr/http.c \
|
|
|
|
netmgr/tlsstream.c
|
|
|
|
|
|
|
|
libisc_la_CPPFLAGS += \
|
|
|
|
$(LIBNGHTTP2_CFLAGS)
|
|
|
|
|
|
|
|
libisc_la_LIBADD += \
|
|
|
|
$(LIBNGHTTP2_LIBS)
|
|
|
|
endif
|
|
|
|
|
2018-08-07 16:46:53 +02:00
|
|
|
if HAVE_JSON_C
|
|
|
|
libisc_la_CPPFLAGS += \
|
|
|
|
$(JSON_C_CFLAGS)
|
|
|
|
|
|
|
|
libisc_la_LIBADD += \
|
|
|
|
$(JSON_C_LIBS)
|
|
|
|
endif HAVE_JSON_C
|
|
|
|
|
|
|
|
if HAVE_LIBXML2
|
|
|
|
libisc_la_CPPFLAGS += \
|
|
|
|
$(LIBXML2_CFLAGS)
|
|
|
|
|
|
|
|
libisc_la_LIBADD += \
|
|
|
|
$(LIBXML2_LIBS)
|
|
|
|
endif HAVE_LIBXML2
|
|
|
|
|
|
|
|
if HAVE_CMOCKA
|
|
|
|
SUBDIRS = tests
|
|
|
|
endif
|