Skip to content

Commit fd40cb5

Browse files
committed
dnsdist: master port for openwrt 19.07, with uci and odhcpd integration
Signed-off-by: Peter van Dijk <peter.van.dijk@powerdns.com>
1 parent e6ecebb commit fd40cb5

35 files changed

Lines changed: 2878 additions & 135 deletions

.github/workflows/multi-arch-test-build.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,10 @@ jobs:
1111
fail-fast: false
1212
matrix:
1313
arch:
14-
- arc_archs
1514
- arm_cortex-a9_vfpv3-d16
1615
- mips_24kc
17-
- powerpc_464fp
18-
- powerpc_8540
1916
runtime_test: [false]
2017
include:
21-
- arch: aarch64_cortex-a53
22-
runtime_test: true
23-
- arch: arm_cortex-a15_neon-vfpv4
24-
runtime_test: true
2518
- arch: x86_64
2619
runtime_test: true
2720

libs/h2o-tiny/Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
include $(TOPDIR)/rules.mk
2+
3+
PKG_NAME:=h2o
4+
PKG_VERSION:=2.2.6
5+
PKG_RELEASE:=$(AUTORELEASE)
6+
7+
PKG_SOURCE_URL:=https://codeload.github.com/h2o/h2o/tar.gz/v${PKG_VERSION}?
8+
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
9+
PKG_HASH:=f8cbc1b530d85ff098f6efc2c3fdbc5e29baffb30614caac59d5c710f7bda201
10+
11+
PKG_MAINTAINER:=Peter van Dijk <peter.van.dijk@powerdns.com>
12+
PKG_LICENSE:=MIT
13+
PKG_LICENSE_FILES:=LICENSE
14+
15+
include $(INCLUDE_DIR)/package.mk
16+
include $(INCLUDE_DIR)/cmake.mk
17+
18+
CMAKE_OPTIONS += \
19+
-DBUILD_SHARED_LIBS=ON \
20+
-DWITH_MRUBY=OFF
21+
22+
define Package/libh2o-evloop-tiny
23+
SECTION:=libs
24+
CATEGORY:=Libraries
25+
TITLE:=H2O Library compiled with its own event loop
26+
URL:=https://h2o.examp1e.net/
27+
DEPENDS:=+libopenssl +zlib
28+
endef
29+
30+
define Package/libh2o-tiny
31+
SECTION:=libs
32+
CATEGORY:=Libraries
33+
TITLE:=H2O Library compiled with libuv
34+
URL:=https://h2o.examp1e.net/
35+
DEPENDS:=+libuv +libopenssl +zlib +libyaml
36+
endef
37+
38+
define Build/InstallDev
39+
$(call Build/InstallDev/cmake,$(1))
40+
$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libh2o-evloop.pc
41+
$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libh2o-evloop.pc
42+
$(SED) 's,/usr/include,$$$${prefix}/include,g' $(1)/usr/lib/pkgconfig/libh2o.pc
43+
$(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' $(1)/usr/lib/pkgconfig/libh2o.pc
44+
endef
45+
46+
define Package/libh2o-evloop-tiny/install
47+
$(INSTALL_DIR) $(1)/usr/lib
48+
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libh2o-evloop.so* $(1)/usr/lib/
49+
endef
50+
51+
define Package/libh2o-tiny/install
52+
$(INSTALL_DIR) $(1)/usr/lib
53+
$(CP) $(PKG_INSTALL_DIR)/usr/lib/libh2o.so* $(1)/usr/lib/
54+
endef
55+
56+
$(eval $(call BuildPackage,libh2o-evloop-tiny))
57+
$(eval $(call BuildPackage,libh2o-tiny))
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--- a/include/h2o/socket.h
2+
+++ b/include/h2o/socket.h
3+
@@ -29,6 +29,7 @@ extern "C" {
4+
#include <stdint.h>
5+
#include <sys/socket.h>
6+
#include <openssl/ssl.h>
7+
+#include <openssl/opensslconf.h>
8+
#include "h2o/cache.h"
9+
#include "h2o/memory.h"
10+
#include "h2o/openssl_backport.h"
11+
@@ -44,7 +45,11 @@ extern "C" {
12+
13+
#if OPENSSL_VERSION_NUMBER >= 0x10002000L
14+
#define H2O_USE_ALPN 1
15+
+#ifndef OPENSSL_NO_NEXTPROTONEG
16+
#define H2O_USE_NPN 1
17+
+#else
18+
+#define H2O_USE_NPN 0
19+
+#endif
20+
#elif OPENSSL_VERSION_NUMBER >= 0x10001000L
21+
#define H2O_USE_ALPN 0
22+
#define H2O_USE_NPN 1
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From f7d5cb83826c7e2b1a3dc618b434d85df130a4d5 Mon Sep 17 00:00:00 2001
2+
From: James Taylor <james@jtaylor.id.au>
3+
Date: Tue, 10 Dec 2019 21:58:45 +1100
4+
Subject: [PATCH] Explicitly link against WSLAY when available
5+
6+
When other libraries attempt to link against libh2o and libh2o-evloop that was
7+
compiled with libwslay available, there are errors from missing symbols
8+
associated with code which makes use of the wslay library. To rectify this,
9+
explicitly link against libwslay during the build process.
10+
11+
Fixes #2105
12+
13+
Signed-off-by: James Taylor <james@jtaylor.id.au>
14+
---
15+
CMakeLists.txt | 12 ++++++++++--
16+
1 file changed, 10 insertions(+), 2 deletions(-)
17+
18+
--- a/CMakeLists.txt
19+
+++ b/CMakeLists.txt
20+
@@ -386,13 +386,21 @@ SET_TARGET_PROPERTIES(libh2o PROPERTIES
21+
OUTPUT_NAME h2o
22+
VERSION ${LIBRARY_VERSION}
23+
SOVERSION ${LIBRARY_SOVERSION})
24+
-TARGET_LINK_LIBRARIES(libh2o ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
25+
+IF (WSLAY_FOUND)
26+
+ TARGET_LINK_LIBRARIES(libh2o ${WSLAY_LIBRARIES} ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
27+
+ELSE ()
28+
+ TARGET_LINK_LIBRARIES(libh2o ${LIBUV_LIBRARIES} ${EXTRA_LIBS})
29+
+ENDIF (WSLAY_FOUND)
30+
SET_TARGET_PROPERTIES(libh2o-evloop PROPERTIES
31+
OUTPUT_NAME h2o-evloop
32+
COMPILE_FLAGS "-DH2O_USE_LIBUV=0"
33+
VERSION ${LIBRARY_VERSION}
34+
SOVERSION ${LIBRARY_SOVERSION})
35+
-TARGET_LINK_LIBRARIES(libh2o-evloop ${EXTRA_LIBS})
36+
+IF (WSLAY_FOUND)
37+
+ TARGET_LINK_LIBRARIES(libh2o-evloop ${WSLAY_LIBRARIES} ${EXTRA_LIBS})
38+
+ELSE ()
39+
+ TARGET_LINK_LIBRARIES(libh2o-evloop ${EXTRA_LIBS})
40+
+ENDIF (WSLAY_FOUND)
41+
42+
IF (OPENSSL_FOUND)
43+
TARGET_INCLUDE_DIRECTORIES(libh2o PUBLIC ${OPENSSL_INCLUDE_DIR})
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--- a/deps/picotls/include/picotls/openssl.h
2+
+++ b/deps/picotls/include/picotls/openssl.h
3+
@@ -26,11 +26,14 @@
4+
#include <openssl/evp.h>
5+
#include <openssl/hmac.h>
6+
#include <openssl/x509.h>
7+
+#include <openssl/opensslconf.h>
8+
#include "../picotls.h"
9+
10+
#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
11+
+#if !defined(OPENSSL_NO_CHACHA) && !defined(OPENSSL_NO_POLY1305)
12+
#define PTLS_OPENSSL_HAVE_CHACHA20_POLY1305
13+
#endif
14+
+#endif
15+
16+
extern ptls_key_exchange_algorithm_t ptls_openssl_secp256r1;
17+
extern ptls_key_exchange_algorithm_t *ptls_openssl_key_exchanges[];
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
From 03dbd6757d043581b5d250107b6f1cda6ae203a9 Mon Sep 17 00:00:00 2001
2+
From: Frederik Deweerdt <fdeweerdt@fastly.com>
3+
Date: Wed, 25 Oct 2017 13:52:28 -0700
4+
Subject: [PATCH] Autodetect backtrace and backtrace_symbols_fd
5+
6+
---
7+
CMakeLists.txt | 13 +++++++++++++
8+
src/main.c | 10 ++++++----
9+
2 files changed, 19 insertions(+), 4 deletions(-)
10+
11+
--- a/CMakeLists.txt
12+
+++ b/CMakeLists.txt
13+
@@ -58,6 +58,19 @@ __sync_add_and_fetch(&a, 1);
14+
return 0;
15+
}" ARCH_SUPPORTS_64BIT_ATOMICS)
16+
17+
+CHECK_C_SOURCE_COMPILES("
18+
+#include <execinfo.h>
19+
+int main(void) {
20+
+void *p[10];
21+
+int ret = backtrace(p, 10);
22+
+backtrace_symbols_fd(p, ret, 2);
23+
+return 0;
24+
+}" LIBC_HAS_BACKTRACE)
25+
+
26+
+IF (LIBC_HAS_BACKTRACE)
27+
+ ADD_DEFINITIONS("-DLIBC_HAS_BACKTRACE")
28+
+ENDIF ()
29+
+
30+
SET(WITH_BUNDLED_SSL_DEFAULT "ON")
31+
IF ((NOT UNIX) OR CYGWIN)
32+
SET(WITH_BUNDLED_SSL_DEFAULT "OFF")
33+
--- a/src/main.c
34+
+++ b/src/main.c
35+
@@ -48,7 +48,7 @@
36+
#include <openssl/crypto.h>
37+
#include <openssl/err.h>
38+
#include <openssl/ssl.h>
39+
-#ifdef __GLIBC__
40+
+#ifdef LIBC_HAS_BACKTRACE
41+
#include <execinfo.h>
42+
#endif
43+
#if H2O_USE_PICOTLS
44+
@@ -1436,7 +1436,8 @@ static void on_sigterm(int signo)
45+
notify_all_threads();
46+
}
47+
48+
-#ifdef __GLIBC__
49+
+#ifdef LIBC_HAS_BACKTRACE
50+
+
51+
static int popen_crash_handler(void)
52+
{
53+
char *cmd_fullpath = h2o_configurator_get_cmd_path(conf.crash_handler), *argv[] = {cmd_fullpath, NULL};
54+
@@ -1488,13 +1489,14 @@ static void on_sigfatal(int signo)
55+
56+
raise(signo);
57+
}
58+
-#endif
59+
+
60+
+#endif /* LIBC_HAS_BACKTRACE */
61+
62+
static void setup_signal_handlers(void)
63+
{
64+
h2o_set_signal_handler(SIGTERM, on_sigterm);
65+
h2o_set_signal_handler(SIGPIPE, SIG_IGN);
66+
-#ifdef __GLIBC__
67+
+#ifdef LIBC_HAS_BACKTRACE
68+
if ((crash_handler_fd = popen_crash_handler()) == -1)
69+
crash_handler_fd = 2;
70+
h2o_set_signal_handler(SIGABRT, on_sigfatal);
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
--- a/deps/neverbleed/neverbleed.c
2+
+++ b/deps/neverbleed/neverbleed.c
3+
@@ -36,6 +36,7 @@
4+
#include <sys/types.h>
5+
#include <sys/uio.h>
6+
#include <unistd.h>
7+
+#include <openssl/engine.h>
8+
#include <openssl/rand.h>
9+
#include <openssl/ssl.h>
10+
#include <openssl/rsa.h>
11+
--- a/deps/picotls/lib/openssl.c
12+
+++ b/deps/picotls/lib/openssl.c
13+
@@ -36,6 +36,7 @@
14+
#include <openssl/evp.h>
15+
#include <openssl/objects.h>
16+
#include <openssl/rand.h>
17+
+#include <openssl/rsa.h>
18+
#include <openssl/x509.h>
19+
#include <openssl/x509v3.h>
20+
#include <openssl/x509_vfy.h>
21+
@@ -941,7 +942,7 @@ int ptls_openssl_encrypt_ticket(ptls_buf
22+
23+
Exit:
24+
if (cctx != NULL)
25+
- EVP_CIPHER_CTX_cleanup(cctx);
26+
+ EVP_CIPHER_CTX_reset(cctx);
27+
if (hctx != NULL)
28+
HMAC_CTX_free(hctx);
29+
return ret;
30+
@@ -1011,7 +1012,7 @@ int ptls_openssl_decrypt_ticket(ptls_buf
31+
32+
Exit:
33+
if (cctx != NULL)
34+
- EVP_CIPHER_CTX_cleanup(cctx);
35+
+ EVP_CIPHER_CTX_reset(cctx);
36+
if (hctx != NULL)
37+
HMAC_CTX_free(hctx);
38+
return ret;
39+
--- a/src/main.c
40+
+++ b/src/main.c
41+
@@ -45,6 +45,7 @@
42+
#include <sys/types.h>
43+
#include <sys/un.h>
44+
#include <sys/wait.h>
45+
+#include <openssl/dh.h>
46+
#include <openssl/crypto.h>
47+
#include <openssl/err.h>
48+
#include <openssl/ssl.h>
49+
@@ -1827,7 +1828,7 @@ static h2o_iovec_t on_extra_status(void
50+
" \"listeners\": %zu,\n"
51+
" \"worker-threads\": %zu,\n"
52+
" \"num-sessions\": %lu",
53+
- SSLeay_version(SSLEAY_VERSION), current_time, restart_time, (uint64_t)(now - conf.launch_time), generation,
54+
+ OpenSSL_version(OPENSSL_VERSION), current_time, restart_time, (uint64_t)(now - conf.launch_time), generation,
55+
num_connections(0), conf.max_connections, conf.num_listeners, conf.num_threads, num_sessions(0));
56+
assert(ret.len < BUFSIZE);
57+
58+
@@ -2008,7 +2009,7 @@ int main(int argc, char **argv)
59+
break;
60+
case 'v':
61+
printf("h2o version " H2O_VERSION "\n");
62+
- printf("OpenSSL: %s\n", SSLeay_version(SSLEAY_VERSION));
63+
+ printf("OpenSSL: %s\n", OpenSSL_version(OPENSSL_VERSION));
64+
#if H2O_USE_MRUBY
65+
printf(
66+
"mruby: YES\n"); /* TODO determine the way to obtain the version of mruby (that is being linked dynamically) */
67+
--- a/src/ssl.c
68+
+++ b/src/ssl.c
69+
@@ -911,6 +911,7 @@ void ssl_setup_session_resumption(SSL_CT
70+
#endif
71+
}
72+
73+
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)
74+
static pthread_mutex_t *mutexes;
75+
76+
static void lock_callback(int mode, int n, const char *file, int line)
77+
@@ -937,9 +938,11 @@ static int add_lock_callback(int *num, i
78+
79+
return __sync_add_and_fetch(num, amount);
80+
}
81+
+#endif
82+
83+
void init_openssl(void)
84+
{
85+
+#if OPENSSL_VERSION_NUMBER < 0x1010000fL && !defined(LIBRESSL_VERSION_NUMBER)
86+
int nlocks = CRYPTO_num_locks(), i;
87+
mutexes = h2o_mem_alloc(sizeof(*mutexes) * nlocks);
88+
for (i = 0; i != nlocks; ++i)
89+
@@ -953,6 +956,7 @@ void init_openssl(void)
90+
SSL_load_error_strings();
91+
SSL_library_init();
92+
OpenSSL_add_all_algorithms();
93+
+#endif
94+
95+
cache_init_defaults();
96+
#if H2O_USE_SESSION_TICKETS
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
--- a/deps/neverbleed/neverbleed.c
2+
+++ b/deps/neverbleed/neverbleed.c
3+
@@ -1486,6 +1486,7 @@ int neverbleed_init(neverbleed_t *nb, ch
4+
close(pipe_fds[0]);
5+
pipe_fds[0] = -1;
6+
7+
+#ifndef OPENSSL_NO_ENGINE
8+
/* setup engine */
9+
if ((nb->engine = ENGINE_new()) == NULL || !ENGINE_set_id(nb->engine, "neverbleed") ||
10+
!ENGINE_set_name(nb->engine, "privilege separation software engine") || !ENGINE_set_RSA(nb->engine, rsa_method)
11+
@@ -1497,6 +1498,7 @@ int neverbleed_init(neverbleed_t *nb, ch
12+
goto Fail;
13+
}
14+
ENGINE_add(nb->engine);
15+
+#endif
16+
17+
/* setup thread key */
18+
pthread_key_create(&nb->thread_key, dispose_thread_data);
19+
@@ -1515,7 +1517,9 @@ Fail:
20+
if (listen_fd != -1)
21+
close(listen_fd);
22+
if (nb->engine != NULL) {
23+
+#ifndef OPENSSL_NO_ENGINE
24+
ENGINE_free(nb->engine);
25+
+#endif
26+
nb->engine = NULL;
27+
}
28+
return -1;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--- a/include/h2o/http2_internal.h
2+
+++ b/include/h2o/http2_internal.h
3+
@@ -33,7 +33,7 @@
4+
typedef struct st_h2o_http2_conn_t h2o_http2_conn_t;
5+
typedef struct st_h2o_http2_stream_t h2o_http2_stream_t;
6+
7+
-#define H2O_HTTP2_DEFAULT_OUTBUF_SIZE 81920 /* the target size of each write call; connection flow control window + alpha */
8+
+#define H2O_HTTP2_DEFAULT_OUTBUF_SIZE 8192 /* the target size of each write call; connection flow control window + alpha */
9+
#define H2O_HTTP2_DEFAULT_OUTBUF_SOFT_MAX_SIZE 524288 /* 512KB; stops reading if size exceeds this value */
10+
11+
/* hpack */

0 commit comments

Comments
 (0)