summaryrefslogtreecommitdiffstats
path: root/vtysh
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@nvidia.com>2020-12-15 20:45:23 +0100
committerDonald Sharp <sharpd@nvidia.com>2020-12-15 21:33:17 +0100
commit77f7b4b018735076ca7795f6e0741fb3e0d1a018 (patch)
tree57686535d3183f34e179cbccdf32c98d4bec9e3c /vtysh
parentlib, vtysh: Modify start/end configuration commands to be more hidden (diff)
downloadfrr-77f7b4b018735076ca7795f6e0741fb3e0d1a018.tar.xz
frr-77f7b4b018735076ca7795f6e0741fb3e0d1a018.zip
vtysh: When dry-running no need to start/end configuration
When doing a dry run don't send start/end configuration commands. Ticket: CM-32665 Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'vtysh')
-rw-r--r--vtysh/vtysh.c2
-rw-r--r--vtysh/vtysh.h2
-rw-r--r--vtysh/vtysh_config.c12
-rw-r--r--vtysh/vtysh_main.c10
4 files changed, 14 insertions, 12 deletions
diff --git a/vtysh/vtysh.c b/vtysh/vtysh.c
index c78132508..c3fb663f5 100644
--- a/vtysh/vtysh.c
+++ b/vtysh/vtysh.c
@@ -3187,7 +3187,7 @@ DEFUN (vtysh_copy_to_running,
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");
diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h
index d2675a81b..b2e37074f 100644
--- a/vtysh/vtysh.h
+++ b/vtysh/vtysh.h
@@ -92,7 +92,7 @@ void config_add_line(struct list *, const char *);
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 *);
diff --git a/vtysh/vtysh_config.c b/vtysh/vtysh_config.c
index c8154d969..47f426b5e 100644
--- a/vtysh/vtysh_config.c
+++ b/vtysh/vtysh_config.c
@@ -515,7 +515,7 @@ void vtysh_config_dump(void)
}
/* 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;
@@ -528,12 +528,14 @@ static int vtysh_read_file(FILE *confp)
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");
@@ -544,7 +546,7 @@ static int vtysh_read_file(FILE *confp)
}
/* 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;
@@ -557,7 +559,7 @@ int vtysh_read_config(const char *config_default_dir)
return CMD_ERR_NO_FILE;
}
- ret = vtysh_read_file(confp);
+ ret = vtysh_read_file(confp, dry_run);
fclose(confp);
return (ret);
diff --git a/vtysh/vtysh_main.c b/vtysh/vtysh_main.c
index 6e28df79d..db7cc312d 100644
--- a/vtysh/vtysh_main.c
+++ b/vtysh/vtysh_main.c
@@ -459,7 +459,7 @@ int main(int argc, char **argv, char **env)
/* 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 */
@@ -478,9 +478,9 @@ int main(int argc, char **argv, char **env)
/* 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);
@@ -561,7 +561,7 @@ int main(int argc, char **argv, char **env)
if (inputfile) {
vtysh_flock_config(inputfile);
- ret = vtysh_read_config(inputfile);
+ ret = vtysh_read_config(inputfile, dryrun);
vtysh_unflock_config();
exit(ret);
}
@@ -670,7 +670,7 @@ int main(int argc, char **argv, char **env)
/* 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,