]> git.proxmox.com Git - mirror_frr.git/blobdiff - ldpd/ldpd.c
lib, zebra: add new MPLS zapi message with route replace semantics
[mirror_frr.git] / ldpd / ldpd.c
index 771d3b7459a0ce97521e3151b7872a2f63ca8a1a..a6f0519bd72940330c1524ba0ff13ce3c6fab1ba 100644 (file)
@@ -116,7 +116,7 @@ struct zebra_privs_t ldpd_privs =
 };
 
 /* CTL Socket path */
-char ctl_sock_path[MAXPATHLEN] = LDPD_SOCKET;
+char ctl_sock_path[MAXPATHLEN];
 
 /* LDPd options. */
 #define OPTION_CTLSOCK 1001
@@ -219,6 +219,10 @@ main(int argc, char *argv[])
        int                      pipe_parent2lde[2], pipe_parent2lde_sync[2];
        char                    *ctl_sock_name;
        struct thread           *thread = NULL;
+       bool                    ctl_sock_used = false;
+
+       snprintf(ctl_sock_path, sizeof(ctl_sock_path), LDPD_SOCKET,
+                "", "");
 
        ldpd_process = PROC_MAIN;
        log_procname = log_procnames[ldpd_process];
@@ -232,6 +236,9 @@ main(int argc, char *argv[])
                "      --ctl_socket   Override ctl socket path\n"
                "  -n, --instance     Instance id\n");
 
+       /* set default instance (to differentiate ldpd socket from lde one */
+       init.instance = 1;
+
        while (1) {
                int opt;
 
@@ -244,6 +251,7 @@ main(int argc, char *argv[])
                case 0:
                        break;
                case OPTION_CTLSOCK:
+                       ctl_sock_used = true;
                        ctl_sock_name = strrchr(LDPD_SOCKET, '/');
                        if (ctl_sock_name)
                                /* skip '/' */
@@ -277,6 +285,10 @@ main(int argc, char *argv[])
                }
        }
 
+       if (ldpd_di.pathspace && !ctl_sock_used)
+               snprintf(ctl_sock_path, sizeof(ctl_sock_path), LDPD_SOCKET,
+                        "/", ldpd_di.pathspace);
+
        strlcpy(init.user, ldpd_privs.user, sizeof(init.user));
        strlcpy(init.group, ldpd_privs.group, sizeof(init.group));
        strlcpy(init.ctl_sock_path, ctl_sock_path, sizeof(init.ctl_sock_path));
@@ -438,7 +450,7 @@ ldpd_shutdown(void)
                        if (errno == EINTR)
                                continue;
                        /* No more processes were found. */
-                       if (errno != ECHILD)
+                       if (errno == ECHILD)
                                break;
 
                        /* Unhandled errno condition. */