2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-22 18:19:42 +00:00

Bump the libuv requirement to libuv >= 1.34.0

By bumping the minimum libuv version to 1.34.0, it allows us to remove
all libuv shims we ever had and makes the code much cleaner.  The
up-to-date libuv is available in all distributions supported by BIND
9.19+ either natively or as a backport.
This commit is contained in:
Ondřej Surý 2022-09-27 14:10:40 +02:00
parent d5bead54c0
commit 0086ebf3fc
No known key found for this signature in database
GPG Key ID: 2820F37E873DEA41
8 changed files with 8 additions and 151 deletions

View File

@ -552,8 +552,8 @@ AC_CHECK_HEADERS([pthread_np.h], [], [], [#include <pthread.h>])
# libuv # libuv
AC_MSG_CHECKING([for libuv]) AC_MSG_CHECKING([for libuv])
PKG_CHECK_MODULES([LIBUV], [libuv >= 1.0.0], [], PKG_CHECK_MODULES([LIBUV], [libuv >= 1.34.0], [],
[AC_MSG_ERROR([libuv not found])]) [AC_MSG_ERROR([libuv >= 1.34.0 not found])])
AX_SAVE_FLAGS([libuv]) AX_SAVE_FLAGS([libuv])
CFLAGS="$CFLAGS $LIBUV_CFLAGS" CFLAGS="$CFLAGS $LIBUV_CFLAGS"

View File

@ -60,7 +60,7 @@ To build BIND 9, the following packages must be installed:
- ``perl`` - ``perl``
- ``pkg-config`` / ``pkgconfig`` / ``pkgconf`` - ``pkg-config`` / ``pkgconfig`` / ``pkgconf``
BIND 9.19 requires ``libuv`` 1.x or higher. On older systems, an updated BIND 9.19 requires ``libuv`` 1.34.0 or higher. On older systems, an updated
``libuv`` package needs to be installed from sources such as EPEL, PPA, ``libuv`` package needs to be installed from sources such as EPEL, PPA,
or other native sources. The other option is to build and install or other native sources. The other option is to build and install
``libuv`` from source. ``libuv`` from source.

View File

@ -107,7 +107,7 @@ These are platforms on which current versions of BIND 9 are known *not* to build
- Platforms that do not support atomic operations (via compiler or - Platforms that do not support atomic operations (via compiler or
library) library)
- Linux without NPTL (Native POSIX Thread Library) - Linux without NPTL (Native POSIX Thread Library)
- Platforms on which **libuv** cannot be compiled - Platforms on which **libuv >= 1.34** cannot be compiled or is not available
Installing BIND 9 Installing BIND 9
----------------- -----------------

View File

@ -19,11 +19,6 @@
#include <isc/result.h> #include <isc/result.h>
#include <isc/tid.h> #include <isc/tid.h>
/*
* These functions were introduced in newer libuv, but we still
* want BIND9 compile on older ones so we emulate them.
*/
#define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch)) #define UV_VERSION(major, minor, patch) ((major << 16) | (minor << 8) | (patch))
/* /*
@ -47,58 +42,6 @@
#define UV__ERR(x) (-(x)) #define UV__ERR(x) (-(x))
#endif #endif
#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
int
uv_os_getenv(const char *name, char *buffer, size_t *size);
#define uv_os_setenv(name, value) setenv(name, value, 0)
#endif /* UV_VERSION_HEX < UV_VERSION(1, 12, 0) */
#if UV_VERSION_HEX < UV_VERSION(1, 19, 0)
static inline void *
uv_handle_get_data(const uv_handle_t *handle) {
return (handle->data);
}
static inline void
uv_handle_set_data(uv_handle_t *handle, void *data) {
handle->data = data;
}
static inline void *
uv_req_get_data(const uv_req_t *req) {
return (req->data);
}
static inline void
uv_req_set_data(uv_req_t *req, void *data) {
req->data = data;
}
#endif /* UV_VERSION_HEX < UV_VERSION(1, 19, 0) */
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
int
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb);
#endif
#if UV_VERSION_HEX < UV_VERSION(1, 34, 0)
#define uv_sleep(msec) usleep(msec * 1000)
#endif /* UV_VERSION_HEX < UV_VERSION(1, 34, 0) */
#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
int
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
/*%<
* Associate the UDP handle to a remote address and port, so every message sent
* by this handle is automatically sent to that destination.
*
* NOTE: This is just a limited shim for uv_udp_connect() as it requires the
* handle to be bound.
*/
#else /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
#define isc_uv_udp_connect uv_udp_connect
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
/* /*
* These are used with all versions of libuv: * These are used with all versions of libuv:
*/ */

View File

@ -725,17 +725,14 @@ isc__nm_udp_send(isc_nmhandle_t *handle, const isc_region_t *region,
uvreq->cb.send = cb; uvreq->cb.send = cb;
uvreq->cbarg = cbarg; uvreq->cbarg = cbarg;
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
/* /*
* If we used uv_udp_connect() (and not the shim version for * We used uv_udp_connect(), so the peer address has to be
* older versions of libuv), then the peer address has to be
* set to NULL or else uv_udp_send() could fail or assert, * set to NULL or else uv_udp_send() could fail or assert,
* depending on the libuv version. * depending on the libuv version.
*/ */
if (atomic_load(&sock->connected)) { if (atomic_load(&sock->connected)) {
sa = NULL; sa = NULL;
} }
#endif
r = uv_udp_send(&uvreq->uv_req.udp_send, &sock->uv_handle.udp, r = uv_udp_send(&uvreq->uv_req.udp_send, &sock->uv_handle.udp,
&uvreq->uvbuf, 1, sa, udp_send_cb); &uvreq->uvbuf, 1, sa, udp_send_cb);
@ -790,8 +787,7 @@ udp_connect_direct(isc_nmsocket_t *sock, isc__nm_uvreq_t *req) {
* giving up. * giving up.
*/ */
do { do {
r = isc_uv_udp_connect(&sock->uv_handle.udp, r = uv_udp_connect(&sock->uv_handle.udp, &req->peer.type.sa);
&req->peer.type.sa);
} while (r == UV_EADDRINUSE && --req->connect_tries > 0); } while (r == UV_EADDRINUSE && --req->connect_tries > 0);
if (r != 0) { if (r != 0) {
isc__nm_incstats(sock, STATID_CONNECTFAIL); isc__nm_incstats(sock, STATID_CONNECTFAIL);

View File

@ -16,75 +16,6 @@
#include <isc/util.h> #include <isc/util.h>
#include <isc/uv.h> #include <isc/uv.h>
#if UV_VERSION_HEX < UV_VERSION(1, 12, 0)
#include <stdlib.h>
#include <string.h>
int
uv_os_getenv(const char *name, char *buffer, size_t *size) {
size_t len;
char *buf = getenv(name);
if (buf == NULL) {
return (UV_ENOENT);
}
len = strlen(buf) + 1;
if (len > *size) {
*size = len;
return (UV_ENOBUFS);
}
*size = len;
memmove(buffer, buf, len);
return (0);
}
#endif
#if UV_VERSION_HEX < UV_VERSION(1, 27, 0)
int
isc_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
int err = 0;
do {
int addrlen = (addr->sa_family == AF_INET)
? sizeof(struct sockaddr_in)
: sizeof(struct sockaddr_in6);
err = connect(handle->io_watcher.fd, addr, addrlen);
} while (err == -1 && errno == EINTR);
if (err) {
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
return (uv_translate_sys_error(errno));
#else
return (-errno);
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
}
return (0);
}
#endif /* UV_VERSION_HEX < UV_VERSION(1, 27, 0) */
#if UV_VERSION_HEX < UV_VERSION(1, 32, 0)
int
uv_tcp_close_reset(uv_tcp_t *handle, uv_close_cb close_cb) {
if (setsockopt(handle->io_watcher.fd, SOL_SOCKET, SO_LINGER,
&(struct linger){ 1, 0 }, sizeof(struct linger)) == -1)
{
#if UV_VERSION_HEX >= UV_VERSION(1, 10, 0)
return (uv_translate_sys_error(errno));
#else
return (-errno);
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 10, 0) */
}
INSIST(!uv_is_closing((uv_handle_t *)handle));
uv_close((uv_handle_t *)handle, close_cb);
return (0);
}
#endif /* UV_VERSION_HEX < UV_VERSION(1, 32, 0) */
#define setsockopt_on(socket, level, name) \
setsockopt(socket, level, name, &(int){ 1 }, sizeof(int))
/*% /*%
* Convert a libuv error value into an isc_result_t. The * Convert a libuv error value into an isc_result_t. The
* list of supported error values is not complete; new users * list of supported error values is not complete; new users

View File

@ -228,7 +228,6 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_bind) {
RESET_RETURN; RESET_RETURN;
} }
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_connect) { ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_connect) {
WILL_RETURN(uv_udp_connect, UV_ENOMEM); WILL_RETURN(uv_udp_connect, UV_ENOMEM);
@ -240,8 +239,6 @@ ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_udp_connect) {
RESET_RETURN; RESET_RETURN;
} }
#endif
ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_recv_buffer_size) { ISC_LOOP_TEST_IMPL(mock_udpconnect_uv_recv_buffer_size) {
WILL_RETURN(uv_recv_buffer_size, UV_ENOMEM); WILL_RETURN(uv_recv_buffer_size, UV_ENOMEM);
@ -1133,9 +1130,7 @@ ISC_TEST_ENTRY_CUSTOM(mock_listenudp_uv_udp_recv_start, setup_test,
teardown_test) teardown_test)
ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_open, setup_test, teardown_test) ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_open, setup_test, teardown_test)
ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_bind, setup_test, teardown_test) ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_bind, setup_test, teardown_test)
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_connect, setup_test, teardown_test) ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_udp_connect, setup_test, teardown_test)
#endif
ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_recv_buffer_size, setup_test, ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_recv_buffer_size, setup_test,
teardown_test) teardown_test)
ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_send_buffer_size, setup_test, ISC_TEST_ENTRY_CUSTOM(mock_udpconnect_uv_send_buffer_size, setup_test,

View File

@ -38,13 +38,11 @@ __wrap_uv_udp_open(uv_udp_t *handle, uv_os_sock_t sock);
int int
__wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr, __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
unsigned int flags); unsigned int flags);
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int int
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr); __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr);
int int
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
int *namelen); int *namelen);
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
int int
__wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name, __wrap_uv_udp_getsockname(const uv_udp_t *handle, struct sockaddr *name,
int *namelen); int *namelen);
@ -118,7 +116,6 @@ __wrap_uv_udp_bind(uv_udp_t *handle, const struct sockaddr *addr,
static atomic_int __state_uv_udp_connect __attribute__((unused)) = 0; static atomic_int __state_uv_udp_connect __attribute__((unused)) = 0;
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int int
__wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) { __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
if (atomic_load(&__state_uv_udp_connect) == 0) { if (atomic_load(&__state_uv_udp_connect) == 0) {
@ -126,11 +123,9 @@ __wrap_uv_udp_connect(uv_udp_t *handle, const struct sockaddr *addr) {
} }
return (atomic_load(&__state_uv_udp_connect)); return (atomic_load(&__state_uv_udp_connect));
} }
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
static atomic_int __state_uv_udp_getpeername __attribute__((unused)) = 0; static atomic_int __state_uv_udp_getpeername __attribute__((unused)) = 0;
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
int int
__wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name, __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
int *namelen) { int *namelen) {
@ -139,7 +134,6 @@ __wrap_uv_udp_getpeername(const uv_udp_t *handle, struct sockaddr *name,
} }
return (atomic_load(&__state_uv_udp_getpeername)); return (atomic_load(&__state_uv_udp_getpeername));
} }
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
static atomic_int __state_uv_udp_getsockname = 0; static atomic_int __state_uv_udp_getsockname = 0;
int int
@ -277,10 +271,8 @@ __wrap_uv_fileno(const uv_handle_t *handle, uv_os_fd_t *fd) {
#define uv_udp_open(...) __wrap_uv_udp_open(__VA_ARGS__) #define uv_udp_open(...) __wrap_uv_udp_open(__VA_ARGS__)
#define uv_udp_bind(...) __wrap_uv_udp_bind(__VA_ARGS__) #define uv_udp_bind(...) __wrap_uv_udp_bind(__VA_ARGS__)
#if UV_VERSION_HEX >= UV_VERSION(1, 27, 0)
#define uv_udp_connect(...) __wrap_uv_udp_connect(__VA_ARGS__) #define uv_udp_connect(...) __wrap_uv_udp_connect(__VA_ARGS__)
#define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__VA_ARGS__) #define uv_udp_getpeername(...) __wrap_uv_udp_getpeername(__VA_ARGS__)
#endif /* UV_VERSION_HEX >= UV_VERSION(1, 27, 0) */
#define uv_udp_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__) #define uv_udp_getsockname(...) __wrap_uv_udp_getsockname(__VA_ARGS__)
#define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__) #define uv_udp_send(...) __wrap_uv_udp_send(__VA_ARGS__)
#define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__) #define uv_udp_recv_start(...) __wrap_uv_udp_recv_start(__VA_ARGS__)