lib: Add debug routemap [detail]

Add the ability to turn on `debug routemap detail` for FRR.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
Donald Sharp 2023-02-13 09:14:56 -05:00
parent 5913a17a5b
commit 1c950f37b7
3 changed files with 26 additions and 10 deletions

View File

@ -36,6 +36,8 @@
#include "json.h" #include "json.h"
#include "jhash.h" #include "jhash.h"
#include "lib/routemap_clippy.c"
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map"); DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map");
DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name"); DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name");
DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index"); DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP_INDEX, "Route map index");
@ -614,8 +616,7 @@ static void route_map_clear_all_references(char *rmap_name);
static void route_map_rule_delete(struct route_map_rule_list *, static void route_map_rule_delete(struct route_map_rule_list *,
struct route_map_rule *); struct route_map_rule *);
#define DEBUG_ROUTEMAP 0x01 uint32_t rmap_debug;
static uint32_t rmap_debug;
/* New route map allocation. Please note route map's name must be /* New route map allocation. Please note route map's name must be
specified. */ specified. */
@ -3159,24 +3160,34 @@ DEFUN (rmap_show_unused,
return vty_show_unused_route_map(vty); return vty_show_unused_route_map(vty);
} }
DEFUN (debug_rmap, DEFPY (debug_rmap,
debug_rmap_cmd, debug_rmap_cmd,
"debug route-map", "debug route-map [detail]$detail",
DEBUG_STR DEBUG_STR
"Debug option set for route-maps\n") "Debug option set for route-maps\n"
"Detailed output\n")
{ {
SET_FLAG(rmap_debug, DEBUG_ROUTEMAP); if (!detail)
SET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
else
SET_FLAG(rmap_debug, DEBUG_ROUTEMAP | DEBUG_ROUTEMAP_DETAIL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }
DEFUN (no_debug_rmap, DEFPY (no_debug_rmap,
no_debug_rmap_cmd, no_debug_rmap_cmd,
"no debug route-map", "no debug route-map [detail]$detail",
NO_STR NO_STR
DEBUG_STR DEBUG_STR
"Debug option set for route-maps\n") "Debug option set for route-maps\n"
"Detailed output\n")
{ {
UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP); if (!detail)
UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
else
UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP | DEBUG_ROUTEMAP_DETAIL);
return CMD_SUCCESS; return CMD_SUCCESS;
} }

View File

@ -37,6 +37,10 @@ DECLARE_MTYPE(ROUTE_MAP_NAME);
DECLARE_MTYPE(ROUTE_MAP_RULE); DECLARE_MTYPE(ROUTE_MAP_RULE);
DECLARE_MTYPE(ROUTE_MAP_COMPILED); DECLARE_MTYPE(ROUTE_MAP_COMPILED);
#define DEBUG_ROUTEMAP 0x01
#define DEBUG_ROUTEMAP_DETAIL 0x02
extern uint32_t rmap_debug;
/* Route map's type. */ /* Route map's type. */
enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY }; enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY };

View File

@ -152,6 +152,7 @@ clippy_scan += \
lib/nexthop_group.c \ lib/nexthop_group.c \
lib/northbound_cli.c \ lib/northbound_cli.c \
lib/plist.c \ lib/plist.c \
lib/routemap.c \
lib/routemap_cli.c \ lib/routemap_cli.c \
lib/thread.c \ lib/thread.c \
lib/vty.c \ lib/vty.c \