// 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) {
+ // RedHat defines SO_REUSEPORT but the kernel does not support it
+ // and returns ENOPROTOOPT so ignore this error.
+ if ((setsockopt(sock, SOL_SOCKET, SO_REUSEPORT,
+ (char *)&flag, sizeof(flag)) < 0) &&
+ (errno != ENOPROTOOPT)) {
close(sock);
isc_throw(SocketConfigError, "Can't set SO_REUSEPORT option on IPv6"
" socket.");