summaryrefslogtreecommitdiff
path: root/zebra/main.c
diff options
context:
space:
mode:
authorPaul Jakma <paul.jakma@sun.com>2006-10-15 23:35:57 +0000
committerPaul Jakma <paul.jakma@sun.com>2006-10-15 23:35:57 +0000
commit876b8be0ab24721e8f94d47dde022563f76db992 (patch)
tree60afcf14974d39a081b64c71191038701e73a3f5 /zebra/main.c
parent98954844ae56d142e96341d5dff959ec5518111e (diff)
[daemon startup] Add --dry-run/-C argument to daemons, to check config file syntax
2006-10-04 Oliver Hookins <ohookins@gmail.com> * 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 <astergiakis@antcor.com> * 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
Diffstat (limited to 'zebra/main.c')
-rw-r--r--zebra/main.c14
1 files changed, 12 insertions, 2 deletions
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 ();