diff options
author | Everton Marques <everton.marques@gmail.com> | 2014-08-21 15:47:28 -0300 |
---|---|---|
committer | David Lamparter <equinox@opensourcerouting.org> | 2015-02-04 06:07:59 +0100 |
commit | 1f298949bea9e58623eb81f245491dcdb1df8c59 (patch) | |
tree | 43f99443889cd692a3f6c8adfc40328a868efb67 | |
parent | 7cb0d4a384b4964cc53b61549ffdef37fb0d76c5 (diff) | |
download | quagga-1f298949bea9e58623eb81f245491dcdb1df8c59.tar.bz2 quagga-1f298949bea9e58623eb81f245491dcdb1df8c59.tar.xz |
pimd: -z command-line switch to specify zebra socket path.
-rw-r--r-- | doc/pimd.8 | 17 | ||||
-rw-r--r-- | lib/zclient.c | 7 | ||||
-rw-r--r-- | lib/zclient.h | 1 | ||||
-rw-r--r-- | pimd/pim_main.c | 10 | ||||
-rw-r--r-- | pimd/pim_zebra.c | 7 | ||||
-rw-r--r-- | pimd/pim_zebra.h | 2 | ||||
-rw-r--r-- | pimd/pim_zlookup.c | 23 |
7 files changed, 51 insertions, 16 deletions
@@ -12,6 +12,9 @@ pimd \- a PIM routing for use with Quagga Routing Suite. .B \-i .I pid-file ] [ +.B \-z +.I path +] [ .B \-P .I port-number ] [ @@ -52,6 +55,10 @@ When pimd starts its process identifier is written to \fB\fIpid-file\fR. The init system uses the recorded PID to stop or restart pimd. The likely default is \fB\fI/var/run/pimd.pid\fR. .TP +\fB\-z\fR, \fB\-\-socket \fR\fIpath\fR +Specify the socket path for contacting the zebra daemon. +The likely default is \fB\fI/var/run/zserv.api\fR. +.TP \fB\-P\fR, \fB\-\-vty_port \fR\fIport-number\fR Specify the port that the pimd VTY will listen on. This defaults to 2611, as specified in \fB\fI/etc/services\fR. @@ -80,6 +87,16 @@ The default location of the .B pimd config file. .TP +.BI /var/run/pimd.pid +The default location of the +.B pimd +pid file. +.TP +.BI /var/run/zserv.api +The default location of the +.B zebra +unix socket file. +.TP .BI $(PWD)/pimd.log If the .B pimd diff --git a/lib/zclient.c b/lib/zclient.c index c3a4905f..93614360 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -229,7 +229,7 @@ zclient_socket_connect (struct zclient *zclient) #ifdef HAVE_TCP_ZEBRA zclient->sock = zclient_socket (); #else - zclient->sock = zclient_socket_un (zclient_serv_path ? zclient_serv_path : ZEBRA_SERV_PATH); + zclient->sock = zclient_socket_un (zclient_serv_path_get()); #endif return zclient->sock; } @@ -1053,6 +1053,11 @@ zclient_event (enum event event, struct zclient *zclient) } } +const char *const zclient_serv_path_get() +{ + return zclient_serv_path ? zclient_serv_path : ZEBRA_SERV_PATH; +} + void zclient_serv_path_set (char *path) { diff --git a/lib/zclient.h b/lib/zclient.h index 6a5e6268..c7d4d227 100644 --- a/lib/zclient.h +++ b/lib/zclient.h @@ -136,6 +136,7 @@ extern int zclient_socket(void); extern int zclient_socket_un (const char *path); extern int zclient_socket_connect (struct zclient *); extern void zclient_serv_path_set (char *path); +extern const char *const zclient_serv_path_get (void); /* Send redistribute command to zebra daemon. Do not update zclient state. */ extern int zebra_redistribute_send (int command, struct zclient *, int type); diff --git a/pimd/pim_main.c b/pimd/pim_main.c index 64d7787d..b314df27 100644 --- a/pimd/pim_main.c +++ b/pimd/pim_main.c @@ -98,6 +98,7 @@ Daemon which manages PIM.\n\n\ -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 main(int argc, char** argv, char** envp) { 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 @@ int main(int argc, char** argv, char** envp) { 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 @@ int main(int argc, char** argv, char** envp) { case 'i': pid_file = optarg; break; + case 'z': + zebra_sock_path = optarg; + break; case 'A': vty_addr = optarg; break; @@ -298,10 +303,11 @@ Hello, this is " QUAGGA_PROGNAME " " QUAGGA_VERSION " " PIMD_PROGNAME " " PIMD_V 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 44046dbb..321e3171 100644 --- a/pimd/pim_zebra.c +++ b/pimd/pim_zebra.c @@ -642,14 +642,17 @@ static int redist_read_ipv4_route(int command, struct zclient *zclient, 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 474e7a2e..d624c866 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 be0499e3..ed47e673 100644 --- a/pimd/pim_zlookup.c +++ b/pimd/pim_zlookup.c @@ -66,16 +66,19 @@ static int zclient_lookup_connect(struct thread *t) __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 */ |