]> git.proxmox.com Git - mirror_frr.git/blobdiff - babeld/babel_main.c
Merge branch 'master' into bfd-final
[mirror_frr.git] / babeld / babel_main.c
index eb2909b40e6cd6a61501dd58a4455f6e37c06f0e..2b87bed0fb886b4b738473d4e84365f47749983b 100644 (file)
@@ -73,7 +73,6 @@ int protocol_port;                /* babel's port */
 int protocol_socket = -1;         /* socket: communicate with others babeld */
 
 static char babel_config_default[] = SYSCONFDIR BABEL_DEFAULT_CONFIG;
-static char *babel_config_file = NULL;
 static char *babel_vty_addr = NULL;
 static int babel_vty_port = BABEL_VTY_PORT;
 
@@ -84,7 +83,7 @@ static zebra_capabilities_t _caps_p [] =
     ZCAP_BIND
 };
 
-static struct zebra_privs_t babeld_privs =
+struct zebra_privs_t babeld_privs =
 {
 #if defined(FRR_USER)
     .user = FRR_USER,
@@ -197,9 +196,6 @@ main(int argc, char **argv)
     /* this replace kernel_setup && kernel_setup_socket */
     babelz_zebra_init ();
 
-    /* Get zebra configuration file. */
-    vty_read_config (babel_config_file, babel_config_default);
-
     /* init buffer */
     rc = resize_receive_buffer(1500);
     if(rc < 0)
@@ -207,8 +203,6 @@ main(int argc, char **argv)
 
     schedule_neighbours_check(5000, 1);
 
-    zlog_notice ("BABELd %s starting: vty@%d", BABEL_VERSION, babel_vty_port);
-
     frr_config_fork();
     frr_run(master);
 
@@ -281,8 +275,7 @@ babel_load_state_file(void)
     if(fd >= 0 && rc < 0) {
         zlog_err("unlink(babel-state): %s", safe_strerror(errno));
         /* If we couldn't unlink it, it's probably stale. */
-        close(fd);
-        fd = -1;
+        goto fini;
     }
     if(fd >= 0) {
         char buf[100];
@@ -317,9 +310,12 @@ babel_load_state_file(void)
                 zlog_err("Couldn't parse babel-state.");
             }
         }
-        close(fd);
-        fd = -1;
+        goto fini;
     }
+fini:
+    if (fd >= 0)
+        close(fd);
+    return ;
 }
 
 static void
@@ -337,6 +333,7 @@ babel_exit_properly(void)
     babel_save_state_file();
     debugf(BABEL_DEBUG_COMMON, "Remove pid file.");
     debugf(BABEL_DEBUG_COMMON, "Done.");
+    frr_fini();
 
     exit(0);
 }
@@ -377,25 +374,22 @@ babel_save_state_file(void)
 void
 show_babel_main_configuration (struct vty *vty)
 {
-    vty_outln (vty,
-            "state file              = %s%s"
-            "configuration file      = %s%s"
-            "protocol informations:%s"
-            "  multicast address     = %s%s"
-            "  port                  = %d%s"
-            "vty address             = %s%s"
-            "vty port                = %d%s"
-            "id                      = %s%s"
-            "kernel_metric           = %d",
-            state_file, VTYNL,
-            babel_config_file ? babel_config_file : babel_config_default,
-            VTYNL,
-            VTYNL,
-            format_address(protocol_group), VTYNL,
-            protocol_port, VTYNL,
+    vty_out (vty,
+            "state file              = %s\n"
+            "configuration file      = %s\n"
+            "protocol informations:\n"
+            "  multicast address     = %s\n"
+            "  port                  = %d\n"
+            "vty address             = %s\n"
+            "vty port                = %d\n"
+            "id                      = %s\n"
+            "kernel_metric           = %d\n",
+            state_file,
+            babeld_di.config_file ? babeld_di.config_file : babel_config_default,
+            format_address(protocol_group),
+            protocol_port,
             babel_vty_addr ? babel_vty_addr : "None",
-            VTYNL,
-            babel_vty_port, VTYNL,
-            format_eui64(myid), VTYNL,
+            babel_vty_port,
+            format_eui64(myid),
             kernel_metric);
 }