diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-09-19 09:14:53 +0200 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2020-07-02 08:17:51 +0200 |
| commit | f3517f58f198cef90bf1e04449f8514daf818630 (patch) | |
| tree | 125a8f775f3afc60fef97315cfa3f153c5df234e | |
| parent | 416d0484c061e9b8c586ee7ba3cc079c827bfd8f (diff) | |
bgpd: running-config rpki indicates only non default values
the show running-config rpki was displaying systematically the default
values, when at least one cache server was configured. now, if the rpki
configuration has been changed, either because of a new cache server, or
because of a change in the default settings, then the associated
configuration is dumped in the 'show running-config' command.
adding to this, to permit user to dump the settings values, the command
'show rpki configuration' dumps the values whatever default or not.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
| -rw-r--r-- | bgpd/bgp_rpki.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/bgpd/bgp_rpki.c b/bgpd/bgp_rpki.c index 3bd4f6ff5a..1e2ebf580f 100644 --- a/bgpd/bgp_rpki.c +++ b/bgpd/bgp_rpki.c @@ -904,20 +904,36 @@ static void free_cache(struct cache *cache) XFREE(MTYPE_BGP_RPKI_CACHE, cache); } + +/* return true if config changed from default */ +static bool config_changed(void) +{ + if (polling_period != POLLING_PERIOD_DEFAULT) + return true; + if (retry_interval != RETRY_INTERVAL_DEFAULT) + return true; + if (expire_interval != EXPIRE_INTERVAL_DEFAULT) + return true; + return false; +} + static int config_write(struct vty *vty) { struct listnode *cache_node; struct cache *cache; - if (listcount(cache_list)) { + if (listcount(cache_list) && config_changed()) { if (rpki_debug) vty_out(vty, "debug rpki\n"); vty_out(vty, "!\n"); vty_out(vty, "rpki\n"); - vty_out(vty, " rpki polling_period %d\n", polling_period); - vty_out(vty, " rpki retry-interval %d\n", retry_interval); - vty_out(vty, " rpki expire_interval %d\n", expire_interval) + if (polling_period != POLLING_PERIOD_DEFAULT) + vty_out(vty, " rpki polling_period %d\n", polling_period); + if (retry_interval != RETRY_INTERVAL_DEFAULT) + vty_out(vty, " rpki retry-interval %d\n", retry_interval); + if (expire_interval != EXPIRE_INTERVAL_DEFAULT) + vty_out(vty, " rpki expire_interval %d\n", expire_interval); for (ALL_LIST_ELEMENTS_RO(cache_list, cache_node, cache)) { switch (cache->type) { struct tr_tcp_config *tcp_config; @@ -1423,6 +1439,25 @@ DEFUN (show_rpki_cache_connection, return CMD_SUCCESS; } +DEFUN (show_rpki_configuration, + show_rpki_configuration_cmd, + "show rpki configuration", + SHOW_STR + RPKI_OUTPUT_STRING + "Show RPKI configuration\n") +{ + vty_out(vty, "rpki is %s", + listcount(cache_list) ? "Enabled" : "Disabled"); + if (!listcount(cache_list)) + return CMD_SUCCESS; + vty_out(vty, " (%d cache servers configured)", listcount(cache_list)); + vty_out(vty, "\n"); + vty_out(vty, "\tpolling period %d\n", polling_period); + vty_out(vty, "\tretry interval %d\n", retry_interval); + vty_out(vty, "\texpire interval %d\n", expire_interval); + return CMD_SUCCESS; +} + static int config_on_exit(struct vty *vty) { reset(false); @@ -1564,6 +1599,7 @@ static void install_cli_commands(void) install_element(VIEW_NODE, &show_rpki_cache_server_cmd); install_element(VIEW_NODE, &show_rpki_prefix_cmd); install_element(VIEW_NODE, &show_rpki_as_number_cmd); + install_element(VIEW_NODE, &show_rpki_configuration_cmd); /* Install debug commands */ install_element(CONFIG_NODE, &debug_rpki_cmd); |
