From 51c7566f0aff75018fc0051e6e4cf69271951883 Mon Sep 17 00:00:00 2001 From: Sindhu Parvathi Gopinathan Date: Mon, 20 Mar 2023 05:15:03 -0700 Subject: [PATCH 1/2] lib:fix clear route-map cmd using DEFPY Due to the wrong input argv id, "argv[idx_word]->arg" fetched in-correctly and it clears all the route-maps instead of specific one. Now correct argv id is passed to clear the given route-map counters. Also, use RMAP_NAME which allows to show list of configured route-maps in the system. After Fix:- Ticket:#3407773 Issue:3407773 Testing: UT done Before: TORC11# clear route-map counters WORD route-map name After: TORC11# clear route-map counters RMAP_NAME route-map name my-as Signed-off-by: Chirag Shah Signed-off-by: Sindhu Parvathi Gopinathan's (cherry picked from commit 463110f7335632d03557f1c5bfdd066b170011a8) --- lib/routemap.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/lib/routemap.c b/lib/routemap.c index 44d7185567..ed3e73f2c1 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -3097,27 +3097,24 @@ static void clear_route_map_helper(struct route_map *map) index->applied_clear = index->applied; } -DEFUN (rmap_clear_counters, +DEFPY (rmap_clear_counters, rmap_clear_counters_cmd, - "clear route-map counters [WORD]", + "clear route-map counters [RMAP_NAME$rmapname]", CLEAR_STR "route-map information\n" "counters associated with the specified route-map\n" "route-map name\n") { - int idx_word = 2; struct route_map *map; - const char *name = (argc == 3 ) ? argv[idx_word]->arg : NULL; - - if (name) { - map = route_map_lookup_by_name(name); + if (rmapname) { + map = route_map_lookup_by_name(rmapname); if (map) clear_route_map_helper(map); else { vty_out(vty, "%s: 'route-map %s' not found\n", - frr_protonameinst, name); + frr_protonameinst, rmapname); return CMD_SUCCESS; } } else { From 27b051fb888512c70ca5bbab9f1c6973de737b7d Mon Sep 17 00:00:00 2001 From: Donatas Abraitis Date: Tue, 21 Mar 2023 10:34:38 +0200 Subject: [PATCH 2/2] lib: Include clippy generated commands for routemap.c Signed-off-by: Donatas Abraitis --- lib/routemap.c | 2 ++ lib/subdir.am | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/routemap.c b/lib/routemap.c index ed3e73f2c1..210027105d 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"); 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 \