mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
lib: shuffle around command line options
New `FRR_NO_SPLIT_CONFIG` flag for newly added daemons where we're just rolling without split config and always expect configs to be loaded via vtysh/integrated config. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
This commit is contained in:
parent
62646e1350
commit
b1dc60f4ab
61
lib/libfrr.c
61
lib/libfrr.c
@ -121,7 +121,6 @@ static const struct option lo_always[] = {
|
|||||||
{"scriptdir", required_argument, NULL, OPTION_SCRIPTDIR},
|
{"scriptdir", required_argument, NULL, OPTION_SCRIPTDIR},
|
||||||
{"log", required_argument, NULL, OPTION_LOG},
|
{"log", required_argument, NULL, OPTION_LOG},
|
||||||
{"log-level", required_argument, NULL, OPTION_LOGLEVEL},
|
{"log-level", required_argument, NULL, OPTION_LOGLEVEL},
|
||||||
{"tcli", no_argument, NULL, OPTION_TCLI},
|
|
||||||
{"command-log-always", no_argument, NULL, OPTION_LOGGING},
|
{"command-log-always", no_argument, NULL, OPTION_LOGGING},
|
||||||
{"limit-fds", required_argument, NULL, OPTION_LIMIT_FDS},
|
{"limit-fds", required_argument, NULL, OPTION_LIMIT_FDS},
|
||||||
{NULL}};
|
{NULL}};
|
||||||
@ -138,31 +137,43 @@ static const struct optspec os_always = {
|
|||||||
" --scriptdir Override scripts directory\n"
|
" --scriptdir Override scripts directory\n"
|
||||||
" --log Set Logging to stdout, syslog, or file:<name>\n"
|
" --log Set Logging to stdout, syslog, or file:<name>\n"
|
||||||
" --log-level Set Logging Level to use, debug, info, warn, etc\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",
|
" --limit-fds Limit number of fds supported\n",
|
||||||
lo_always};
|
lo_always};
|
||||||
|
|
||||||
|
|
||||||
static const struct option lo_cfg_pid_dry[] = {
|
static const struct option lo_cfg[] = {
|
||||||
{"pid_file", required_argument, NULL, 'i'},
|
|
||||||
{"config_file", required_argument, NULL, 'f'},
|
{"config_file", required_argument, NULL, 'f'},
|
||||||
|
{"dryrun", no_argument, NULL, 'C'},
|
||||||
|
{NULL}};
|
||||||
|
static const struct optspec os_cfg = {
|
||||||
|
"f:C",
|
||||||
|
" -f, --config_file Set configuration 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
|
#ifdef HAVE_SQLITE3
|
||||||
{"db_file", required_argument, NULL, OPTION_DB_FILE},
|
{"db_file", required_argument, NULL, OPTION_DB_FILE},
|
||||||
#endif
|
#endif
|
||||||
{"dryrun", no_argument, NULL, 'C'},
|
|
||||||
{"terminal", no_argument, NULL, 't'},
|
|
||||||
{NULL}};
|
{NULL}};
|
||||||
static const struct optspec os_cfg_pid_dry = {
|
static const struct optspec os_fullcli = {
|
||||||
"f:i:Ct",
|
"t",
|
||||||
" -f, --config_file Set configuration file name\n"
|
" --tcli Use transaction-based CLI\n"
|
||||||
" -i, --pid_file Set process identifier file name\n"
|
|
||||||
#ifdef HAVE_SQLITE3
|
|
||||||
" --db_file Set database file name\n"
|
|
||||||
#endif
|
|
||||||
" -C, --dryrun Check configuration for validity and exit\n"
|
|
||||||
" -t, --terminal Open terminal session on stdio\n"
|
" -t, --terminal Open terminal session on stdio\n"
|
||||||
" -d -t Daemonize after terminal session ends\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[] = {
|
static const struct option lo_zclient[] = {
|
||||||
@ -320,8 +331,12 @@ void frr_preinit(struct frr_daemon_info *daemon, int argc, char **argv)
|
|||||||
umask(0027);
|
umask(0027);
|
||||||
|
|
||||||
opt_extend(&os_always);
|
opt_extend(&os_always);
|
||||||
if (!(di->flags & FRR_NO_CFG_PID_DRY))
|
if (!(di->flags & FRR_NO_SPLIT_CONFIG))
|
||||||
opt_extend(&os_cfg_pid_dry);
|
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))
|
if (!(di->flags & FRR_NO_PRIVSEP))
|
||||||
opt_extend(&os_user);
|
opt_extend(&os_user);
|
||||||
if (!(di->flags & FRR_NO_ZCLIENT))
|
if (!(di->flags & FRR_NO_ZCLIENT))
|
||||||
@ -459,12 +474,12 @@ static int frr_opt(int opt)
|
|||||||
frr_defaults_profile_set(optarg);
|
frr_defaults_profile_set(optarg);
|
||||||
break;
|
break;
|
||||||
case 'i':
|
case 'i':
|
||||||
if (di->flags & FRR_NO_CFG_PID_DRY)
|
if (di->flags & FRR_NO_PID)
|
||||||
return 1;
|
return 1;
|
||||||
di->pid_file = optarg;
|
di->pid_file = optarg;
|
||||||
break;
|
break;
|
||||||
case 'f':
|
case 'f':
|
||||||
if (di->flags & FRR_NO_CFG_PID_DRY)
|
if (di->flags & FRR_NO_SPLIT_CONFIG)
|
||||||
return 1;
|
return 1;
|
||||||
di->config_file = optarg;
|
di->config_file = optarg;
|
||||||
break;
|
break;
|
||||||
@ -497,18 +512,18 @@ static int frr_opt(int opt)
|
|||||||
break;
|
break;
|
||||||
#ifdef HAVE_SQLITE3
|
#ifdef HAVE_SQLITE3
|
||||||
case OPTION_DB_FILE:
|
case OPTION_DB_FILE:
|
||||||
if (di->flags & FRR_NO_CFG_PID_DRY)
|
if (di->flags & FRR_NO_PID)
|
||||||
return 1;
|
return 1;
|
||||||
di->db_file = optarg;
|
di->db_file = optarg;
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case 'C':
|
case 'C':
|
||||||
if (di->flags & FRR_NO_CFG_PID_DRY)
|
if (di->flags & FRR_NO_SPLIT_CONFIG)
|
||||||
return 1;
|
return 1;
|
||||||
di->dryrun = true;
|
di->dryrun = true;
|
||||||
break;
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
if (di->flags & FRR_NO_CFG_PID_DRY)
|
if (di->flags & FRR_LIMITED_CLI)
|
||||||
return 1;
|
return 1;
|
||||||
di->terminal = true;
|
di->terminal = true;
|
||||||
break;
|
break;
|
||||||
@ -986,7 +1001,7 @@ void frr_config_fork(void)
|
|||||||
{
|
{
|
||||||
hook_call(frr_late_init, master);
|
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 */
|
/* Don't start execution if we are in dry-run mode */
|
||||||
if (di->dryrun) {
|
if (di->dryrun) {
|
||||||
frr_config_read_in(NULL);
|
frr_config_read_in(NULL);
|
||||||
|
@ -40,15 +40,17 @@ extern "C" {
|
|||||||
#define FRR_NO_PRIVSEP (1 << 0)
|
#define FRR_NO_PRIVSEP (1 << 0)
|
||||||
#define FRR_NO_TCPVTY (1 << 1)
|
#define FRR_NO_TCPVTY (1 << 1)
|
||||||
#define FRR_LIMITED_CLI (1 << 2)
|
#define FRR_LIMITED_CLI (1 << 2)
|
||||||
#define FRR_NO_CFG_PID_DRY (1 << 3)
|
#define FRR_NO_SPLIT_CONFIG (1 << 3)
|
||||||
#define FRR_NO_ZCLIENT (1 << 4)
|
#define FRR_NO_PID (1 << 4)
|
||||||
|
#define FRR_NO_CFG_PID_DRY (FRR_NO_PID | FRR_NO_SPLIT_CONFIG)
|
||||||
|
#define FRR_NO_ZCLIENT (1 << 5)
|
||||||
/* If FRR_DETACH_LATER is used, the daemon will keep its parent running
|
/* If FRR_DETACH_LATER is used, the daemon will keep its parent running
|
||||||
* until frr_detach() is called. Normally "somedaemon -d" returns once the
|
* until frr_detach() is called. Normally "somedaemon -d" returns once the
|
||||||
* main event loop is reached in the daemon; use this for extra startup bits.
|
* main event loop is reached in the daemon; use this for extra startup bits.
|
||||||
*
|
*
|
||||||
* Does nothing if -d isn't used.
|
* Does nothing if -d isn't used.
|
||||||
*/
|
*/
|
||||||
#define FRR_DETACH_LATER (1 << 5)
|
#define FRR_DETACH_LATER (1 << 6)
|
||||||
|
|
||||||
enum frr_cli_mode {
|
enum frr_cli_mode {
|
||||||
FRR_CLI_CLASSIC = 0,
|
FRR_CLI_CLASSIC = 0,
|
||||||
|
Loading…
Reference in New Issue
Block a user