]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Do not use the interface manager until it is ready
authorAram Sargsyan <aram@isc.org>
Tue, 14 Jun 2022 10:42:28 +0000 (10:42 +0000)
committerAram Sargsyan <aram@isc.org>
Tue, 14 Jun 2022 14:31:24 +0000 (14:31 +0000)
The `ns_interfacemgr_create()` function, when calling
`isc_nm_routeconnect()`, uses the newly created `ns_interfacemgr_t`
instance before initializing its reference count and the magic value.

Defer the `isc_nm_routeconnect()` call until the initializations
are complete.

lib/ns/interfacemgr.c

index b399fe9f55b4e89fd34fed159b22c9d76a258030..473a79f0c15fb1c3971ad7d31c8198551168b395 100644 (file)
@@ -331,15 +331,6 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
        UNUSED(geoip);
 #endif /* if defined(HAVE_GEOIP2) */
 
-       if (scan) {
-               result = isc_nm_routeconnect(nm, route_connected, mgr);
-               if (result != ISC_R_SUCCESS) {
-                       isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_INFO,
-                                     "unable to open route socket: %s",
-                                     isc_result_totext(result));
-               }
-       }
-
        isc_refcount_init(&mgr->references, 1);
        mgr->magic = IFMGR_MAGIC;
        *mgrp = mgr;
@@ -353,6 +344,15 @@ ns_interfacemgr_create(isc_mem_t *mctx, ns_server_t *sctx,
                RUNTIME_CHECK(result == ISC_R_SUCCESS);
        }
 
+       if (scan) {
+               result = isc_nm_routeconnect(nm, route_connected, mgr);
+               if (result != ISC_R_SUCCESS) {
+                       isc_log_write(IFMGR_COMMON_LOGARGS, ISC_LOG_INFO,
+                                     "unable to open route socket: %s",
+                                     isc_result_totext(result));
+               }
+       }
+
        return (ISC_R_SUCCESS);
 
 cleanup_listenon: