mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-30 05:57:52 +00:00
Use SO_REUSEPORT_LB on FreeBSD if available
This commit is contained in:
parent
1c672367a0
commit
94cb73d96c
@ -4475,6 +4475,13 @@ isc_socket_bind(isc_socket_t *sock0, const isc_sockaddr_t *sockaddr,
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d) failed", sock->fd);
|
||||
}
|
||||
#if defined(__FreeBSD_kernel__) && defined(SO_REUSEPORT_LB)
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEPORT_LB,
|
||||
(void *)&on, sizeof(on)) < 0)
|
||||
{
|
||||
UNEXPECTED_ERROR(__FILE__, __LINE__,
|
||||
"setsockopt(%d) failed", sock->fd);
|
||||
}
|
||||
#elif defined(__linux__) && defined(SO_REUSEPORT)
|
||||
if (setsockopt(sock->fd, SOL_SOCKET, SO_REUSEPORT,
|
||||
(void *)&on, sizeof(on)) < 0)
|
||||
@ -5334,7 +5341,8 @@ init_hasreuseport() {
|
||||
* We only want to use it on Linux, if it's available. On BSD we want to dup()
|
||||
* sockets instead of re-binding them.
|
||||
*/
|
||||
#if defined(SO_REUSEPORT) && defined(__linux__)
|
||||
#if (defined(SO_REUSEPORT) && defined(__linux__)) || \
|
||||
(defined(SO_REUSEPORT_LB) && defined(__FreeBSD_kernel__))
|
||||
int sock, yes = 1;
|
||||
sock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
if (sock < 0) {
|
||||
@ -5348,8 +5356,13 @@ init_hasreuseport() {
|
||||
{
|
||||
close(sock);
|
||||
return;
|
||||
#if defined(__FreeBSD_kernel__)
|
||||
} else if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT_LB,
|
||||
(void *)&yes, sizeof(yes)) < 0)
|
||||
#else
|
||||
} else if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
|
||||
(void *)&yes, sizeof(yes)) < 0)
|
||||
#endif
|
||||
{
|
||||
close(sock);
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user