Commit 58830fb15c for bind
commit 58830fb15cbddeb6171b9c131dd4dfb76403f011
Author: OndÅ™ej Surý <ondrej@isc.org>
Date: Fri Sep 4 15:09:04 2026 +0200
Only ask the route socket for address changes
The interface rescan reacts to RTM_NEWADDR and RTM_DELADDR alone, yet
the socket received link state changes on Linux and, on the BSDs,
every routing table change as well. That traffic only fills the buffer
whose overflow now costs a full rescan cycle. Subscribe to the address
groups only on Linux, and install the message type filter where the
BSDs offer one; macOS has none and keeps receiving everything.
diff --git a/lib/isc/netmgr/udp.c b/lib/isc/netmgr/udp.c
index bb3b2c5f72..332ef2f4de 100644
--- a/lib/isc/netmgr/udp.c
+++ b/lib/isc/netmgr/udp.c
@@ -371,10 +371,6 @@ isc_nm_listenudp(uint32_t workers, isc_sockaddr_t *iface, isc_nm_recv_cb_t cb,
static isc_result_t
route_socket(uv_os_sock_t *fdp) {
uv_os_sock_t fd = -1;
-#ifdef USE_NETLINK
- struct sockaddr_nl sa = { 0 };
- int r;
-#endif
RETERR(isc__nm_socket(ROUTE_SOCKET_PF, SOCK_RAW, ROUTE_SOCKET_PROTOCOL,
&fd));
@@ -383,14 +379,32 @@ route_socket(uv_os_sock_t *fdp) {
isc__nm_socket_error_reporting(fd);
#ifdef USE_NETLINK
- sa.nl_family = PF_NETLINK;
- sa.nl_groups = RTMGRP_LINK | RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
- r = bind(fd, (struct sockaddr *)&sa, sizeof(sa));
+ /* Linux */
+ struct sockaddr_nl sa = {
+ .nl_family = PF_NETLINK,
+ .nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR,
+ };
+
+ int r = bind(fd, (struct sockaddr *)&sa, sizeof(sa));
if (r < 0) {
isc_result_t result = isc_errno_toresult(errno);
isc__nm_closesocket(fd);
return result;
}
+#elif defined(RO_MSGFILTER)
+ /* FreeBSD and NetBSD */
+ unsigned char msgtypes[] = { RTM_NEWADDR, RTM_DELADDR };
+
+ (void)setsockopt(fd, PF_ROUTE, RO_MSGFILTER, &msgtypes,
+ sizeof(msgtypes));
+#elif defined(ROUTE_MSGFILTER)
+ /* OpenBSD */
+ unsigned int rtfilter = ROUTE_FILTER(RTM_NEWADDR) |
+ ROUTE_FILTER(RTM_DELADDR) |
+ ROUTE_FILTER(RTM_DESYNC);
+
+ (void)setsockopt(fd, AF_ROUTE, ROUTE_MSGFILTER, &rtfilter,
+ sizeof(rtfilter));
#endif
*fdp = fd;
diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c
index 5f0d4714b6..b0f700aab7 100644
--- a/tests/libtest/ns.c
+++ b/tests/libtest/ns.c
@@ -114,7 +114,9 @@ setup_server(void **state) {
CHECK(dns_dispatchmgr_create(isc_g_mctx, &dispatchmgr));
+ isc_loop_setup(isc_loop_main(), setup_zone_services, NULL);
isc_loop_setup(isc_loop_main(), setup_interfacemgr, NULL);
+ isc_loop_teardown(isc_loop_main(), shutdown_zone_services, NULL);
return 0;