diff options
Diffstat (limited to 'lib/libfrr.c')
| -rw-r--r-- | lib/libfrr.c | 66 |
1 files changed, 43 insertions, 23 deletions
diff --git a/lib/libfrr.c b/lib/libfrr.c index 9b05bb4fbf..89bbe6de2e 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -116,53 +116,66 @@ static const struct option lo_always[] = { {"module", no_argument, NULL, 'M'}, {"profile", required_argument, NULL, 'F'}, {"pathspace", required_argument, NULL, 'N'}, + {"vrfdefaultname", required_argument, NULL, 'o'}, {"vty_socket", required_argument, NULL, OPTION_VTYSOCK}, {"moduledir", required_argument, NULL, OPTION_MODULEDIR}, {"scriptdir", required_argument, NULL, OPTION_SCRIPTDIR}, {"log", required_argument, NULL, OPTION_LOG}, {"log-level", required_argument, NULL, OPTION_LOGLEVEL}, - {"tcli", no_argument, NULL, OPTION_TCLI}, {"command-log-always", no_argument, NULL, OPTION_LOGGING}, {"limit-fds", required_argument, NULL, OPTION_LIMIT_FDS}, {NULL}}; static const struct optspec os_always = { - "hvdM:F:N:", + "hvdM:F:N:o:", " -h, --help Display this help and exit\n" " -v, --version Print program version\n" " -d, --daemon Runs in daemon mode\n" " -M, --module Load specified module\n" " -F, --profile Use specified configuration profile\n" " -N, --pathspace Insert prefix into config & socket paths\n" + " -o, --vrfdefaultname Set default VRF name.\n" " --vty_socket Override vty socket path\n" " --moduledir Override modules directory\n" " --scriptdir Override scripts directory\n" " --log Set Logging to stdout, syslog, or file:<name>\n" " --log-level Set Logging Level to use, debug, info, warn, etc\n" - " --tcli Use transaction-based CLI\n" " --limit-fds Limit number of fds supported\n", lo_always}; -static const struct option lo_cfg_pid_dry[] = { - {"pid_file", required_argument, NULL, 'i'}, +static const struct option lo_cfg[] = { {"config_file", required_argument, NULL, 'f'}, -#ifdef HAVE_SQLITE3 - {"db_file", required_argument, NULL, OPTION_DB_FILE}, -#endif {"dryrun", no_argument, NULL, 'C'}, - {"terminal", no_argument, NULL, 't'}, {NULL}}; -static const struct optspec os_cfg_pid_dry = { - "f:i:Ct", +static const struct optspec os_cfg = { + "f:C", " -f, --config_file Set configuration file name\n" - " -i, --pid_file Set process identifier file name\n" + " -C, --dryrun Check configuration for validity and exit\n", + lo_cfg}; + + +static const struct option lo_fullcli[] = { + {"terminal", no_argument, NULL, 't'}, + {"tcli", no_argument, NULL, OPTION_TCLI}, #ifdef HAVE_SQLITE3 - " --db_file Set database file name\n" + {"db_file", required_argument, NULL, OPTION_DB_FILE}, #endif - " -C, --dryrun Check configuration for validity and exit\n" + {NULL}}; +static const struct optspec os_fullcli = { + "t", + " --tcli Use transaction-based CLI\n" " -t, --terminal Open terminal session on stdio\n" " -d -t Daemonize after terminal session ends\n", - lo_cfg_pid_dry}; + lo_fullcli}; + + +static const struct option lo_pid[] = { + {"pid_file", required_argument, NULL, 'i'}, + {NULL}}; +static const struct optspec os_pid = { + "i:", + " -i, --pid_file Set process identifier file name\n", + lo_pid}; static const struct option lo_zclient[] = { @@ -320,8 +333,12 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv) umask(0027); opt_extend(&os_always); - if (!(di->flags & FRR_NO_CFG_PID_DRY)) - opt_extend(&os_cfg_pid_dry); + if (!(di->flags & FRR_NO_SPLIT_CONFIG)) + opt_extend(&os_cfg); + if (!(di->flags & FRR_LIMITED_CLI)) + opt_extend(&os_fullcli); + if (!(di->flags & FRR_NO_PID)) + opt_extend(&os_pid); if (!(di->flags & FRR_NO_PRIVSEP)) opt_extend(&os_user); if (!(di->flags & FRR_NO_ZCLIENT)) @@ -459,12 +476,12 @@ static int frr_opt(int opt) frr_defaults_profile_set(optarg); break; case 'i': - if (di->flags & FRR_NO_CFG_PID_DRY) + if (di->flags & FRR_NO_PID) return 1; di->pid_file = optarg; break; case 'f': - if (di->flags & FRR_NO_CFG_PID_DRY) + if (di->flags & FRR_NO_SPLIT_CONFIG) return 1; di->config_file = optarg; break; @@ -495,20 +512,23 @@ static int frr_opt(int opt) snprintf(pidfile_default, sizeof(pidfile_default), "%s/%s.pid", frr_vtydir, di->name); break; + case 'o': + vrf_set_default_name(optarg); + break; #ifdef HAVE_SQLITE3 case OPTION_DB_FILE: - if (di->flags & FRR_NO_CFG_PID_DRY) + if (di->flags & FRR_NO_PID) return 1; di->db_file = optarg; break; #endif case 'C': - if (di->flags & FRR_NO_CFG_PID_DRY) + if (di->flags & FRR_NO_SPLIT_CONFIG) return 1; di->dryrun = true; break; case 't': - if (di->flags & FRR_NO_CFG_PID_DRY) + if (di->flags & FRR_LIMITED_CLI) return 1; di->terminal = true; break; @@ -986,7 +1006,7 @@ void frr_config_fork(void) { hook_call(frr_late_init, master); - if (!(di->flags & FRR_NO_CFG_PID_DRY)) { + if (!(di->flags & FRR_NO_SPLIT_CONFIG)) { /* Don't start execution if we are in dry-run mode */ if (di->dryrun) { frr_config_read_in(NULL); |
