]> git.proxmox.com Git - mirror_frr.git/commitdiff
lib:fix clear route-map cmd using DEFPY
authorSindhu Parvathi Gopinathan <sgopinathan@nvidia.com>
Mon, 20 Mar 2023 12:15:03 +0000 (05:15 -0700)
committerChirag Shah <chirag@nvidia.com>
Tue, 21 Mar 2023 02:17:32 +0000 (19:17 -0700)
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
  <cr>
  WORD  route-map name

After:

TORC11# clear route-map counters
  <cr>
  RMAP_NAME  route-map name
     my-as

Signed-off-by: Chirag Shah <chirag@nvidia.com>
Signed-off-by: Sindhu Parvathi Gopinathan's <sgopinathan@nvidia.com>
lib/routemap.c

index 9f5c9e693e366429d6f60434e5ed850764c3475d..16da81fa746255f5834b38712ae4ab28a3083d0e 100644 (file)
@@ -3101,27 +3101,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 {