summaryrefslogtreecommitdiff
path: root/pimd/pim_main.c
diff options
context:
space:
mode:
authorDavid Lamparter <equinox@opensourcerouting.org>2016-11-13 17:48:56 +0900
committerDavid Lamparter <equinox@opensourcerouting.org>2017-03-08 00:15:36 +0100
commiteb05883f3ecd94be017eb7d15181a989f26541ee (patch)
treef3de680c33e3af0f95520eadf8fb0060dc1ee76c /pimd/pim_main.c
parent857b5446497505f582417e4a5ada029712743cbc (diff)
*: add frr_config_fork()
Centralise read_config/daemonize/dryrun/pidfile/vty_serv into libfrr. This also makes multi-instance pid/config handling available as part of the library. It's only wired up in ospfd, but the code is in lib/. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
Diffstat (limited to 'pimd/pim_main.c')
-rw-r--r--pimd/pim_main.c56
1 files changed, 4 insertions, 52 deletions
diff --git a/pimd/pim_main.c b/pimd/pim_main.c
index 9136b08e9b..f446e33af4 100644
--- a/pimd/pim_main.c
+++ b/pimd/pim_main.c
@@ -50,14 +50,7 @@
extern struct host host;
-char config_default[] = SYSCONFDIR PIMD_DEFAULT_CONFIG;
-
-/* pimd options */
struct option longopts[] = {
- { "daemon", no_argument, NULL, 'd'},
- { "config_file", required_argument, NULL, 'f'},
- { "pid_file", required_argument, NULL, 'i'},
- { "socket", required_argument, NULL, 'z'},
{ 0 }
};
@@ -85,8 +78,6 @@ struct zebra_privs_t pimd_privs =
.cap_num_i = 0
};
-const char *pid_file = PATH_PIMD_PID;
-
FRR_DAEMON_INFO(pimd, PIM,
.vty_port = PIMD_VTY_PORT,
@@ -99,18 +90,10 @@ FRR_DAEMON_INFO(pimd, PIM,
)
int main(int argc, char** argv, char** envp) {
- int daemon_mode = 0;
- char *config_file = NULL;
- char *zebra_sock_path = NULL;
struct thread thread;
frr_preinit(&pimd_di, argc, argv);
- frr_opt_add("df:i:z:", longopts,
- " -d, --daemon Runs 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"
- );
+ frr_opt_add("", longopts, "");
/* this while just reads the options */
while (1) {
@@ -124,18 +107,6 @@ int main(int argc, char** argv, char** envp) {
switch (opt) {
case 0:
break;
- case 'd':
- daemon_mode = 1;
- break;
- case 'f':
- config_file = optarg;
- break;
- case 'i':
- pid_file = optarg;
- break;
- case 'z':
- zebra_sock_path = optarg;
- break;
default:
frr_help_exit (1);
break;
@@ -163,30 +134,11 @@ int main(int argc, char** argv, char** envp) {
/*
* Initialize zclient "update" and "lookup" sockets
*/
- pim_zebra_init(zebra_sock_path);
-
- zlog_notice("Loading configuration - begin");
-
- /* Get configuration file. */
- vty_read_config(config_file, config_default);
-
- /*
- Starting from here zlog_* functions will log according configuration
- */
-
- zlog_notice("Loading configuration - end");
-
- /* Change to the daemon program. */
- if (daemon_mode) {
- if (daemon(0, 0)) {
- zlog_warn("failed to daemonize");
- }
- }
+ pim_zebra_init();
- /* Process ID file creation. */
- pid_output(pid_file);
+ frr_config_fork();
- frr_vty_serv (PIM_VTYSH_PATH);
+ frr_vty_serv();
zlog_notice("Quagga %s " PIMD_PROGNAME " %s starting, VTY interface at port TCP %d",
FRR_VERSION, PIMD_VERSION, pimd_di.vty_port);