From 718e3744195351130f4ce7dbe0613f4b3e23df93 Mon Sep 17 00:00:00 2001 From: paul Date: Fri, 13 Dec 2002 20:15:29 +0000 Subject: Initial revision --- zebra/main.c | 316 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 316 insertions(+) create mode 100644 zebra/main.c (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c new file mode 100644 index 00000000..25d8b6de --- /dev/null +++ b/zebra/main.c @@ -0,0 +1,316 @@ +/* + * zebra daemon main routine. + * Copyright (C) 1997, 98 Kunihiro Ishiguro + * + * This file is part of GNU Zebra. + * + * GNU Zebra is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2, or (at your option) any + * later version. + * + * GNU Zebra is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Zebra; see the file COPYING. If not, write to the Free + * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +#include + +#include "version.h" +#include "getopt.h" +#include "command.h" +#include "thread.h" +#include "filter.h" +#include "memory.h" +#include "prefix.h" +#include "log.h" + +#include "zebra/rib.h" +#include "zebra/zserv.h" +#include "zebra/debug.h" +#include "zebra/rib.h" + +/* Master of threads. */ +struct thread_master *master; + +/* process id. */ +pid_t old_pid; +pid_t pid; + +/* Route retain mode flag. */ +int retain_mode = 0; + +/* Don't delete kernel route. */ +int keep_kernel_mode = 0; + +/* Command line options. */ +struct option longopts[] = +{ + { "batch", no_argument, NULL, 'b'}, + { "daemon", no_argument, NULL, 'd'}, + { "keep_kernel", no_argument, NULL, 'k'}, + { "log_mode", no_argument, NULL, 'l'}, + { "config_file", required_argument, NULL, 'f'}, + { "pid_file", required_argument, NULL, 'i'}, + { "help", no_argument, NULL, 'h'}, + { "vty_addr", required_argument, NULL, 'A'}, + { "vty_port", required_argument, NULL, 'P'}, + { "retain", no_argument, NULL, 'r'}, + { "version", no_argument, NULL, 'v'}, + { 0 } +}; + +/* Default configuration file path. */ +char config_current[] = DEFAULT_CONFIG_FILE; +char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; + +/* Process ID saved for use by init system */ +char *pid_file = PATH_ZEBRA_PID; + +/* Help information display. */ +static void +usage (char *progname, int status) +{ + if (status != 0) + fprintf (stderr, "Try `%s --help' for more information.\n", progname); + else + { + printf ("Usage : %s [OPTION...]\n\n\ +Daemon which manages kernel routing table management and \ +redistribution between different routing protocols.\n\n\ +-b, --batch Runs in batch mode\n\ +-d, --daemon Runs in daemon mode\n\ +-f, --config_file Set configuration file name\n\ +-i, --pid_file Set process identifier file name\n\ +-k, --keep_kernel Don't delete old routes which installed by zebra.\n\ +-l, --log_mode Set verbose log mode flag\n\ +-A, --vty_addr Set vty's bind address\n\ +-P, --vty_port Set vty's port number\n\ +-r, --retain When program terminates, retain added route by zebra.\n\ +-v, --version Print program version\n\ +-h, --help Display this help and exit\n\ +\n\ +Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + } + + exit (status); +} + +/* SIGHUP handler. */ +void +sighup (int sig) +{ + zlog_info ("SIGHUP received"); + + /* Reload of config file. */ + ; +} + +/* SIGINT handler. */ +void +sigint (int sig) +{ + /* Decrared in rib.c */ + void rib_close (); + + zlog_info ("Terminating on signal"); + + if (!retain_mode) + rib_close (); + + exit (0); +} + +/* SIGUSR1 handler. */ +void +sigusr1 (int sig) +{ + zlog_rotate (NULL); +} + +/* Signale wrapper. */ +RETSIGTYPE * +signal_set (int signo, void (*func)(int)) +{ + int ret; + struct sigaction sig; + struct sigaction osig; + + sig.sa_handler = func; + sigemptyset (&sig.sa_mask); + sig.sa_flags = 0; +#ifdef SA_RESTART + sig.sa_flags |= SA_RESTART; +#endif /* SA_RESTART */ + + ret = sigaction (signo, &sig, &osig); + + if (ret < 0) + return (SIG_ERR); + else + return (osig.sa_handler); +} + +/* Initialization of signal handles. */ +void +signal_init () +{ + signal_set (SIGHUP, sighup); + signal_set (SIGINT, sigint); + signal_set (SIGTERM, sigint); + signal_set (SIGPIPE, SIG_IGN); + signal_set (SIGUSR1, sigusr1); +} + +/* Main startup routine. */ +int +main (int argc, char **argv) +{ + char *p; + char *vty_addr = NULL; + int vty_port = 0; + int batch_mode = 0; + int daemon_mode = 0; + char *config_file = NULL; + char *progname; + struct thread thread; + void rib_weed_tables (); + void zebra_vty_init (); + + /* Set umask before anything for security */ + umask (0027); + + /* preserve my name */ + progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); + + zlog_default = openzlog (progname, ZLOG_STDOUT, ZLOG_ZEBRA, + LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); + + while (1) + { + int opt; + + opt = getopt_long (argc, argv, "bdklf:hA:P:rv", longopts, 0); + + if (opt == EOF) + break; + + switch (opt) + { + case 0: + break; + case 'b': + batch_mode = 1; + case 'd': + daemon_mode = 1; + break; + case 'k': + keep_kernel_mode = 1; + break; + case 'l': + /* log_mode = 1; */ + break; + case 'f': + config_file = optarg; + break; + case 'A': + vty_addr = optarg; + break; + case 'i': + pid_file = optarg; + break; + case 'P': + vty_port = atoi (optarg); + break; + case 'r': + retain_mode = 1; + break; + case 'v': + print_version (progname); + exit (0); + break; + case 'h': + usage (progname, 0); + break; + default: + usage (progname, 1); + break; + } + } + + /* Make master thread emulator. */ + master = thread_master_create (); + + /* Vty related initialize. */ + signal_init (); + cmd_init (1); + vty_init (); + memory_init (); + + /* Zebra related initialize. */ + zebra_init (); + rib_init (); + zebra_if_init (); + zebra_debug_init (); + zebra_vty_init (); + access_list_init (); + rtadv_init (); + + /* For debug purpose. */ + /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ + + /* Make kernel routing socket. */ + kernel_init (); + interface_list (); + route_read (); + + /* Sort VTY commands. */ + sort_node (); + +#ifdef HAVE_SNMP + zebra_snmp_init (); +#endif /* HAVE_SNMP */ + + /* Clean up self inserted route. */ + if (! keep_kernel_mode) + rib_sweep_route (); + + /* Configuration file read*/ + vty_read_config (config_file, config_current, config_default); + + /* Clean up rib. */ + rib_weed_tables (); + + /* Exit when zebra is working in batch mode. */ + if (batch_mode) + exit (0); + + /* Needed for BSD routing socket. */ + old_pid = getpid (); + + /* Daemonize. */ + if (daemon_mode) + daemon (0, 0); + + /* Output pid of zebra. */ + pid_output (pid_file); + + /* Needed for BSD routing socket. */ + pid = getpid (); + + /* Make vty server socket. */ + vty_serv_sock (vty_addr, + vty_port ? vty_port : ZEBRA_VTY_PORT, ZEBRA_VTYSH_PATH); + + while (thread_fetch (master, &thread)) + thread_call (&thread); + + /* Not reached... */ + exit (0); +} -- cgit v1.2.3 From 4fc4e7ab47fef3295d0ae40e064fc99478c24e23 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 22 Jan 2003 19:47:09 +0000 Subject: Matthew Grant [zebra 17290] [PATCHES] - Fixes for problems in 0.93b portfix patch --- zebra/main.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 25d8b6de..66469a2f 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -174,7 +174,7 @@ main (int argc, char **argv) { char *p; char *vty_addr = NULL; - int vty_port = 0; + int vty_port = ZEBRA_VTY_PORT; int batch_mode = 0; int daemon_mode = 0; char *config_file = NULL; @@ -226,7 +226,15 @@ main (int argc, char **argv) pid_file = optarg; break; case 'P': + /* Deal with atoi() returning 0 on failure, and zebra not + listening on zebra port... */ + if (strcmp(optarg, "0") == 0) + { + vty_port = 0; + break; + } vty_port = atoi (optarg); + vty_port = (vty_port ? vty_port : ZEBRA_VTY_PORT); break; case 'r': retain_mode = 1; @@ -305,8 +313,7 @@ main (int argc, char **argv) pid = getpid (); /* Make vty server socket. */ - vty_serv_sock (vty_addr, - vty_port ? vty_port : ZEBRA_VTY_PORT, ZEBRA_VTYSH_PATH); + vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); while (thread_fetch (master, &thread)) thread_call (&thread); -- cgit v1.2.3 From edd7c245d3a77012abf801da00d5664ebaa5f749 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 4 Jun 2003 13:59:38 +0000 Subject: 2003-06-04 Paul Jakma * Merge of zebra privileges --- zebra/main.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 66469a2f..72b1fc4e 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -1,5 +1,4 @@ -/* - * zebra daemon main routine. +/* zebra daemon main routine. * Copyright (C) 1997, 98 Kunihiro Ishiguro * * This file is part of GNU Zebra. @@ -30,6 +29,7 @@ #include "memory.h" #include "prefix.h" #include "log.h" +#include "privs.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -62,10 +62,32 @@ struct option longopts[] = { "vty_addr", required_argument, NULL, 'A'}, { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, + { "user", required_argument, NULL, 'u'}, { "version", no_argument, NULL, 'v'}, { 0 } }; +zebra_capabilities_t _caps_p [] = +{ + ZCAP_ADMIN, + ZCAP_SYS_ADMIN, +}; + +/* zebra privileges to run with */ +struct zebra_privs_t zserv_privs = +{ +#if defined(ZEBRA_USER) && defined(ZEBRA_GROUP) + .user = ZEBRA_USER, + .group = ZEBRA_GROUP, +#endif +#ifdef VTY_GROUP + .vty_group = VTY_GROUP, +#endif + .caps_p = _caps_p, + .cap_num_p = sizeof(_caps_p)/sizeof(_caps_p[0]), + .cap_num_i = 0 +}; + /* Default configuration file path. */ char config_current[] = DEFAULT_CONFIG_FILE; char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; @@ -93,6 +115,7 @@ redistribution between different routing protocols.\n\n\ -A, --vty_addr Set vty's bind address\n\ -P, --vty_port Set vty's port number\n\ -r, --retain When program terminates, retain added route by zebra.\n\ +-u, --user User and group to run as\n\ -v, --version Print program version\n\ -h, --help Display this help and exit\n\ \n\ @@ -196,7 +219,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "bdklf:hA:P:rv", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:hA:P:ru:v", longopts, 0); if (opt == EOF) break; @@ -239,6 +262,9 @@ main (int argc, char **argv) case 'r': retain_mode = 1; break; + case 'u': + zserv_privs.user = zserv_privs.group = optarg; + break; case 'v': print_version (progname); exit (0); @@ -255,6 +281,9 @@ main (int argc, char **argv) /* Make master thread emulator. */ master = thread_master_create (); + /* privs initialise */ + zprivs_init (&zserv_privs); + /* Vty related initialize. */ signal_init (); cmd_init (1); -- cgit v1.2.3 From 41908818b8f446befc3654fa5bbc98c6c0af92a3 Mon Sep 17 00:00:00 2001 From: hasso Date: Thu, 5 Jun 2003 11:33:10 +0000 Subject: Unbreak router advertisment feature when using capabilities. --- zebra/main.c | 1 + 1 file changed, 1 insertion(+) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 72b1fc4e..85707f42 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -71,6 +71,7 @@ zebra_capabilities_t _caps_p [] = { ZCAP_ADMIN, ZCAP_SYS_ADMIN, + ZCAP_RAW, }; /* zebra privileges to run with */ -- cgit v1.2.3 From b21b19c5785487f2ff4a6ce38f45c2e6c35f4363 Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 15 Jun 2003 01:28:29 +0000 Subject: 2003-06-15 Paul Jakma * lib/vty.{c,h}: Remove vty layer depending on a 'master' global, pass the thread master in explicitly to vty_init. Sort out some header dependency problems with lib/command.h * zebra/: Move globals to struct zebrad. Update vty_init(). * (.*)/\1_main.c: update call to vty_init(). --- zebra/main.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 85707f42..c47b83e3 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -36,8 +36,11 @@ #include "zebra/debug.h" #include "zebra/rib.h" -/* Master of threads. */ -struct thread_master *master; +/* Zebra instance */ +struct zebra_t zebrad = +{ + .rtm_table_default = 0, +}; /* process id. */ pid_t old_pid; @@ -280,7 +283,7 @@ main (int argc, char **argv) } /* Make master thread emulator. */ - master = thread_master_create (); + zebrad.master = thread_master_create (); /* privs initialise */ zprivs_init (&zserv_privs); @@ -288,7 +291,7 @@ main (int argc, char **argv) /* Vty related initialize. */ signal_init (); cmd_init (1); - vty_init (); + vty_init (zebrad.master); memory_init (); /* Zebra related initialize. */ @@ -345,7 +348,7 @@ main (int argc, char **argv) /* Make vty server socket. */ vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); - while (thread_fetch (master, &thread)) + while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); /* Not reached... */ -- cgit v1.2.3 From 96735eeafe4713b60700915dd2fb6dcbd0f09c8f Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 10 Aug 2003 02:51:22 +0000 Subject: 2003-08-10 amir * Add missing 'i' to getopts, short form of --pid_file. see http://bugzilla.quagga.net/show_bug.cgi?id=25 --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index c47b83e3..c9a19eda 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -223,7 +223,7 @@ main (int argc, char **argv) { int opt; - opt = getopt_long (argc, argv, "bdklf:hA:P:ru:v", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:v", longopts, 0); if (opt == EOF) break; -- cgit v1.2.3 From d81fadfd889aa7bc657fa19752344a585e8c274a Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 14 Aug 2003 05:32:12 +0000 Subject: 2003-08-14 Paul Jakma * zebra/main.c: Fixup ZEBRA_{GROUP,USER} defines -> QUAGGA_{USER,GROUP} * bgpd/bgp_main.c: ditto * ospf6d/ospf6_main.c: ditto * ospfd/ospf_main.c: ditto * ripd/rip_main.c: ditto * ripngd/ripng_main.c: ditto * zebra/main.c: ditto --- zebra/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index c9a19eda..98227ea5 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -80,9 +80,9 @@ zebra_capabilities_t _caps_p [] = /* zebra privileges to run with */ struct zebra_privs_t zserv_privs = { -#if defined(ZEBRA_USER) && defined(ZEBRA_GROUP) - .user = ZEBRA_USER, - .group = ZEBRA_GROUP, +#if defined(QUAGGA_USER) && defined(QUAGGA_GROUP) + .user = QUAGGA_USER, + .group = QUAGGA_GROUP, #endif #ifdef VTY_GROUP .vty_group = VTY_GROUP, -- cgit v1.2.3 From 2d75d05218b76230bbd608cab8d08a5f47d77056 Mon Sep 17 00:00:00 2001 From: paul Date: Mon, 19 Jan 2004 21:31:15 +0000 Subject: 2004-01-19 Paul Jakma * tests/test-sig.c: New file, regression test for sigevents. * lib/Makefile.am: add sigevent.{c,h} * (isis|rip|ripng|ospf|ospf6|bgp)d/\1_main.c: modify for sigevents. * zebra/main.c: ditto. --- zebra/main.c | 55 +++++++++++++++++++------------------------------------ 1 file changed, 19 insertions(+), 36 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 98227ea5..a66734cc 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -30,6 +30,7 @@ #include "prefix.h" #include "log.h" #include "privs.h" +#include "sigevent.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -131,7 +132,7 @@ Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); /* SIGHUP handler. */ void -sighup (int sig) +sighup (void) { zlog_info ("SIGHUP received"); @@ -141,7 +142,7 @@ sighup (int sig) /* SIGINT handler. */ void -sigint (int sig) +sigint (void) { /* Decrared in rib.c */ void rib_close (); @@ -156,44 +157,26 @@ sigint (int sig) /* SIGUSR1 handler. */ void -sigusr1 (int sig) +sigusr1 (void) { zlog_rotate (NULL); } -/* Signale wrapper. */ -RETSIGTYPE * -signal_set (int signo, void (*func)(int)) +struct quagga_signal_t zebra_signals[] = { - int ret; - struct sigaction sig; - struct sigaction osig; - - sig.sa_handler = func; - sigemptyset (&sig.sa_mask); - sig.sa_flags = 0; -#ifdef SA_RESTART - sig.sa_flags |= SA_RESTART; -#endif /* SA_RESTART */ - - ret = sigaction (signo, &sig, &osig); - - if (ret < 0) - return (SIG_ERR); - else - return (osig.sa_handler); -} - -/* Initialization of signal handles. */ -void -signal_init () -{ - signal_set (SIGHUP, sighup); - signal_set (SIGINT, sigint); - signal_set (SIGTERM, sigint); - signal_set (SIGPIPE, SIG_IGN); - signal_set (SIGUSR1, sigusr1); -} + { + .signal = SIGHUP, + .handler = &sighup, + }, + { + .signal = SIGUSR1, + .handler = &sigusr1, + }, + { + .signal = SIGINT, + .handler = &sigusr1, + }, +}; /* Main startup routine. */ int @@ -289,7 +272,7 @@ main (int argc, char **argv) zprivs_init (&zserv_privs); /* Vty related initialize. */ - signal_init (); + signal_init (zebrad.master, Q_SIGC(zebra_signals), zebra_signals); cmd_init (1); vty_init (zebrad.master); memory_init (); -- cgit v1.2.3 From 5e4fa1646cafe9e6f8dd78501bea0d2fe1eafdb4 Mon Sep 17 00:00:00 2001 From: gdt Date: Tue, 16 Mar 2004 14:38:36 +0000 Subject: 2004-03-16 David Young * (many) reference rather than "version.h", because version.h is a generated file and not present in the source tree when using objdir builds. (committed by gdt) works fine with normal builds; didn't try objdir --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index a66734cc..07467bea 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -21,7 +21,7 @@ #include -#include "version.h" +#include #include "getopt.h" #include "command.h" #include "thread.h" -- cgit v1.2.3 From 8c903fbb11e5eed5bcf08d26c2b984d07a82e109 Mon Sep 17 00:00:00 2001 From: hasso Date: Wed, 17 Mar 2004 20:39:18 +0000 Subject: Fix bugzilla #82. --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 07467bea..9966c172 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -174,7 +174,7 @@ struct quagga_signal_t zebra_signals[] = }, { .signal = SIGINT, - .handler = &sigusr1, + .handler = &sigint, }, }; -- cgit v1.2.3 From f571dab0c677ca4f3328ea944cc59ab2269c9a5d Mon Sep 17 00:00:00 2001 From: hasso Date: Mon, 22 Mar 2004 08:55:25 +0000 Subject: Readded SIGTERM handling into sigevent stuff. Fixes bugzilla #85. --- zebra/main.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 9966c172..efc95643 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -176,6 +176,10 @@ struct quagga_signal_t zebra_signals[] = .signal = SIGINT, .handler = &sigint, }, + { + .signal = SIGTERM, + .handler = &sigint, + }, }; /* Main startup routine. */ -- cgit v1.2.3 From ca7769881ffb700c86b606ead5f4177df3c0b2a1 Mon Sep 17 00:00:00 2001 From: hasso Date: Sat, 12 Jun 2004 14:33:05 +0000 Subject: OK, here it is - irdp support. But don't expect me to fix any bugs in it. --- zebra/main.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index efc95643..3384d7dd 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -36,6 +36,7 @@ #include "zebra/zserv.h" #include "zebra/debug.h" #include "zebra/rib.h" +#include "zebra/irdp.h" /* Zebra instance */ struct zebra_t zebrad = @@ -151,6 +152,9 @@ sigint (void) if (!retain_mode) rib_close (); +#ifdef HAVE_IRDP + irdp_finish(); +#endif exit (0); } @@ -289,6 +293,9 @@ main (int argc, char **argv) zebra_vty_init (); access_list_init (); rtadv_init (); +#ifdef HAVE_IRDP + irdp_init(); +#endif /* For debug purpose. */ /* SET_FLAG (zebra_debug_event, ZEBRA_DEBUG_EVENT); */ -- cgit v1.2.3 From 320ec10a24d8dd81d0aa011dc92e07877e4e02f8 Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 20 Jun 2004 19:54:37 +0000 Subject: Removing code which looked at current dir for config file before attempting to read system one. --- zebra/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 3384d7dd..1083ae57 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -95,7 +95,6 @@ struct zebra_privs_t zserv_privs = }; /* Default configuration file path. */ -char config_current[] = DEFAULT_CONFIG_FILE; char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; /* Process ID saved for use by init system */ @@ -317,7 +316,7 @@ main (int argc, char **argv) rib_sweep_route (); /* Configuration file read*/ - vty_read_config (config_file, config_current, config_default); + vty_read_config (config_file, config_default); /* Clean up rib. */ rib_weed_tables (); -- cgit v1.2.3 From 87efd646ffef693235d9d29b005a1467373c51bd Mon Sep 17 00:00:00 2001 From: gdt Date: Wed, 30 Jun 2004 17:36:11 +0000 Subject: Add libtool support. libzebra and libospfapiclient are now built shared, and linked shared with the daemons. This reduces the memory needed when running multiple daemons; each daemon is at least 150k smaller. Static libraries are still built, and libtool should use them on platforms which don't have shared libaries. As with autoconf, the user of a distribution does not need libtool; one just needs that to build from CVS. libospf.a is still a non-shared library, and still installed, not because that makese sense, but because I don't understand why it is the way it is now. Note that the tree was tagged 'libtool-before' just before this commit. --- zebra/main.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 1083ae57..6d40d708 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -48,6 +48,9 @@ struct zebra_t zebrad = pid_t old_pid; pid_t pid; +/* Pacify zclient.o in libzebra, which expects this variable. */ +struct thread_master *master; + /* Route retain mode flag. */ int retain_mode = 0; -- cgit v1.2.3 From c34b6b577ef58e7609de1e088e7923c4c056cfeb Mon Sep 17 00:00:00 2001 From: hasso Date: Tue, 31 Aug 2004 13:41:49 +0000 Subject: Commit my hack (yes, I still call it hack) - command line switch for zebra daemon to change netlink receive buffer size. --- zebra/main.c | 56 +++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 17 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 6d40d708..0c1a7ddb 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -57,6 +57,11 @@ int retain_mode = 0; /* Don't delete kernel route. */ int keep_kernel_mode = 0; +#ifdef HAVE_NETLINK +/* Receive buffer size for netlink socket */ +u_int32_t nl_rcvbufsize = 0; +#endif /* HAVE_NETLINK */ + /* Command line options. */ struct option longopts[] = { @@ -70,6 +75,9 @@ struct option longopts[] = { "vty_addr", required_argument, NULL, 'A'}, { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, +#ifdef HAVE_NETLINK + { "nl-bufsize", no_argument, NULL, 's'}, +#endif /* HAVE_NETLINK */ { "user", required_argument, NULL, 'u'}, { "version", no_argument, NULL, 'v'}, { 0 } @@ -111,23 +119,28 @@ usage (char *progname, int status) fprintf (stderr, "Try `%s --help' for more information.\n", progname); else { - printf ("Usage : %s [OPTION...]\n\n\ -Daemon which manages kernel routing table management and \ -redistribution between different routing protocols.\n\n\ --b, --batch Runs in batch mode\n\ --d, --daemon Runs in daemon mode\n\ --f, --config_file Set configuration file name\n\ --i, --pid_file Set process identifier file name\n\ --k, --keep_kernel Don't delete old routes which installed by zebra.\n\ --l, --log_mode Set verbose log mode flag\n\ --A, --vty_addr Set vty's bind address\n\ --P, --vty_port Set vty's port number\n\ --r, --retain When program terminates, retain added route by zebra.\n\ --u, --user User and group to run as\n\ --v, --version Print program version\n\ --h, --help Display this help and exit\n\ -\n\ -Report bugs to %s\n", progname, ZEBRA_BUG_ADDRESS); + printf ("Usage : %s [OPTION...]\n\n"\ + "Daemon which manages kernel routing table management and "\ + "redistribution between different routing protocols.\n\n"\ + "-b, --batch Runs in batch mode\n"\ + "-d, --daemon Runs in daemon mode\n"\ + "-f, --config_file Set configuration file name\n"\ + "-i, --pid_file Set process identifier file name\n"\ + "-k, --keep_kernel Don't delete old routes which installed by "\ + "zebra.\n"\ + "-l, --log_mode Set verbose log mode flag\n"\ + "-A, --vty_addr Set vty's bind address\n"\ + "-P, --vty_port Set vty's port number\n"\ + "-r, --retain When program terminates, retain added route "\ + "by zebra.\n"\ + "-u, --user User and group to run as\n", progname); +#ifdef HAVE_NETLINK + printf ("-s, --nl-bufsize Set netlink receive buffer size\n"); +#endif /* HAVE_NETLINK */ + printf ("-v, --version Print program version\n"\ + "-h, --help Display this help and exit\n"\ + "\n"\ + "Report bugs to %s\n", ZEBRA_BUG_ADDRESS); } exit (status); @@ -216,7 +229,11 @@ main (int argc, char **argv) { int opt; +#ifdef HAVE_NETLINK + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:vs:", longopts, 0); +#else opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:v", longopts, 0); +#endif /* HAVE_NETLINK */ if (opt == EOF) break; @@ -259,6 +276,11 @@ main (int argc, char **argv) case 'r': retain_mode = 1; break; +#ifdef HAVE_NETLINK + case 's': + nl_rcvbufsize = atoi (optarg); + break; +#endif /* HAVE_NETLINK */ case 'u': zserv_privs.user = zserv_privs.group = optarg; break; -- cgit v1.2.3 From 18a6dce6f83dd20caf1f36c8e840868ff0bf6dbd Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 3 Oct 2004 18:18:34 +0000 Subject: Common router id. --- zebra/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 0c1a7ddb..e10755b9 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -35,7 +35,7 @@ #include "zebra/rib.h" #include "zebra/zserv.h" #include "zebra/debug.h" -#include "zebra/rib.h" +#include "zebra/router-id.h" #include "zebra/irdp.h" /* Zebra instance */ @@ -314,6 +314,7 @@ main (int argc, char **argv) rib_init (); zebra_if_init (); zebra_debug_init (); + router_id_init(); zebra_vty_init (); access_list_init (); rtadv_init (); -- cgit v1.2.3 From fce954f8de1456dd62d26b52902a4a352ef17a93 Mon Sep 17 00:00:00 2001 From: hasso Date: Thu, 7 Oct 2004 20:29:24 +0000 Subject: Fix warnings. Didn't even look at files not compiled in Linux though. --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index e10755b9..72e2c585 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -109,7 +109,7 @@ struct zebra_privs_t zserv_privs = char config_default[] = SYSCONFDIR DEFAULT_CONFIG_FILE; /* Process ID saved for use by init system */ -char *pid_file = PATH_ZEBRA_PID; +const char *pid_file = PATH_ZEBRA_PID; /* Help information display. */ static void -- cgit v1.2.3 From c065230a4c617a1cdf8813dd25384bcc9591f61a Mon Sep 17 00:00:00 2001 From: hasso Date: Thu, 25 Nov 2004 19:33:48 +0000 Subject: Make group to run daemon as configurable. Fixes #2 from Bugzilla #64. --- zebra/main.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 72e2c585..42e6bd14 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -79,6 +79,7 @@ struct option longopts[] = { "nl-bufsize", no_argument, NULL, 's'}, #endif /* HAVE_NETLINK */ { "user", required_argument, NULL, 'u'}, + { "group", required_argument, NULL, 'g'}, { "version", no_argument, NULL, 'v'}, { 0 } }; @@ -133,7 +134,8 @@ usage (char *progname, int status) "-P, --vty_port Set vty's port number\n"\ "-r, --retain When program terminates, retain added route "\ "by zebra.\n"\ - "-u, --user User and group to run as\n", progname); + "-u, --user User to run as\n"\ + "-g, --group Group to run as\n", progname); #ifdef HAVE_NETLINK printf ("-s, --nl-bufsize Set netlink receive buffer size\n"); #endif /* HAVE_NETLINK */ @@ -230,9 +232,9 @@ main (int argc, char **argv) int opt; #ifdef HAVE_NETLINK - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:vs:", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:", longopts, 0); #else - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:v", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:v", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) @@ -281,9 +283,12 @@ main (int argc, char **argv) nl_rcvbufsize = atoi (optarg); break; #endif /* HAVE_NETLINK */ - case 'u': - zserv_privs.user = zserv_privs.group = optarg; - break; + case 'u': + zserv_privs.user = optarg; + break; + case 'g': + zserv_privs.group = optarg; + break; case 'v': print_version (progname); exit (0); -- cgit v1.2.3 From 887c44a4f3d8219dc5b1c52b5dcde1f31d52b73d Mon Sep 17 00:00:00 2001 From: ajs Date: Fri, 3 Dec 2004 16:36:46 +0000 Subject: 2004-12-03 Andrew J. Schorr * bgp_main.c: (sigint) Use zlog_notice for termination message. (main) Use zlog_notice for startup announcement. * isis_main.c: (sigint,sigterm) Use zlog_notice for termination message. (terminate) This function should be static, not global. (main) Use zlog_notice for startup announcement, and remove ifdef ZEBRA_VERSION. * version.h.in: Remove declaration for pid_output_lock, this function is now static, not global. * pid_output.c: (pid_output_lock) This function should be static, not global. And remove "old umask" error message, since it was really an unimportant debug message, not an error. (pid_output) Need to declare static function pid_output_lock. * ospf6_main.c: (sigint,sigterm) Use zlog_notice for termination message. (main) Remove commented-out call to pid_output_lock (which should never be called other than from inside pid_output). And use zlog_notice to print the startup message, which now includes the vty port. * ospf_main.c: (sigint) Use zlog_notice for termination message. (main) Issue a startup announcement using zlog_notice. * rip_main.c: (sigint) Use zlog_notice for termination message. (main) Add a startup announcement using zlog_notice. * ripng_main.c: (sighup) Remove spurious terminating message. (sigint) Use zlog_notice for termination message. (main) Issue a startup announcement using zlog_notice. * main.c: (sigint) Use zlog_notice for termination message. (main) Add a startup announcement using zlog_notice. --- zebra/main.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 42e6bd14..96420da6 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -165,7 +165,7 @@ sigint (void) /* Decrared in rib.c */ void rib_close (); - zlog_info ("Terminating on signal"); + zlog_notice ("Terminating on signal"); if (!retain_mode) rib_close (); @@ -372,6 +372,9 @@ main (int argc, char **argv) /* Make vty server socket. */ vty_serv_sock (vty_addr, vty_port, ZEBRA_VTYSH_PATH); + /* Print banner. */ + zlog_notice ("Zebra %s starting: vty@%d", QUAGGA_VERSION, vty_port); + while (thread_fetch (zebrad.master, &thread)) thread_call (&thread); -- cgit v1.2.3 From 274a4a4447b13f89f8237156a887d05a24a73cc6 Mon Sep 17 00:00:00 2001 From: ajs Date: Tue, 7 Dec 2004 15:39:31 +0000 Subject: 2004-12-07 Andrew J. Schorr * bgp_main.c: (main) The 2nd argument to openzlog has been removed. * isis_main.c: (main) The 2nd argument to openzlog has been removed. * ospf6_main.c: (main) The 2nd argument to openzlog has been removed. Note that stdout logging will no longer be enabled by default when not running as a daemon. * ospf_main.c: (main) The 2nd argument to openzlog has been removed. * rip_main.c: (main) The 2nd argument to openzlog has been removed. * ripng_main.c: (main) The 2nd argument to openzlog has been removed. * main.c: (main) The 2nd argument to openzlog has been removed. So stdout logging will no longer be enabled by default. * irdp_main.c: (irdp_finish) Reduce severity of shutdown message from LOG_WARNING to LOG_INFO. * vtysh.c: Make several functions static instead of global. Added several commands to support destination-specific logging levels. (vtysh_completion) This function is unused, so comment it out. * basic.texi: Document new logging features. Separate basic config commands from basic VTY commands. * log.h: Replace struct zlog flags and maskpri fields with maxlvl array to support individual logging levels for each destination. Remove the 2nd argument to openzlog since the default logging config should be standardized inside the library. Replaced the zlog_set_flag and zlog_reset_flag functions with zlog_set_level. And zlog_set_file now requires an additional log_level argument. Declare zlog_proto_names for use inside command.c in the "show logging" command. Added defines useful for command construction. * log.c: (vzlog) Decide where to send the message based on the individual logging levels configured for each destination. Remove support for ZLOG_STDERR since it was never actually used. Support record-priority for terminal monitors. (zlog_signal,zlog_backtrace_sigsafe) Support destination-specific logging levels. Remove stderr support (was never used). Added support for terminal monitor logging. (_zlog_assert_failed) Increase message severity to LOG_EMERG. (openzlog) Remove 2nd argument since default config should be standardized in library. By default, terminal monitoring is set to debug, and all other logging is disabled. (zlog_set_flag,zlog_reset_flag) Removed. (zlog_set_level) New function to replace zlog_set_flag and zlog_reset_flag. Supports destination-specific logging levels. (zlog_set_file,zlog_reset_file) Support file-specific logging level. (zlog_rotate) Log an error message if fopen fails, and support new file-specific logging level. * command.h: Change DEFUN_CMD_FUNC_DECL and DEFUN_CMD_FUNC_TEXT so that command functions will be static instead of global. Remove declarations for config_exit and config_help. Define new macros DEFUNSH_ATTR, DEFUNSH_HIDDEN, and DEFUNSH_DEPRECATED so we can have deprecated commands in vtysh. Similarly, for completeness, define macros ALIAS_SH, ALIAS_SH_HIDDEN, and ALIAS_SH_DEPRECATED. Also, fix bug in ALIAS_ATTR macro (didn't matter because it was never used). * command.c: Make many functions static instead of global. (facility_name,facility_match,level_match) New functions to support enhanced destination-specific logging levels. (config_write_host) Support new destination-specific logging levels. (config_logmsg) Added new "logmsg" command to help test logging system. (show_logging) Added "show logging" command to show the current configuration of the logging system. (config_log_stdout_level) Support explicit stdout logging level. (no_config_log_stdout) Now takes optional LEVEL arg. (config_log_monitor,config_log_monitor_level,no_config_log_monitor) New commands creating new "log monitor" commands to set terminal monitoring log level. (config_log_file_level) Support explicit file logging level. (config_log_syslog_level) Support explicit syslog logging level. (config_log_facility,no_config_log_facility) Implement new "log facility" command. (cmd_init) Add hooks for new commands: "show logging", "logmsg", "log stdout ", "log monitor", "log monitor ", "no log monitor", "log file ", "no log file ", "log syslog ", "log facility", and "no log facility". * vty.h: Added a "level" argument to vty_log so it can support "log record-priority". Declare new function vty_log_fixed for use in signal handlers. * vty.c: (vty_log,vty_log_out) Added a "level" argument to support "log record-priority" for vty terminal monitors. (vty_down_level) Use config_exit_cmd.func instead of calling config_exit directly (since command functions will now be static instead of global). (vty_log_fixed) New function to send terminal monitor messages from inside a signal handler. --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 96420da6..019e8d20 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -224,7 +224,7 @@ main (int argc, char **argv) /* preserve my name */ progname = ((p = strrchr (argv[0], '/')) ? ++p : argv[0]); - zlog_default = openzlog (progname, ZLOG_STDOUT, ZLOG_ZEBRA, + zlog_default = openzlog (progname, ZLOG_ZEBRA, LOG_CONS|LOG_NDELAY|LOG_PID, LOG_DAEMON); while (1) -- cgit v1.2.3 From 583d800c11922018af02420a758f974be691065f Mon Sep 17 00:00:00 2001 From: hasso Date: Sun, 16 Jan 2005 23:34:02 +0000 Subject: * main.c: With --nl-bufsize argument is required. [pullup candidate] --- zebra/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 019e8d20..540bf316 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -76,7 +76,7 @@ struct option longopts[] = { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, #ifdef HAVE_NETLINK - { "nl-bufsize", no_argument, NULL, 's'}, + { "nl-bufsize", required_argument, NULL, 's'}, #endif /* HAVE_NETLINK */ { "user", required_argument, NULL, 'u'}, { "group", required_argument, NULL, 'g'}, -- cgit v1.2.3 From a1ac18c4d5b4f8f4f279efb2ae12b46258f22282 Mon Sep 17 00:00:00 2001 From: paul Date: Tue, 28 Jun 2005 17:17:12 +0000 Subject: 2005-06-28 Paul Jakma * (global) Extern and static'ification, with related fixups of declarations, ensuring files include their own headers, etc. if_ioctl.c: (interface_info_ioctl) fix obvious arg mis-order in list loop --- zebra/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 540bf316..acfde80a 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -37,6 +37,7 @@ #include "zebra/debug.h" #include "zebra/router-id.h" #include "zebra/irdp.h" +#include "zebra/rtadv.h" /* Zebra instance */ struct zebra_t zebrad = @@ -149,7 +150,7 @@ usage (char *progname, int status) } /* SIGHUP handler. */ -void +static void sighup (void) { zlog_info ("SIGHUP received"); @@ -159,7 +160,7 @@ sighup (void) } /* SIGINT handler. */ -void +static void sigint (void) { /* Decrared in rib.c */ @@ -177,7 +178,7 @@ sigint (void) } /* SIGUSR1 handler. */ -void +static void sigusr1 (void) { zlog_rotate (NULL); @@ -215,8 +216,6 @@ main (int argc, char **argv) char *config_file = NULL; char *progname; struct thread thread; - void rib_weed_tables (); - void zebra_vty_init (); /* Set umask before anything for security */ umask (0027); -- cgit v1.2.3 From ceacedba227e77156f92f7676b274c48a2817e8f Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 29 Sep 2005 14:39:32 +0000 Subject: 2005-09-29 Paul Jakma * configure.ac: Add the test for Solaris least-privileges. Set defines for whether capabilities are supported and whether of the linux or solaris variety. Add missing-prototypes, missing-declarations, char-subscripts and cast-qual warnings to default cflags, cause Hasso enjoys warnings, and we really should clean the remaining ones up. (ie isisd..). * (*/*main.c) Update the zebra_capabilities_t arrays in the various daemons to match the changes made in lib/privs.h. * zebra.h: Solaris capabilities requires priv.h to be included. * privs.{c,h}: Add support for Solaris Least-Privileges. privs.h: Reduce some of the abstract capabilities, which do not have rough equivalents on both systems. Rename the net related caps to _NET, as they should have been in first place. (zprivs_terminate) should take the zebra_privs_t as argument so that it can update change pointer. Add an additional privilege state, ZPRIVS_UNKNOWN. * privs.c: (various capability functions) Add Solaris privileges variants. (zprivs_state) Use privs.c specific generic types to represent various capability/privilege related types, so that each can be typedef'd as appropriate on each platform. (zprivs_null_state) static added, to hold the state the null method should report (should be raised by default, and LOWERED if zprivs_terminate has been called) (zprivs_state_null) Report back the zprivs_null_state. (cap_map) Make it able to map abstract capability to multiple system capabilities. (zcaps2sys) Map to abstract capabilities to multiple system privileges/capabilities. (zprivs_init) move capability related init to seperate function, zprivs_caps_init. (zprivs_terminate) ditto, moved to zprivs_caps_terminate. Set the change_state callback to the NULL state, so the user can continue to run and use the callbacks. --- zebra/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index acfde80a..67108c4e 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -87,9 +87,9 @@ struct option longopts[] = zebra_capabilities_t _caps_p [] = { - ZCAP_ADMIN, + ZCAP_NET_ADMIN, ZCAP_SYS_ADMIN, - ZCAP_RAW, + ZCAP_NET_RAW, }; /* zebra privileges to run with */ -- cgit v1.2.3 From e8e1946edf6ba87ef53832cdceccc39d7f0c3f26 Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 19 Jan 2006 20:16:55 +0000 Subject: [compiler] miscellaneous trivial compiler warning fixes 2006-01-19 Paul Jakma * (general) various miscellaneous compiler warning fixes. Remove redundant break statements from switch clauses which return. return from main, not exit, cause it annoys SOS. Remove stray semi-colons which cause empty-statement warnings. * zebra/main.c: (sighup) remove private declaration of external function. --- zebra/main.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 67108c4e..dbe1b537 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -163,9 +163,6 @@ sighup (void) static void sigint (void) { - /* Decrared in rib.c */ - void rib_close (); - zlog_notice ("Terminating on signal"); if (!retain_mode) @@ -378,5 +375,5 @@ main (int argc, char **argv) thread_call (&thread); /* Not reached... */ - exit (0); + return 0; } -- cgit v1.2.3 From 70ad2da67e6edee613c6eefae9480c9e9955c2fc Mon Sep 17 00:00:00 2001 From: paul Date: Sun, 15 Oct 2006 23:35:57 +0000 Subject: [daemon startup] Add --dry-run/-C argument to daemons, to check config file syntax 2006-10-04 Oliver Hookins * bgpd/bgp_main.c: Add configuration check option, with '-C' rather than '-c' for consistency between daemons. * isisd/isis_main.c: ditto * ospf6d/ospf6_main.c: ditto * ospfd/ospf_main.c: ditto * ripngd/ripng_main.c: ditto * vtysh/vtysh_main.c: ditto * ripd/rip_main.c: Change the config check option to '-C' and tidy up the code. * zebra/main.c: ditto 2006-10-04 Stergiakis Alexandros * ripd/rip_main.c: This trivial patch introduces a new command-line option '-c', which instructs zebra/ripd to check its configuration file for validity, print any error message, and then exit. This is useful when the configuration file is edited by hand or otherwise, and you simply want to validate it without any other effect. * zebra/main.c: ditto --- zebra/main.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index dbe1b537..ed45bd13 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -76,6 +76,7 @@ struct option longopts[] = { "vty_addr", required_argument, NULL, 'A'}, { "vty_port", required_argument, NULL, 'P'}, { "retain", no_argument, NULL, 'r'}, + { "dryrun", no_argument, NULL, 'C'}, #ifdef HAVE_NETLINK { "nl-bufsize", required_argument, NULL, 's'}, #endif /* HAVE_NETLINK */ @@ -131,6 +132,7 @@ usage (char *progname, int status) "-k, --keep_kernel Don't delete old routes which installed by "\ "zebra.\n"\ "-l, --log_mode Set verbose log mode flag\n"\ + "-C, --dryrun Check configuration for validity and exit\n"\ "-A, --vty_addr Set vty's bind address\n"\ "-P, --vty_port Set vty's port number\n"\ "-r, --retain When program terminates, retain added route "\ @@ -208,6 +210,7 @@ main (int argc, char **argv) char *p; char *vty_addr = NULL; int vty_port = ZEBRA_VTY_PORT; + int dryrun = 0; int batch_mode = 0; int daemon_mode = 0; char *config_file = NULL; @@ -228,9 +231,9 @@ main (int argc, char **argv) int opt; #ifdef HAVE_NETLINK - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vs:C", longopts, 0); #else - opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:v", longopts, 0); + opt = getopt_long (argc, argv, "bdklf:i:hA:P:ru:g:vC", longopts, 0); #endif /* HAVE_NETLINK */ if (opt == EOF) @@ -248,6 +251,9 @@ main (int argc, char **argv) case 'k': keep_kernel_mode = 1; break; + case 'C': + dryrun = 1; + break; case 'l': /* log_mode = 1; */ break; @@ -345,6 +351,10 @@ main (int argc, char **argv) /* Configuration file read*/ vty_read_config (config_file, config_default); + /* Don't start execution if we are in dry-run mode */ + if (dryrun) + return(0); + /* Clean up rib. */ rib_weed_tables (); -- cgit v1.2.3 From fb6ce7ca5dfee02536e32ec5c76be7ae8737cb4e Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 2 May 2007 16:05:35 +0000 Subject: [zebra] Routemap support on received routes, with 'set src' command (linux) 2007-05-01 David L Stevens * (general) These changes collectively add route-map and prefix-list support to zebra and fix a bug in "show route-map" (with no argument). * doc/main.texi: added route-map, prefix-list, ip protocol and set src documentation * lib/command.h: added PROTOCOL_NODE type * lib/log.c: (proto_name2num) new function, protocol name to number translation. * lib/routemap.c: (vty_show_route_map) fixed "show route-map" without route-map name * lib/routemap.h: added RMAP_ZEBRA type * lib/zebra.h: added proto_name2num() prototype * vtysh/extract.pl.in: added VTYSH_ZEBRA flag for route-map and plist * vtysh/Makefile.am: added zebra_routemap.c * vtysh/vtysh.h: added VTYSH_ZEBRA flag to VTYSH_RMAP * zebra/connected.c: (connected_up_ipv4) added src preference argument to rib_add_ipv4() * zebra/kernel_socket.c: (rtm_read) ditto * zebra/main.c: added prefix list initialization * zebra/Makefile.am: added zebra_routemap.c source file * zebra/rib.h: added generic address union "g_addr" and use in existing places that had an explicit union. Added "src" to struct nexthop. Added preferred src arg to nexthop_ipv4_add and rib_add_ipv4. * zebra/rt_netlink.c: (netlink_routing_table) set preferred source on netlink messages. (netlink_route_change) ditto (netlink_route_multipath) ditto. * zebra/rtread_getmsg.c: (handle_route_entry) added (NULL) src to rib_add_ipv4() call. * zebra/rtread_proc.c: (proc_route_read) ditto * zebra/zebra_rib.c: (nexthop_ipv4_add) add src argument. (nexthop_ipv4_ifindex_add) ditto (rib_add_ipv4) ditto (nexthop_active_check) Add route-map processing. * zebra/zebra_routemap.c: new file for zebra route-map commands. * zebra/zebra_vty.c: (ip_protocol_cmd) Apply route-map to protocol (vty_show_ip_route_detail) added "src" printing (vty_show_ip_route) ditto (show_ip_protocol_cmd) new command, list routemaps. (config_write_protocol) write out routemap protocl config. (zebra_vty_init) Install the new routemap protocol commands. * zebra/zserv.c: (zread_ipv4_add) added (NULL) src arg (zebra_init) init zebra route-maps. * zebra/zserv.h: add zebra_route_map_init --- zebra/main.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index ed45bd13..7d895799 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -29,6 +29,7 @@ #include "memory.h" #include "prefix.h" #include "log.h" +#include "plist.h" #include "privs.h" #include "sigevent.h" @@ -324,6 +325,7 @@ main (int argc, char **argv) router_id_init(); zebra_vty_init (); access_list_init (); + prefix_list_init (); rtadv_init (); #ifdef HAVE_IRDP irdp_init(); -- cgit v1.2.3 From c3273834bc2fc09d74212a0a5723cf1808b58204 Mon Sep 17 00:00:00 2001 From: pilot Date: Fri, 14 Sep 2007 13:31:52 +0000 Subject: + fixed bug #402: now the second zebra process doesn't destroy routes of the first one before dying + we are not going to receive routing messages originated by old_pid, because rib_sweep_route() is called after damon() now. This will allow to drop old_pid completely soon. --- zebra/main.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 7d895799..2f966523 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -346,11 +346,13 @@ main (int argc, char **argv) zebra_snmp_init (); #endif /* HAVE_SNMP */ - /* Clean up self inserted route. */ - if (! keep_kernel_mode) - rib_sweep_route (); - - /* Configuration file read*/ + /* 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 + * zebra->ribq structure until we enter the main execution loop. + * The notifications from kernel will show originating PID equal + * to that after daemon() completes (if ever called). + */ vty_read_config (config_file, config_default); /* Don't start execution if we are in dry-run mode */ @@ -374,6 +376,17 @@ main (int argc, char **argv) /* Output pid of zebra. */ pid_output (pid_file); + /* After we have successfully acquired the pidfile, we can be sure + * about being the only copy of zebra process, which is submitting + * changes to the FIB. + * Clean up zebra-originated routes. The requests will be sent to OS + * immediately, so originating PID in notifications from kernel + * will be equal to the current getpid(). To know about such routes, + * we have to have route_read() called before. + */ + if (! keep_kernel_mode) + rib_sweep_route (); + /* Needed for BSD routing socket. */ pid = getpid (); -- cgit v1.2.3 From d3c31e99d04a740b1ec3077f48c5abb075634e6b Mon Sep 17 00:00:00 2001 From: pilot Date: Fri, 14 Sep 2007 14:56:28 +0000 Subject: + sayonara old_pid! --- zebra/main.c | 4 ---- 1 file changed, 4 deletions(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 2f966523..6019260f 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -47,7 +47,6 @@ struct zebra_t zebrad = }; /* process id. */ -pid_t old_pid; pid_t pid; /* Pacify zclient.o in libzebra, which expects this variable. */ @@ -366,9 +365,6 @@ main (int argc, char **argv) if (batch_mode) exit (0); - /* Needed for BSD routing socket. */ - old_pid = getpid (); - /* Daemonize. */ if (daemon_mode) daemon (0, 0); -- cgit v1.2.3 From a73770abf4e87b073ca51ca0cd4171d712ca9bff Mon Sep 17 00:00:00 2001 From: paul Date: Thu, 29 May 2008 18:29:16 +0000 Subject: [daemons] Sanity check port number arguments before use 2008-05-29 Martin Nagy * */*main.c: Sanity check port numbers before using. --- zebra/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'zebra/main.c') diff --git a/zebra/main.c b/zebra/main.c index 6019260f..61750f1d 100644 --- a/zebra/main.c +++ b/zebra/main.c @@ -275,7 +275,8 @@ main (int argc, char **argv) break; } vty_port = atoi (optarg); - vty_port = (vty_port ? vty_port : ZEBRA_VTY_PORT); + if (vty_port <= 0 || vty_port > 0xffff) + vty_port = ZEBRA_VTY_PORT; break; case 'r': retain_mode = 1; -- cgit v1.2.3