Skip to content

Commit

Permalink
bgpd: fix debug rpki display in show run
Browse files Browse the repository at this point in the history
Only include "debug rpki" in "show run" if it was requested from the
configure mode but not it was from the enabled mode.

Signed-off-by: Philippe Guibert <[email protected]>
Signed-off-by: Louis Scalbert <[email protected]>
  • Loading branch information
pguibert6WIND authored and louis-6wind committed Jan 11, 2024
1 parent fc7b905 commit 93f05b0
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions bgpd/bgp_rpki.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "bgpd/bgp_aspath.h"
#include "bgpd/bgp_route.h"
#include "bgpd/bgp_rpki.h"
#include "bgpd/bgp_debug.h"
#include "northbound_cli.h"

#include "lib/network.h"
Expand All @@ -56,7 +57,7 @@ DEFINE_MTYPE_STATIC(BGPD, BGP_RPKI_REVALIDATE, "BGP RPKI Revalidation");
static struct event *t_rpki_sync;

#define RPKI_DEBUG(...) \
if (rpki_debug) { \
if (rpki_debug_conf || rpki_debug_term) { \
zlog_debug("RPKI: " __VA_ARGS__); \
}

Expand Down Expand Up @@ -88,6 +89,7 @@ struct rpki_for_each_record_arg {
enum asnotation_mode asnotation;
};

static int bgp_rpki_write_debug(struct vty *vty, bool running);
static int start(void);
static void stop(void);
static int reset(bool force);
Expand Down Expand Up @@ -129,7 +131,7 @@ static bool rtr_is_running;
static bool rtr_is_stopping;
static bool rtr_is_synced;
static _Atomic int rtr_update_overflow;
static bool rpki_debug;
static bool rpki_debug_conf, rpki_debug_term;
static unsigned int polling_period;
static unsigned int expire_interval;
static unsigned int retry_interval;
Expand Down Expand Up @@ -598,7 +600,8 @@ static void rpki_init_sync_socket(void)

static int bgp_rpki_init(struct event_loop *master)
{
rpki_debug = false;
rpki_debug_conf = false;
rpki_debug_term = false;
rtr_is_running = false;
rtr_is_stopping = false;
rtr_is_synced = false;
Expand Down Expand Up @@ -632,6 +635,7 @@ static int bgp_rpki_module_init(void)
hook_register(bgp_rpki_prefix_status, rpki_validate_prefix);
hook_register(frr_late_init, bgp_rpki_init);
hook_register(frr_early_fini, bgp_rpki_fini);
hook_register(bgp_hook_config_write_debug, &bgp_rpki_write_debug);

return 0;
}
Expand Down Expand Up @@ -1047,6 +1051,19 @@ static void free_cache(struct cache *cache)
XFREE(MTYPE_BGP_RPKI_CACHE, cache);
}

static int bgp_rpki_write_debug(struct vty *vty, bool running)
{
if (rpki_debug_conf && running) {
vty_out(vty, "debug rpki\n");
return 1;
}
if ((rpki_debug_conf || rpki_debug_term) && !running) {
vty_out(vty, " BGP RPKI debugging is on\n");
return 1;
}
return 0;
}

static int config_write(struct vty *vty)
{
struct listnode *cache_node;
Expand All @@ -1059,9 +1076,6 @@ static int config_write(struct vty *vty)
/* do not display the default config values */
return 0;

if (rpki_debug)
vty_out(vty, "debug rpki\n");

vty_out(vty, "!\n");
vty_out(vty, "rpki\n");

Expand Down Expand Up @@ -1763,7 +1777,10 @@ DEFUN (debug_rpki,
DEBUG_STR
"Enable debugging for rpki\n")
{
rpki_debug = true;
if (vty->node == CONFIG_NODE)
rpki_debug_conf = true;
else
rpki_debug_term = true;
return CMD_SUCCESS;
}

Expand All @@ -1774,7 +1791,10 @@ DEFUN (no_debug_rpki,
DEBUG_STR
"Disable debugging for rpki\n")
{
rpki_debug = false;
if (vty->node == CONFIG_NODE)
rpki_debug_conf = false;
else
rpki_debug_term = false;
return CMD_SUCCESS;
}

Expand Down

0 comments on commit 93f05b0

Please sign in to comment.