diff options
author | Renato Westphal <renato@opensourcerouting.org> | 2019-11-07 17:20:06 +0100 |
---|---|---|
committer | Renato Westphal <renato@opensourcerouting.org> | 2019-11-30 01:30:01 +0100 |
commit | 083be18cb8616deeb594fcc6b94a7232d377a0fb (patch) | |
tree | 4fb017638422dbd36bcb19cd5dba3b891501195e /lib | |
parent | Merge pull request #5409 from qlyoung/bgpd-lcom-ecom-parse-fixes (diff) | |
download | frr-083be18cb8616deeb594fcc6b94a7232d377a0fb.tar.xz frr-083be18cb8616deeb594fcc6b94a7232d377a0fb.zip |
lib: fix display of candidate configurations
Commit 5e6a9350c16 implemented an optimization where candidate
configurations are validated only before being displayed. The
validation is done only to create default child nodes (due to
how libyang works) and any possible error is ignored (candidate
configurations can be invalid/incomplete).
The problem is that we were calling lyd_validate() only when the
CLI "with-defaults" option was used. But some cli_show() callbacks
assume that default nodes exist and can crash when displaying a
candidate configuration that isn't validated. To fix this, call
lyd_validate() before displaying candidate configuration even when
"with-defaults" is not used (that was a micro-optimization that
shouldn't have been done).
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/northbound_cli.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index d3e788d5d..009e5bd82 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -432,12 +432,12 @@ void nb_cli_show_config_prepare(struct nb_config *config, bool with_defaults) lyd_schema_sort(config->dnode, 1); /* - * When "with-defaults" is used, call lyd_validate() only to create - * default child nodes, ignoring any possible validation error. This - * doesn't need to be done when displaying the running configuration - * since it's always fully validated. + * Call lyd_validate() only to create default child nodes, ignoring + * any possible validation error. This doesn't need to be done when + * displaying the running configuration since it's always fully + * validated. */ - if (with_defaults && config != running_config) + if (config != running_config) (void)lyd_validate(&config->dnode, LYD_OPT_CONFIG | LYD_OPT_WHENAUTODEL, ly_native_ctx); |