zebra_if_init();
zebra_debug_init();
+ /* Open Zebra API server socket */
+ zserv_open(zserv_path);
+
/*
* Initialize NS( and implicitly the VRF module), and make kernel
* routing socket. */
/* The listener socket for clients connecting to us */
static int zsock;
+static bool started_p;
/* The lock that protects access to zapi client objects */
static pthread_mutex_t client_mutex;
/* Free client list's mutex */
pthread_mutex_destroy(&client_mutex);
+
+ started_p = false;
}
-void zserv_start(char *path)
+
+/*
+ * Open zebra's ZAPI listener socket. This is done early during startup,
+ * before zebra is ready to listen and accept client connections.
+ */
+void zserv_open(const char *path)
{
int ret;
mode_t old_mask;
path, safe_strerror(errno));
close(zsock);
zsock = -1;
+ }
+
+ umask(old_mask);
+}
+
+/*
+ * Start listening for ZAPI client connections.
+ */
+void zserv_start(const char *path)
+{
+ int ret;
+
+ /* This may be called more than once during startup - potentially once
+ * per netns - but only do this work once.
+ */
+ if (started_p)
+ return;
+
+ if (zsock <= 0) {
+ flog_err_sys(EC_LIB_SOCKET, "Zserv socket open failed");
return;
}
return;
}
- umask(old_mask);
+ started_p = true;
zserv_event(NULL, ZSERV_ACCEPT);
}
*/
extern void zserv_close(void);
+/*
+ * Open Zebra API server socket.
+ *
+ * Create and open the server socket.
+ *
+ * path
+ * where to place the Unix domain socket
+ */
+extern void zserv_open(const char *path);
+
/*
* Start Zebra API server.
*
- * Allocates resources, creates the server socket and begins listening on the
- * socket.
+ * Allocates resources and begins listening on the server socket.
*
* path
* where to place the Unix domain socket
*/
-extern void zserv_start(char *path);
+extern void zserv_start(const char *path);
/*
* Send a message to a connected Zebra API client.