]> git.puffer.fish Git - mirror/frr.git/commitdiff
lib: Allow some usage statistics for route-maps 3091/head
authorDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 25 Sep 2018 19:02:51 +0000 (15:02 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Tue, 25 Sep 2018 19:02:51 +0000 (15:02 -0400)
Keep track of how often route-maps are applied and
how often each clause of a route-map is applied.

This change showed that `show route-map` was outputting
odd data so fix that output and add in the applied
times too.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
lib/routemap.c
lib/routemap.h

index bec6d389e534298d66db39fe83940f9e1af40e43..028351f6c6b37c5d833cd555078fd77e00c267eb 100644 (file)
@@ -854,11 +854,13 @@ static void vty_show_route_map_entry(struct vty *vty, struct route_map *map)
        struct route_map_index *index;
        struct route_map_rule *rule;
 
-       vty_out(vty, "%s:\n", frr_protonameinst);
+       vty_out(vty, "route-map: %s Invoked: %" PRIu64 "\n",
+               map->name, map->applied);
 
        for (index = map->head; index; index = index->next) {
-               vty_out(vty, "route-map %s, %s, sequence %d\n", map->name,
-                       route_map_type_str(index->type), index->pref);
+               vty_out(vty, " %s, sequence %d Invoked %" PRIu64 "\n",
+                       route_map_type_str(index->type), index->pref,
+                       index->applied);
 
                /* Description */
                if (index->description)
@@ -904,6 +906,8 @@ static int vty_show_route_map(struct vty *vty, const char *name)
 {
        struct route_map *map;
 
+       vty_out(vty, "%s:\n", frr_protonameinst);
+
        if (name) {
                map = route_map_lookup_by_name(name);
 
@@ -1457,8 +1461,10 @@ route_map_result_t route_map_apply(struct route_map *map,
        if (map == NULL)
                return RMAP_DENYMATCH;
 
+       map->applied++;
        for (index = map->head; index; index = index->next) {
                /* Apply this index. */
+               index->applied++;
                ret = route_map_apply_match(&index->match_list, prefix, type,
                                            object);
 
index a193e325360c675be31041665fd3b47bf68ac572..191456368740cc4b213b12bff545e64aab9443ad 100644 (file)
@@ -142,6 +142,9 @@ struct route_map_index {
        struct route_map_index *next;
        struct route_map_index *prev;
 
+       /* Keep track how many times we've try to apply */
+       uint64_t applied;
+
        QOBJ_FIELDS
 };
 DECLARE_QOBJ_TYPE(route_map_index)
@@ -163,6 +166,9 @@ struct route_map {
        bool to_be_processed; /* True if modification isn't acted on yet */
        bool deleted;         /* If 1, then this node will be deleted */
 
+       /* How many times have we applied this route-map */
+       uint64_t applied;
+
        QOBJ_FIELDS
 };
 DECLARE_QOBJ_TYPE(route_map)