]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/main.c
iquagga-faster-compile.patch
[mirror_frr.git] / zebra / main.c
index 2d6a4ac865fb9a553c2401670036ae8bc186baa8..306468fce342e457468913d36be91c6e7230c554 100644 (file)
@@ -39,6 +39,7 @@
 #include "zebra/router-id.h"
 #include "zebra/irdp.h"
 #include "zebra/rtadv.h"
+#include "zebra/zebra_fpm.h"
 
 /* Zebra instance */
 struct zebra_t zebrad =
@@ -60,7 +61,7 @@ int keep_kernel_mode = 0;
 
 #ifdef HAVE_NETLINK
 /* Receive buffer size for netlink socket */
-u_int32_t nl_rcvbufsize = 0;
+u_int32_t nl_rcvbufsize = 4194304;
 #endif /* HAVE_NETLINK */
 
 /* Command line options. */
@@ -71,6 +72,7 @@ struct option longopts[] =
   { "keep_kernel", no_argument,       NULL, 'k'},
   { "config_file", required_argument, NULL, 'f'},
   { "pid_file",    required_argument, NULL, 'i'},
+  { "socket",      required_argument, NULL, 'z'},
   { "help",        no_argument,       NULL, 'h'},
   { "vty_addr",    required_argument, NULL, 'A'},
   { "vty_port",    required_argument, NULL, 'P'},
@@ -103,7 +105,7 @@ struct zebra_privs_t zserv_privs =
   .vty_group = VTY_GROUP,
 #endif
   .caps_p = _caps_p,
-  .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]),
+  .cap_num_p = array_size(_caps_p),
   .cap_num_i = 0
 };
 
@@ -128,6 +130,7 @@ usage (char *progname, int status)
              "-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"\
              "-k, --keep_kernel  Don't delete old routes which installed by "\
                                  "zebra.\n"\
              "-C, --dryrun       Check configuration for validity and exit\n"\
@@ -148,7 +151,7 @@ usage (char *progname, int status)
 
   exit (status);
 }
-\f
+
 /* SIGHUP handler. */
 static void 
 sighup (void)
@@ -200,7 +203,7 @@ struct quagga_signal_t zebra_signals[] =
     .handler = &sigint,
   },
 };
-\f
+
 /* Main startup routine. */
 int
 main (int argc, char **argv)
@@ -214,6 +217,7 @@ main (int argc, char **argv)
   char *config_file = NULL;
   char *progname;
   struct thread thread;
+  char *zserv_path = NULL;
 
   /* Set umask before anything for security */
   umask (0027);
@@ -229,9 +233,9 @@ main (int argc, char **argv)
       int opt;
   
 #ifdef HAVE_NETLINK  
-      opt = getopt_long (argc, argv, "bdkf:i:hA:P:ru:g:vs:C", longopts, 0);
+      opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vs:C", longopts, 0);
 #else
-      opt = getopt_long (argc, argv, "bdkf:i:hA:P:ru:g:vC", longopts, 0);
+      opt = getopt_long (argc, argv, "bdkf:i:z:hA:P:ru:g:vC", longopts, 0);
 #endif /* HAVE_NETLINK */
 
       if (opt == EOF)
@@ -261,6 +265,9 @@ main (int argc, char **argv)
         case 'i':
           pid_file = optarg;
           break;
+       case 'z':
+         zserv_path = optarg;
+         break;
        case 'P':
          /* Deal with atoi() returning 0 on failure, and zebra not
             listening on zebra port... */
@@ -307,7 +314,7 @@ main (int argc, char **argv)
   zprivs_init (&zserv_privs);
 
   /* Vty related initialize. */
-  signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals);
+  signal_init (zebrad.master, array_size(zebra_signals), zebra_signals);
   cmd_init (1);
   vty_init (zebrad.master);
   memory_init ();
@@ -321,7 +328,9 @@ main (int argc, char **argv)
   zebra_vty_init ();
   access_list_init ();
   prefix_list_init ();
+#ifdef RTADV
   rtadv_init ();
+#endif
 #ifdef HAVE_IRDP
   irdp_init();
 #endif
@@ -334,13 +343,16 @@ main (int argc, char **argv)
   interface_list ();
   route_read ();
 
-  /* Sort VTY commands. */
-  sort_node ();
-
 #ifdef HAVE_SNMP
   zebra_snmp_init ();
 #endif /* HAVE_SNMP */
 
+#ifdef HAVE_FPM
+  zfpm_init (zebrad.master, 1, 0);
+#else
+  zfpm_init (zebrad.master, 0, 0);
+#endif
+
   /* Process the configuration file. Among other configuration
   *  directives we can meet those installing static routes. Such
   *  requests will not be executed immediately, but queued in
@@ -362,8 +374,11 @@ main (int argc, char **argv)
     exit (0);
 
   /* Daemonize. */
-  if (daemon_mode)
-    daemon (0, 0);
+  if (daemon_mode && daemon (0, 0) < 0)
+    {
+      zlog_err("Zebra daemon failed: %s", strerror(errno));
+      exit (1);
+    }
 
   /* Output pid of zebra. */
   pid_output (pid_file);
@@ -383,7 +398,7 @@ main (int argc, char **argv)
   pid = getpid ();
 
   /* This must be done only after locking pidfile (bug #403). */
-  zebra_zserv_socket_init ();
+  zebra_zserv_socket_init (zserv_path);
 
   /* Make vty server socket. */
   vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH);