Commit dddc0834 authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[3512] Set SO_REUSEPORT option when opening multicast socket.

This is required on NetNSD and OpenBSD so as multiple sockets can be bound
to in6addr_any and dhcp server port.
parent dc6da560
...@@ -73,6 +73,19 @@ PktFilterInet6::openSocket(const Iface& iface, ...@@ -73,6 +73,19 @@ PktFilterInet6::openSocket(const Iface& iface,
" socket."); " socket.");
} }
#ifdef SO_REUSEPORT
// Set SO_REUSEPORT has to be set to open multiple sockets and bind to
// in6addr_any (binding to port). Binding to port is required on some
// operating systems, e.g. NetBSD and OpenBSD so as the socket can
// join the socket to multicast group.
if (setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
(char *)&flag, sizeof(flag)) < 0) {
close(sock);
isc_throw(SocketConfigError, "Can't set SO_REUSEPORT option on IPv6"
" socket.");
}
#endif
if (bind(sock, (struct sockaddr *)&addr6, sizeof(addr6)) < 0) { if (bind(sock, (struct sockaddr *)&addr6, sizeof(addr6)) < 0) {
// Get the error message immediately after the bind because the // Get the error message immediately after the bind because the
// invocation to close() below would override the errno. // invocation to close() below would override the errno.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment