int ret;
const char *fname = argv[1]->arg;
- ret = vtysh_read_config(fname);
+ ret = vtysh_read_config(fname, true);
/* Return to enable mode - the 'read_config' api leaves us up a level */
vtysh_execute_no_pager("enable");
int vtysh_mark_file(const char *filename);
-int vtysh_read_config(const char *);
+int vtysh_read_config(const char *filename, bool dry_run);
int vtysh_write_config_integrated(void);
void vtysh_config_parse_line(void *, const char *);
}
/* Read up configuration file from file_name. */
-static int vtysh_read_file(FILE *confp)
+static int vtysh_read_file(FILE *confp, bool dry_run)
{
struct vty *vty;
int ret;
vtysh_execute_no_pager("enable");
vtysh_execute_no_pager("configure terminal");
- vtysh_execute_no_pager("XFRR_start_configuration");
+ if (!dry_run)
+ vtysh_execute_no_pager("XFRR_start_configuration");
/* Execute configuration file. */
ret = vtysh_config_from_file(vty, confp);
- vtysh_execute_no_pager("XFRR_end_configuration");
+ if (!dry_run)
+ vtysh_execute_no_pager("XFRR_end_configuration");
vtysh_execute_no_pager("end");
vtysh_execute_no_pager("disable");
}
/* Read up configuration file from config_default_dir. */
-int vtysh_read_config(const char *config_default_dir)
+int vtysh_read_config(const char *config_default_dir, bool dry_run)
{
FILE *confp = NULL;
int ret;
return CMD_ERR_NO_FILE;
}
- ret = vtysh_read_file(confp);
+ ret = vtysh_read_file(confp, dry_run);
fclose(confp);
return (ret);
/* Read vtysh configuration file before connecting to daemons.
* (file may not be readable to calling user in SUID mode) */
suid_on();
- vtysh_read_config(vtysh_config);
+ vtysh_read_config(vtysh_config, dryrun);
suid_off();
}
/* Error code library system */
/* Start execution only if not in dry-run mode */
if (dryrun && !cmd) {
if (inputfile) {
- ret = vtysh_read_config(inputfile);
+ ret = vtysh_read_config(inputfile, dryrun);
} else {
- ret = vtysh_read_config(frr_config);
+ ret = vtysh_read_config(frr_config, dryrun);
}
exit(ret);
if (inputfile) {
vtysh_flock_config(inputfile);
- ret = vtysh_read_config(inputfile);
+ ret = vtysh_read_config(inputfile, dryrun);
vtysh_unflock_config();
exit(ret);
}
/* Boot startup configuration file. */
if (boot_flag) {
vtysh_flock_config(frr_config);
- ret = vtysh_read_config(frr_config);
+ ret = vtysh_read_config(frr_config, dryrun);
vtysh_unflock_config();
if (ret) {
fprintf(stderr,