summaryrefslogtreecommitdiffstats
path: root/lib/routemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/routemap.c')
-rw-r--r--lib/routemap.c50
1 files changed, 32 insertions, 18 deletions
diff --git a/lib/routemap.c b/lib/routemap.c
index 3542994e6..e8f4a6c1a 100644
--- a/lib/routemap.c
+++ b/lib/routemap.c
@@ -1456,14 +1456,14 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
(note, this includes the description for the "NEXT"
and "GOTO" frobs now
- Match | No Match
- |
- permit action | cont
- |
- ------------------+---------------
- |
- deny deny | cont
- |
+ | Match | No Match | No op
+ |-----------|--------------|-------
+ permit | action | cont | cont.
+ | | default:deny | default:permit
+ -------------------+-----------------------
+ | deny | cont | cont.
+ deny | | default:deny | default:permit
+ |-----------|--------------|--------
action)
-Apply Set statements, accept route
@@ -1497,12 +1497,12 @@ int route_map_delete_set(struct route_map_index *index, const char *set_name,
We need to make sure our route-map processing matches the above
*/
-static route_map_result_t
+static enum route_map_match_result_t
route_map_apply_match(struct route_map_rule_list *match_list,
const struct prefix *prefix, route_map_object_t type,
void *object)
{
- route_map_result_t ret = RMAP_NOMATCH;
+ enum route_map_match_result_t ret = RMAP_NOMATCH;
struct route_map_rule *match;
@@ -1534,7 +1534,8 @@ route_map_result_t route_map_apply(struct route_map *map,
route_map_object_t type, void *object)
{
static int recursion = 0;
- int ret = 0;
+ enum route_map_match_result_t match_ret = RMAP_NOMATCH;
+ route_map_result_t ret = 0;
struct route_map_index *index;
struct route_map_rule *set;
@@ -1554,24 +1555,33 @@ route_map_result_t route_map_apply(struct route_map *map,
for (index = map->head; index; index = index->next) {
/* Apply this index. */
index->applied++;
- ret = route_map_apply_match(&index->match_list, prefix, type,
- object);
+ match_ret = route_map_apply_match(&index->match_list, prefix,
+ type, object);
/* Now we apply the matrix from above */
- if (ret == RMAP_NOMATCH)
+ if (match_ret == RMAP_NOMATCH || match_ret == RMAP_NOOP)
/* 'cont' from matrix - continue to next route-map
* sequence */
continue;
- else if (ret == RMAP_MATCH) {
+ else if (match_ret == RMAP_MATCH) {
if (index->type == RMAP_PERMIT)
/* 'action' */
{
+ /* Match succeeded, rmap is of type permit */
+ ret = RMAP_PERMITMATCH;
+
/* permit+match must execute sets */
for (set = index->set_list.head; set;
set = set->next)
- ret = (*set->cmd->func_apply)(
- set->value, prefix, type,
- object);
+ /*
+ * We dont care abt the return value
+ * for set cmd. Almost always,
+ * RMAP_OKAY is returned. Rarely
+ * do we see RMAP_ERROR
+ */
+ match_ret = (*set->cmd->func_apply)(
+ set->value, prefix, type,
+ object);
/* Call another route-map if available */
if (index->nextrm) {
@@ -1622,6 +1632,10 @@ route_map_result_t route_map_apply(struct route_map *map,
}
}
}
+
+ if (match_ret == RMAP_NOOP)
+ return RMAP_PERMITMATCH;
+
/* Finally route-map does not match at all. */
return RMAP_DENYMATCH;
}