pimd: -z command-line switch to specify zebra socket path.
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index 64d7787..b314df2 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -98,6 +98,7 @@
-d, --daemon Run in daemon mode\n\
-f, --config_file Set configuration file name\n\
-i, --pid_file Set process identifier file name\n\
+-z, --socket Set path of zebra socket\n\
-A, --vty_addr Set vty's bind address\n\
-P, --vty_port Set vty's port number\n\
-v, --version Print program version\n\
@@ -125,6 +126,7 @@
int vty_port = -1;
int daemon_mode = 0;
char *config_file = NULL;
+ char *zebra_sock_path = NULL;
struct thread thread;
umask(0027);
@@ -138,7 +140,7 @@
while (1) {
int opt;
- opt = getopt_long (argc, argv, "df:i:A:P:vZh", longopts, 0);
+ opt = getopt_long (argc, argv, "df:i:z:A:P:vZh", longopts, 0);
if (opt == EOF)
break;
@@ -155,6 +157,9 @@
case 'i':
pid_file = optarg;
break;
+ case 'z':
+ zebra_sock_path = optarg;
+ break;
case 'A':
vty_addr = optarg;
break;
@@ -298,10 +303,11 @@
zlog_notice("!HAVE_CLOCK_MONOTONIC");
#endif
+
/*
Initialize zclient "update" and "lookup" sockets
*/
- pim_zebra_init();
+ pim_zebra_init(zebra_sock_path);
while (thread_fetch(master, &thread))
thread_call(&thread);
diff --git a/pimd/pim_zebra.c b/pimd/pim_zebra.c
index 44046db..321e317 100644
--- a/pimd/pim_zebra.c
+++ b/pimd/pim_zebra.c
@@ -642,14 +642,17 @@
return 0;
}
-void pim_zebra_init()
+void pim_zebra_init(char *zebra_sock_path)
{
int i;
+ if (zebra_sock_path)
+ zclient_serv_path_set(zebra_sock_path);
+
#ifdef HAVE_TCP_ZEBRA
zlog_notice("zclient update contacting ZEBRA daemon at socket TCP %s,%d", "127.0.0.1", ZEBRA_PORT);
#else
- zlog_notice("zclient update contacting ZEBRA daemon at socket UNIX %s", ZEBRA_SERV_PATH);
+ zlog_notice("zclient update contacting ZEBRA daemon at socket UNIX %s", zclient_serv_path_get());
#endif
/* Socket for receiving updates from Zebra daemon */
diff --git a/pimd/pim_zebra.h b/pimd/pim_zebra.h
index 474e7a2..d624c86 100644
--- a/pimd/pim_zebra.h
+++ b/pimd/pim_zebra.h
@@ -26,7 +26,7 @@
#include "pim_igmp.h"
#include "pim_ifchannel.h"
-void pim_zebra_init(void);
+void pim_zebra_init(char *zebra_sock_path);
void pim_scan_oil(void);
diff --git a/pimd/pim_zlookup.c b/pimd/pim_zlookup.c
index be0499e..ed47e67 100644
--- a/pimd/pim_zlookup.c
+++ b/pimd/pim_zlookup.c
@@ -66,16 +66,19 @@
__PRETTY_FUNCTION__, "127.0.0.1", ZEBRA_PORT);
}
#else
- zlog_debug("%s: FIXME blocking connect: zclient_socket_un()",
- __PRETTY_FUNCTION__);
- zlookup->sock = zclient_socket_un(ZEBRA_SERV_PATH);
- if (zlookup->sock < 0) {
- zlog_warn("%s: failure connecting UNIX socket %s",
- __PRETTY_FUNCTION__, ZEBRA_SERV_PATH);
- }
- else if (zclient_debug) {
- zlog_notice("%s: connected UNIX socket %s",
- __PRETTY_FUNCTION__, ZEBRA_SERV_PATH);
+ {
+ const char *const path = zclient_serv_path_get();
+ zlog_debug("%s: FIXME blocking connect: zclient_socket_un()",
+ __PRETTY_FUNCTION__);
+ zlookup->sock = zclient_socket_un(path);
+ if (zlookup->sock < 0) {
+ zlog_warn("%s: failure connecting UNIX socket %s",
+ __PRETTY_FUNCTION__, path);
+ }
+ else if (zclient_debug) {
+ zlog_notice("%s: connected UNIX socket %s",
+ __PRETTY_FUNCTION__, path);
+ }
}
#endif /* HAVE_TCP_ZEBRA */