summaryrefslogtreecommitdiff
path: root/lib/routemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/routemap.c')
-rw-r--r--lib/routemap.c89
1 files changed, 77 insertions, 12 deletions
diff --git a/lib/routemap.c b/lib/routemap.c
index 7749ea4cc7..fb70860024 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -263,6 +263,24 @@ void route_map_no_match_tag_hook(int (*func)(
rmap_match_set_hook.no_match_tag = func;
}
+/* set sr-te color */
+void route_map_set_srte_color_hook(int (*func)(struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.set_srte_color = func;
+}
+
+/* no set sr-te color */
+void route_map_no_set_srte_color_hook(int (*func)(struct vty *vty,
+ struct route_map_index *index,
+ const char *command,
+ const char *arg))
+{
+ rmap_match_set_hook.no_set_srte_color = func;
+}
+
/* set ip nexthop */
void route_map_set_ip_nexthop_hook(int (*func)(struct vty *vty,
struct route_map_index *index,
@@ -353,8 +371,7 @@ int generic_match_add(struct vty *vty, struct route_map_index *index,
"%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
else
- zlog_warn("Argument form is unsupported or malformed: "
- "%s %s", command, arg);
+ zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
/*
@@ -405,8 +422,7 @@ int generic_match_delete(struct vty *vty, struct route_map_index *index,
"%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
else
- zlog_warn("Argument form is unsupported or malformed: "
- "%s %s", command, arg);
+ zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
@@ -441,8 +457,7 @@ int generic_set_add(struct vty *vty, struct route_map_index *index,
"%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
else
- zlog_warn("Argument form is unsupported or malformed: "
- "%s %s", command, arg);
+ zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
break;
@@ -470,8 +485,7 @@ int generic_set_delete(struct vty *vty, struct route_map_index *index,
"%% [%s] Argument form is unsupported or malformed.\n",
frr_protonameinst);
else
- zlog_warn("Argument form is unsupported or malformed: "
- "%s %s", command, arg);
+ zlog_warn("Argument form is unsupported or malformed: %s %s", command, arg);
return CMD_WARNING_CONFIG_FAILED;
case RMAP_COMPILE_SUCCESS:
break;
@@ -825,9 +839,10 @@ 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, "route-map: %s Invoked: %" PRIu64 " Optimization: %s\n",
+ vty_out(vty, "route-map: %s Invoked: %" PRIu64 " Optimization: %s Processed Change: %s\n",
map->name, map->applied - map->applied_clear,
- map->optimization_disabled ? "disabled" : "enabled");
+ map->optimization_disabled ? "disabled" : "enabled",
+ map->to_be_processed ? "true" : "false");
for (index = map->head; index; index = index->next) {
vty_out(vty, " %s, sequence %d Invoked %" PRIu64 "\n",
@@ -1692,14 +1707,19 @@ route_map_get_index(struct route_map *map, const struct prefix *prefix,
* more noops, we retain this return value and
* return this eventually if there are no
* matches.
+ * If a best match route-map index already
+ * exists, do not reset the match_ret.
*/
- if (*match_ret != RMAP_NOMATCH)
+ if (!best_index && (*match_ret != RMAP_NOMATCH))
*match_ret = ret;
} else {
/*
* ret is RMAP_NOMATCH.
+ * If a best match route-map index already
+ * exists, do not reset the match_ret.
*/
- *match_ret = ret;
+ if (!best_index)
+ *match_ret = ret;
}
}
@@ -2411,6 +2431,7 @@ route_map_result_t route_map_apply(struct route_map *map,
for (; index; index = index->next) {
if (!skip_match_clause) {
+ index->applied++;
/* Apply this index. */
match_ret = route_map_apply_match(&index->match_list,
prefix, type, object);
@@ -2610,6 +2631,47 @@ static unsigned int route_map_dep_data_hash_make_key(const void *p)
return string_hash_make(dep_data->rname);
}
+DEFUN (set_srte_color,
+ set_srte_color_cmd,
+ "set sr-te color [(1-4294967295)]",
+ SET_STR
+ SRTE_STR
+ SRTE_COLOR_STR
+ "Color of the SR-TE Policies to match with\n")
+{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
+ int idx = 0;
+ char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
+ ? argv[idx]->arg
+ : NULL;
+
+ if (rmap_match_set_hook.set_srte_color)
+ return rmap_match_set_hook.set_srte_color(vty, index,
+ "sr-te color", arg);
+ return CMD_SUCCESS;
+}
+
+DEFUN (no_set_srte_color,
+ no_set_srte_color_cmd,
+ "no set sr-te color [(1-4294967295)]",
+ NO_STR
+ SET_STR
+ SRTE_STR
+ SRTE_COLOR_STR
+ "Color of the SR-TE Policies to match with\n")
+{
+ VTY_DECLVAR_CONTEXT(route_map_index, index);
+ int idx = 0;
+ char *arg = argv_find(argv, argc, "(1-4294967295)", &idx)
+ ? argv[idx]->arg
+ : NULL;
+
+ if (rmap_match_set_hook.no_set_srte_color)
+ return rmap_match_set_hook.no_set_srte_color(
+ vty, index, "sr-te color", arg);
+ return CMD_SUCCESS;
+}
+
static void *route_map_dep_hash_alloc(void *p)
{
char *dep_name = (char *)p;
@@ -3234,5 +3296,8 @@ void route_map_init(void)
install_element(RMAP_NODE, &routemap_optimization_cmd);
install_element(RMAP_NODE, &no_routemap_optimization_cmd);
+ install_element(RMAP_NODE, &set_srte_color_cmd);
+ install_element(RMAP_NODE, &no_set_srte_color_cmd);
+
install_element(ENABLE_NODE, &show_route_map_pfx_tbl_cmd);
}