diff --git a/CHANGES b/CHANGES index 7caed4d536..173cacd838 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +5403. [func] Don't set udp recv/send buffer sizes, sockets will + use system defaults. [GL #1713] + 5402. [bug] Enable SO_REUSEADDR on all platforms, and either SO_REUSEPORT_LB on FreeBSD, or SO_REUSEPORT on Linux. [GL !3365] diff --git a/doc/arm/notes-9.17.2.xml b/doc/arm/notes-9.17.2.xml index 407855b84a..dcfc529c95 100644 --- a/doc/arm/notes-9.17.2.xml +++ b/doc/arm/notes-9.17.2.xml @@ -89,6 +89,12 @@ [GL #1674] + + + BIND 9 no longer sets the recv and send buffer sizes for sockets, relying + on system defaults instead. [GL #1713] + + diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c index 8f6826ffa9..1b642b8928 100644 --- a/lib/isc/netmgr/udp.c +++ b/lib/isc/netmgr/udp.c @@ -167,11 +167,14 @@ isc__nm_async_udplisten(isc__networker_t *worker, isc__netievent_t *ev0) { if (r < 0) { isc__nm_incstats(sock->mgr, sock->statsindex[STATID_BINDFAIL]); } - +#ifdef ISC_RECV_BUFFER_SIZE uv_recv_buffer_size(&sock->uv_handle.handle, - &(int){ 16 * 1024 * 1024 }); + &(int){ ISC_RECV_BUFFER_SIZE }); +#endif +#ifdef ISC_SEND_BUFFER_SIZE uv_send_buffer_size(&sock->uv_handle.handle, - &(int){ 16 * 1024 * 1024 }); + &(int){ ISC_SEND_BUFFER_SIZE }); +#endif uv_udp_recv_start(&sock->uv_handle.udp, isc__nm_alloc_cb, udp_recv_cb); } diff --git a/lib/isc/unix/socket.c b/lib/isc/unix/socket.c index 2a749e4c99..f1cb70ff71 100644 --- a/lib/isc/unix/socket.c +++ b/lib/isc/unix/socket.c @@ -271,21 +271,13 @@ typedef isc_event_t intev_t; #endif /* ifndef USE_CMSG */ #endif /* ifdef SO_TIMESTAMP */ -/*% - * The size to raise the receive buffer to (from BIND 8). - */ -#ifdef TUNE_LARGE -#ifdef sun -#define RCVBUFSIZE (1 * 1024 * 1024) -#define SNDBUFSIZE (1 * 1024 * 1024) -#else /* ifdef sun */ -#define RCVBUFSIZE (16 * 1024 * 1024) -#define SNDBUFSIZE (16 * 1024 * 1024) -#endif /* ifdef sun */ -#else /* ifdef TUNE_LARGE */ -#define RCVBUFSIZE (32 * 1024) -#define SNDBUFSIZE (32 * 1024) -#endif /* TUNE_LARGE */ +#if defined(SO_RCVBUF) && defined(ISC_RECV_BUFFER_SIZE) +#define SET_RCVBUF +#endif + +#if defined(SO_SNDBUF) && defined(ISC_SEND_BUFFER_SIZE) +#define SET_SNDBUF +#endif /*% * Instead of calculating the cmsgbuf lengths every time we take @@ -1942,9 +1934,9 @@ free_socket(isc__socket_t **socketp) { isc_mem_put(sock->manager->mctx, sock, sizeof(*sock)); } -#ifdef SO_RCVBUF +#if defined(SET_RCVBUF) static isc_once_t rcvbuf_once = ISC_ONCE_INIT; -static int rcvbuf = RCVBUFSIZE; +static int rcvbuf = ISC_RECV_BUFFER_SIZE; static void set_rcvbuf(void) { @@ -2000,9 +1992,9 @@ cleanup: } #endif /* ifdef SO_RCVBUF */ -#ifdef SO_SNDBUF +#if defined(SET_SNDBUF) static isc_once_t sndbuf_once = ISC_ONCE_INIT; -static int sndbuf = SNDBUFSIZE; +static int sndbuf = ISC_SEND_BUFFER_SIZE; static void set_sndbuf(void) { @@ -2105,10 +2097,10 @@ opensocket(isc__socketmgr_t *manager, isc__socket_t *sock, #if defined(USE_CMSG) || defined(SO_NOSIGPIPE) int on = 1; #endif /* if defined(USE_CMSG) || defined(SO_NOSIGPIPE) */ -#if defined(SO_RCVBUF) || defined(SO_SNDBUF) +#if defined(SET_RCVBUF) || defined(SET_SNDBUF) socklen_t optlen; int size = 0; -#endif /* if defined(SO_RCVBUF) || defined(SO_SNDBUF) */ +#endif again: if (dup_socket == NULL) { @@ -2271,7 +2263,7 @@ again: set_tcp_maxseg(sock, 1280 - 20 - 40); /* 1280 - TCP - IPV6 */ } -#if defined(USE_CMSG) || defined(SO_RCVBUF) || defined(SO_SNDBUF) +#if defined(USE_CMSG) || defined(SET_RCVBUF) || defined(SET_SNDBUF) if (sock->type == isc_sockettype_udp) { #if defined(USE_CMSG) #if defined(SO_TIMESTAMP) @@ -2360,7 +2352,7 @@ again: } #endif /* if defined(IP_DONTFRAG) */ -#if defined(SO_RCVBUF) +#if defined(SET_RCVBUF) optlen = sizeof(size); if (getsockopt(sock->fd, SOL_SOCKET, SO_RCVBUF, (void *)&size, &optlen) == 0 && @@ -2378,9 +2370,9 @@ again: sock->fd, rcvbuf, strbuf); } } -#endif /* if defined(SO_RCVBUF) */ +#endif /* if defined(SET_RCVBUF) */ -#if defined(SO_SNDBUF) +#if defined(SET_SNDBUF) optlen = sizeof(size); if (getsockopt(sock->fd, SOL_SOCKET, SO_SNDBUF, (void *)&size, &optlen) == 0 && @@ -2424,7 +2416,7 @@ again: sock->fd, strbuf); } #endif /* ifdef IP_RECVTOS */ -#endif /* defined(USE_CMSG) || defined(SO_RCVBUF) || defined(SO_SNDBUF) */ +#endif /* defined(USE_CMSG) || defined(SET_RCVBUF) || defined(SET_SNDBUF) */ setup_done: inc_stats(manager->stats, sock->statsindex[STATID_OPEN]);