]> git.proxmox.com Git - mirror_frr.git/blobdiff - nhrpd/nhrp_main.c
nhrpd: Add NHRP_ERR_XXXX for zlog_err to zlog_ferr conversion
[mirror_frr.git] / nhrpd / nhrp_main.c
index a44ce35bb8e91f933b965c204bb32b2a063f74fd..e9f44e855862bc888ad5bab34cb66d53780a8357 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "nhrpd.h"
 #include "netlink.h"
+#include "nhrp_errors.h"
 
 DEFINE_MGROUP(NHRPD, "NHRP")
 
@@ -32,18 +33,16 @@ struct thread_master *master;
 struct timeval current_time;
 
 /* nhrpd options. */
-struct option longopts[] = {
-       { 0 }
-};
+struct option longopts[] = {{0}};
 
 /* nhrpd privileges */
-static zebra_capabilities_t _caps_p [] = {
-       ZCAP_NET_RAW,
-       ZCAP_NET_ADMIN,
-       ZCAP_DAC_OVERRIDE,      /* for now needed to write to /proc/sys/net/ipv4/<if>/send_redirect */
+static zebra_capabilities_t _caps_p[] = {
+       ZCAP_NET_RAW, ZCAP_NET_ADMIN,
+       ZCAP_DAC_OVERRIDE, /* for now needed to write to
+                             /proc/sys/net/ipv4/<if>/send_redirect */
 };
 
-static struct zebra_privs_t nhrpd_privs = {
+struct zebra_privs_t nhrpd_privs = {
 #if defined(FRR_USER) && defined(FRR_GROUP)
        .user = FRR_USER,
        .group = FRR_GROUP,
@@ -61,7 +60,8 @@ static void parse_arguments(int argc, char **argv)
 
        while (1) {
                opt = frr_getopt(argc, argv, 0);
-               if(opt < 0) break;
+               if (opt < 0)
+                       break;
 
                switch (opt) {
                case 0:
@@ -81,6 +81,7 @@ static void nhrp_sigusr1(void)
 static void nhrp_request_stop(void)
 {
        debugf(NHRP_DEBUG_COMMON, "Exiting...");
+       frr_early_fini();
 
        nhrp_shortcut_terminate();
        nhrp_nhs_terminate();
@@ -89,35 +90,35 @@ static void nhrp_request_stop(void)
        evmgr_terminate();
        nhrp_vc_terminate();
        vrf_terminate();
-       /* memory_terminate(); */
-       /* vty_terminate(); */
-       cmd_terminate();
-       /* signal_terminate(); */
-       zprivs_terminate(&nhrpd_privs);
 
        debugf(NHRP_DEBUG_COMMON, "Done.");
-
-       closezlog();
+       frr_fini();
 
        exit(0);
 }
 
 static struct quagga_signal_t sighandlers[] = {
-       { .signal = SIGUSR1, .handler = &nhrp_sigusr1, },
-       { .signal = SIGINT,  .handler = &nhrp_request_stop, },
-       { .signal = SIGTERM, .handler = &nhrp_request_stop, },
+       {
+               .signal = SIGUSR1,
+               .handler = &nhrp_sigusr1,
+       },
+       {
+               .signal = SIGINT,
+               .handler = &nhrp_request_stop,
+       },
+       {
+               .signal = SIGTERM,
+               .handler = &nhrp_request_stop,
+       },
 };
 
-FRR_DAEMON_INFO(nhrpd, NHRP,
-       .vty_port = NHRP_VTY_PORT,
+FRR_DAEMON_INFO(nhrpd, NHRP, .vty_port = NHRP_VTY_PORT,
 
-       .proghelp = "Implementation of the NHRP routing protocol.",
+               .proghelp = "Implementation of the NHRP routing protocol.",
 
-       .signals = sighandlers,
-       .n_signals = array_size(sighandlers),
+               .signals = sighandlers, .n_signals = array_size(sighandlers),
 
-       .privs = &nhrpd_privs,
-)
+               .privs = &nhrpd_privs, )
 
 int main(int argc, char **argv)
 {
@@ -128,8 +129,9 @@ int main(int argc, char **argv)
 
        /* Library inits. */
        master = frr_init();
+       nhrp_error_init();
+       vrf_init(NULL, NULL, NULL, NULL);
        nhrp_interface_init();
-       vrf_init();
        resolver_init();
 
        /* Run with elevated capabilities, as for all netlink activity