Commit 539838f83b for bind

commit 539838f83b9d38ceac0da9db00ff2a1b548f586d
Author: OndÅ™ej Surý <ondrej@isc.org>
Date:   Fri Sep 4 14:23:29 2026 +0200

    Report route socket overflows on FreeBSD and NetBSD

    Those kernels drop route messages silently when the socket buffer
    overflows, unless SO_RERROR is set; then the next read fails with
    ENOBUFS. Setting it makes the route socket take the same overflow
    recovery path as netlink on Linux instead of waiting for the periodic
    interface rescan.

diff --git a/lib/isc/netmgr/netmgr-int.h b/lib/isc/netmgr/netmgr-int.h
index fa5797a26b..d4beb7876e 100644
--- a/lib/isc/netmgr/netmgr-int.h
+++ b/lib/isc/netmgr/netmgr-int.h
@@ -1395,6 +1395,12 @@ isc__nm_socket_max_port_range(uv_os_sock_t fd ISC_ATTR_UNUSED,
  * (Linux only).
  */

+isc_result_t
+isc__nm_socket_error_reporting(uv_os_sock_t fd ISC_ATTR_UNUSED);
+/*%<
+ * Set SO_RERROR for error reporting on the socket (FreeBSD and NetBSD-only).
+ */
+
 void
 isc__nm_set_network_buffers(uv_handle_t *handle);
 /*%>
diff --git a/lib/isc/netmgr/socket.c b/lib/isc/netmgr/socket.c
index 5f4b86090f..3e83cf87eb 100644
--- a/lib/isc/netmgr/socket.c
+++ b/lib/isc/netmgr/socket.c
@@ -453,3 +453,14 @@ isc__nm_socket_max_port_range(uv_os_sock_t fd ISC_ATTR_UNUSED,
 #endif
 	return ISC_R_SUCCESS;
 }
+
+isc_result_t
+isc__nm_socket_error_reporting(uv_os_sock_t fd ISC_ATTR_UNUSED) {
+#ifdef SO_RERROR
+	if (setsockopt_on(fd, SOL_SOCKET, SO_RERROR) == -1) {
+		return ISC_R_FAILURE;
+	}
+#endif
+
+	return ISC_R_SUCCESS;
+}
diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c
index 593c2114d2..b63ea8c0e9 100644
--- a/lib/isc/netmgr/udp.c
+++ b/lib/isc/netmgr/udp.c
@@ -378,6 +378,9 @@ route_socket(uv_os_sock_t *fdp) {

 	RETERR(isc__nm_socket(ROUTE_SOCKET_PF, SOCK_RAW, ROUTE_SOCKET_PROTOCOL,
 			      &fd));
+	INSIST(fd >= 0);
+
+	isc__nm_socket_error_reporting(fd);

 #ifdef USE_NETLINK
 	sa.nl_family = PF_NETLINK;