summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/routemap.c67
-rw-r--r--lib/routemap.h4
-rw-r--r--lib/subdir.am1
3 files changed, 45 insertions, 27 deletions
diff --git a/lib/routemap.c b/lib/routemap.c
index f56e6a6122..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");
@@ -613,7 +615,8 @@ static unsigned int route_map_dep_hash_make_key(const void *p);
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 *);
-static bool rmap_debug;
+
+uint32_t rmap_debug;
/* New route map allocation. Please note route map's name must be
specified. */
@@ -681,7 +684,7 @@ static struct route_map *route_map_add(const char *name)
if (!map->ipv6_prefix_table)
map->ipv6_prefix_table = route_table_init();
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Add route-map %s", name);
return map;
}
@@ -701,7 +704,7 @@ static void route_map_free_map(struct route_map *map)
while ((index = map->head) != NULL)
route_map_index_delete(index, 0);
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Deleting route-map %s", map->name);
list = &route_map_master;
@@ -1132,7 +1135,7 @@ void route_map_index_delete(struct route_map_index *index, int notify)
QOBJ_UNREG(index);
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Deleting route-map %s sequence %d",
index->map->name, index->pref);
@@ -1243,7 +1246,7 @@ route_map_index_add(struct route_map *map, enum route_map_type type, int pref)
route_map_notify_dependencies(map->name, RMAP_EVENT_CALL_ADDED);
}
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Route-map %s add sequence %d, type: %s",
map->name, pref, route_map_type_str(type));
@@ -2580,13 +2583,13 @@ route_map_result_t route_map_apply_ext(struct route_map *map,
&match_ret);
if (index) {
index->applied++;
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug(
"Best match route-map: %s, sequence: %d for pfx: %pFX, result: %s",
map->name, index->pref, prefix,
route_map_cmd_result_str(match_ret));
} else {
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug(
"No best match sequence for pfx: %pFX in route-map: %s, result: %s",
prefix, map->name,
@@ -2612,7 +2615,7 @@ route_map_result_t route_map_apply_ext(struct route_map *map,
/* Apply this index. */
match_ret = route_map_apply_match(&index->match_list,
prefix, match_object);
- if (rmap_debug) {
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP)) {
zlog_debug(
"Route-map: %s, sequence: %d, prefix: %pFX, result: %s",
map->name, index->pref, prefix,
@@ -2725,7 +2728,7 @@ route_map_result_t route_map_apply_ext(struct route_map *map,
}
route_map_apply_end:
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Route-map: %s, prefix: %pFX, result: %s",
(map ? map->name : "null"), prefix,
route_map_result_str(ret));
@@ -2780,7 +2783,7 @@ static void route_map_clear_reference(struct hash_bucket *bucket, void *arg)
tmp_dep_data.rname = arg;
dep_data = hash_release(dep->dep_rmap_hash, &tmp_dep_data);
if (dep_data) {
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Clearing reference for %s to %s count: %d",
dep->dep_name, tmp_dep_data.rname,
dep_data->refcnt);
@@ -2800,7 +2803,7 @@ static void route_map_clear_all_references(char *rmap_name)
{
int i;
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Clearing references for %s", rmap_name);
for (i = 1; i < ROUTE_MAP_DEP_MAX; i++) {
@@ -2876,7 +2879,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
case RMAP_EVENT_LLIST_ADDED:
case RMAP_EVENT_CALL_ADDED:
case RMAP_EVENT_FILTER_ADDED:
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Adding dependency for filter %s in route-map %s",
dep_name, rmap_name);
dep = (struct route_map_dep *)hash_get(
@@ -2905,7 +2908,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
case RMAP_EVENT_LLIST_DELETED:
case RMAP_EVENT_CALL_DELETED:
case RMAP_EVENT_FILTER_DELETED:
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Deleting dependency for filter %s in route-map %s",
dep_name, rmap_name);
dep = (struct route_map_dep *)hash_get(dephash, dname, NULL);
@@ -2959,7 +2962,7 @@ static int route_map_dep_update(struct hash *dephash, const char *dep_name,
}
if (dep) {
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
hash_iterate(dep->dep_rmap_hash,
route_map_print_dependency, dname);
}
@@ -3031,7 +3034,7 @@ static void route_map_process_dependency(struct hash_bucket *bucket, void *data)
dep_data = bucket->data;
rmap_name = dep_data->rname;
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Notifying %s of dependency", rmap_name);
if (route_map_master.event_hook)
(*route_map_master.event_hook)(rmap_name);
@@ -3079,7 +3082,7 @@ void route_map_notify_dependencies(const char *affected_name,
if (!dep->this_hash)
dep->this_hash = upd8_hash;
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
zlog_debug("Filter %s updated", dep->dep_name);
hash_iterate(dep->dep_rmap_hash, route_map_process_dependency,
(void *)event);
@@ -3157,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")
{
- rmap_debug = true;
+ 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")
{
- rmap_debug = false;
+ if (!detail)
+ UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
+ else
+ UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP | DEBUG_ROUTEMAP_DETAIL);
+
return CMD_SUCCESS;
}
@@ -3189,7 +3202,7 @@ static struct cmd_node rmap_debug_node = {
void route_map_show_debug(struct vty *vty)
{
- if (rmap_debug)
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP))
vty_out(vty, "debug route-map\n");
}
@@ -3198,7 +3211,7 @@ static int rmap_config_write_debug(struct vty *vty)
{
int write = 0;
- if (rmap_debug) {
+ if (CHECK_FLAG(rmap_debug, DEBUG_ROUTEMAP)) {
vty_out(vty, "debug route-map\n");
write++;
}
@@ -3400,7 +3413,7 @@ void route_map_init(void)
8, route_map_dep_hash_make_key, route_map_dep_hash_cmp,
"Route Map Dep Hash");
- rmap_debug = false;
+ UNSET_FLAG(rmap_debug, DEBUG_ROUTEMAP);
route_map_cli_init();
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 \