From 1c950f37b74dd589b21246e7abbd7772b2632a5f Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Mon, 13 Feb 2023 09:14:56 -0500 Subject: [PATCH] lib: Add `debug routemap [detail]` Add the ability to turn on `debug routemap detail` for FRR. Signed-off-by: Donald Sharp --- lib/routemap.c | 31 +++++++++++++++++++++---------- lib/routemap.h | 4 ++++ lib/subdir.am | 1 + 3 files changed, 26 insertions(+), 10 deletions(-) diff --git a/lib/routemap.c b/lib/routemap.c index 0ca7eaa555..4b9033594c 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -36,6 +36,8 @@ #include "json.h" #include "jhash.h" +#include "lib/routemap_clippy.c" + DEFINE_MTYPE_STATIC(LIB, ROUTE_MAP, "Route map"); DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name"); 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 *, struct route_map_rule *); -#define DEBUG_ROUTEMAP 0x01 -static uint32_t rmap_debug; +uint32_t rmap_debug; /* New route map allocation. Please note route map's name must be specified. */ @@ -3159,24 +3160,34 @@ DEFUN (rmap_show_unused, return vty_show_unused_route_map(vty); } -DEFUN (debug_rmap, +DEFPY (debug_rmap, debug_rmap_cmd, - "debug route-map", + "debug route-map [detail]$detail", 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; } -DEFUN (no_debug_rmap, +DEFPY (no_debug_rmap, no_debug_rmap_cmd, - "no debug route-map", + "no debug route-map [detail]$detail", NO_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; } diff --git a/lib/routemap.h b/lib/routemap.h index 9c78e15735..ddcb8f2ddb 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -37,6 +37,10 @@ DECLARE_MTYPE(ROUTE_MAP_NAME); DECLARE_MTYPE(ROUTE_MAP_RULE); DECLARE_MTYPE(ROUTE_MAP_COMPILED); +#define DEBUG_ROUTEMAP 0x01 +#define DEBUG_ROUTEMAP_DETAIL 0x02 +extern uint32_t rmap_debug; + /* Route map's type. */ enum route_map_type { RMAP_PERMIT, RMAP_DENY, RMAP_ANY }; diff --git a/lib/subdir.am b/lib/subdir.am index 18e9825a7a..dcff31ebba 100644 --- a/lib/subdir.am +++ b/lib/subdir.am @@ -152,6 +152,7 @@ clippy_scan += \ lib/nexthop_group.c \ lib/northbound_cli.c \ lib/plist.c \ + lib/routemap.c \ lib/routemap_cli.c \ lib/thread.c \ lib/vty.c \