diff options
Diffstat (limited to 'lib/routemap.c')
| -rw-r--r-- | lib/routemap.c | 151 |
1 files changed, 147 insertions, 4 deletions
diff --git a/lib/routemap.c b/lib/routemap.c index bec6d389e5..bc45cd51d0 100644 --- a/lib/routemap.c +++ b/lib/routemap.c @@ -111,6 +111,20 @@ struct route_map_match_set_hooks { const char *arg, route_map_event_t type); + /* match ip next hop type */ + int (*match_ip_next_hop_type)(struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ip next hop type */ + int (*no_match_ip_next_hop_type)(struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + /* match ipv6 address */ int (*match_ipv6_address)(struct vty *vty, struct route_map_index *index, @@ -138,6 +152,19 @@ struct route_map_match_set_hooks { const char *arg, route_map_event_t type); + /* match ipv6 next-hop type */ + int (*match_ipv6_next_hop_type)(struct vty *vty, + struct route_map_index *index, + const char *command, + const char *arg, + route_map_event_t type); + + /* no match ipv6next-hop type */ + int (*no_match_ipv6_next_hop_type)(struct vty *vty, + struct route_map_index *index, + const char *command, const char *arg, + route_map_event_t type); + /* match metric */ int (*match_metric)(struct vty *vty, struct route_map_index *index, const char *command, const char *arg, @@ -275,6 +302,22 @@ void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( rmap_match_set_hook.no_match_ip_next_hop_prefix_list = func; } +/* match ip next hop type */ +void route_map_match_ip_next_hop_type_hook(int (*func)( + struct vty *vty, struct route_map_index *index, const char *command, + const char *arg, route_map_event_t type)) +{ + rmap_match_set_hook.match_ip_next_hop_type = func; +} + +/* no match ip next hop type */ +void route_map_no_match_ip_next_hop_type_hook(int (*func)( + struct vty *vty, struct route_map_index *index, const char *command, + const char *arg, route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ip_next_hop_type = func; +} + /* match ipv6 address */ void route_map_match_ipv6_address_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, @@ -308,6 +351,22 @@ void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( rmap_match_set_hook.no_match_ipv6_address_prefix_list = func; } +/* match ipv6 next-hop type */ +void route_map_match_ipv6_next_hop_type_hook(int (*func)( + struct vty *vty, struct route_map_index *index, const char *command, + const char *arg, route_map_event_t type)) +{ + rmap_match_set_hook.match_ipv6_next_hop_type = func; +} + +/* no match ipv6 next-hop type */ +void route_map_no_match_ipv6_next_hop_type_hook(int (*func)( + struct vty *vty, struct route_map_index *index, const char *command, + const char *arg, route_map_event_t type)) +{ + rmap_match_set_hook.no_match_ipv6_next_hop_type = func; +} + /* match metric */ void route_map_match_metric_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, @@ -854,11 +913,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 +965,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); @@ -928,7 +991,7 @@ static int vty_show_route_map(struct vty *vty, const char *name) for (ALL_LIST_ELEMENTS_RO(maplist, ln, map)) vty_show_route_map_entry(vty, map); - list_delete_and_null(&maplist); + list_delete(&maplist); } return CMD_SUCCESS; } @@ -1457,8 +1520,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); @@ -2028,6 +2093,45 @@ DEFUN (no_match_ip_next_hop_prefix_list, return CMD_SUCCESS; } +DEFUN(match_ip_next_hop_type, match_ip_next_hop_type_cmd, + "match ip next-hop type <blackhole>", + MATCH_STR IP_STR + "Match next-hop address of route\n" + "Match entries by type\n" + "Blackhole\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT(route_map_index, index); + + if (rmap_match_set_hook.match_ip_next_hop_type) + return rmap_match_set_hook.match_ip_next_hop_type( + vty, index, "ip next-hop type", argv[idx_word]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + +DEFUN(no_match_ip_next_hop_type, no_match_ip_next_hop_type_cmd, + "no match ip next-hop type [<blackhole>]", + NO_STR MATCH_STR IP_STR + "Match next-hop address of route\n" + "Match entries by type\n" + "Blackhole\n") +{ + int idx_word = 5; + VTY_DECLVAR_CONTEXT(route_map_index, index); + + if (rmap_match_set_hook.no_match_ip_next_hop) { + if (argc <= idx_word) + return rmap_match_set_hook.no_match_ip_next_hop( + vty, index, "ip next-hop type", NULL, + RMAP_EVENT_MATCH_DELETED); + return rmap_match_set_hook.no_match_ip_next_hop( + vty, index, "ip next-hop type", argv[idx_word]->arg, + RMAP_EVENT_MATCH_DELETED); + } + return CMD_SUCCESS; +} + DEFUN (match_ipv6_address, match_ipv6_address_cmd, @@ -2106,6 +2210,39 @@ DEFUN (no_match_ipv6_address_prefix_list, return CMD_SUCCESS; } +DEFUN(match_ipv6_next_hop_type, match_ipv6_next_hop_type_cmd, + "match ipv6 next-hop type <blackhole>", + MATCH_STR IPV6_STR + "Match address of route\n" + "Match entries by type\n" + "Blackhole\n") +{ + int idx_word = 4; + VTY_DECLVAR_CONTEXT(route_map_index, index); + + if (rmap_match_set_hook.match_ipv6_next_hop_type) + return rmap_match_set_hook.match_ipv6_next_hop_type( + vty, index, "ipv6 next-hop type", argv[idx_word]->arg, + RMAP_EVENT_MATCH_ADDED); + return CMD_SUCCESS; +} + +DEFUN(no_match_ipv6_next_hop_type, no_match_ipv6_next_hop_type_cmd, + "no match ipv6 next-hop type [<blackhole>]", + NO_STR MATCH_STR IPV6_STR + "Match address of route\n" + "Match entries by type\n" + "Blackhole\n") +{ + int idx_word = 5; + VTY_DECLVAR_CONTEXT(route_map_index, index); + + if (rmap_match_set_hook.no_match_ipv6_next_hop_type) + return rmap_match_set_hook.no_match_ipv6_next_hop_type( + vty, index, "ipv6 next-hop type", argv[idx_word]->arg, + RMAP_EVENT_MATCH_DELETED); + return CMD_SUCCESS; +} DEFUN (match_metric, match_metric_cmd, @@ -2873,12 +3010,18 @@ void route_map_init(void) install_element(RMAP_NODE, &match_ip_next_hop_prefix_list_cmd); install_element(RMAP_NODE, &no_match_ip_next_hop_prefix_list_cmd); + install_element(RMAP_NODE, &match_ip_next_hop_type_cmd); + install_element(RMAP_NODE, &no_match_ip_next_hop_type_cmd); + install_element(RMAP_NODE, &match_ipv6_address_cmd); install_element(RMAP_NODE, &no_match_ipv6_address_cmd); install_element(RMAP_NODE, &match_ipv6_address_prefix_list_cmd); install_element(RMAP_NODE, &no_match_ipv6_address_prefix_list_cmd); + install_element(RMAP_NODE, &match_ipv6_next_hop_type_cmd); + install_element(RMAP_NODE, &no_match_ipv6_next_hop_type_cmd); + install_element(RMAP_NODE, &match_metric_cmd); install_element(RMAP_NODE, &no_match_metric_cmd); |
