diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2018-09-28 10:51:50 +0200 |
---|---|---|
committer | Donatas Abraitis <donatas.abraitis@gmail.com> | 2018-10-02 09:57:45 +0200 |
commit | 61ad901e57049995709bcffe1ffaee65a9927a00 (patch) | |
tree | e23d845fcbf1c2a5828853ac39cd8732e0480d14 /lib | |
parent | Merge pull request #3092 from donaldsharp/bgp_listen_or_listen (diff) | |
download | frr-61ad901e57049995709bcffe1ffaee65a9927a00.tar.xz frr-61ad901e57049995709bcffe1ffaee65a9927a00.zip |
bgpd: Match routes by type under route-maps
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/routemap.c | 137 | ||||
-rw-r--r-- | lib/routemap.h | 16 |
2 files changed, 153 insertions, 0 deletions
diff --git a/lib/routemap.c b/lib/routemap.c index bec6d389e..2111a4f4d 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, @@ -2028,6 +2087,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 +2204,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 +3004,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); diff --git a/lib/routemap.h b/lib/routemap.h index a193e3253..c654806b4 100644 --- a/lib/routemap.h +++ b/lib/routemap.h @@ -283,6 +283,14 @@ extern void route_map_match_ip_next_hop_prefix_list_hook(int (*func)( extern void route_map_no_match_ip_next_hop_prefix_list_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, const char *arg, route_map_event_t type)); +/* match ip next hop type */ +extern 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)); +/* no match ip next hop type */ +extern 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)); /* match ipv6 address */ extern void route_map_match_ipv6_address_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, @@ -299,6 +307,14 @@ extern void route_map_match_ipv6_address_prefix_list_hook(int (*func)( extern void route_map_no_match_ipv6_address_prefix_list_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, const char *arg, route_map_event_t type)); +/* match ipv6 next-hop type */ +extern 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)); +/* no match ipv6 next-hop type */ +extern 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)); /* match metric */ extern void route_map_match_metric_hook(int (*func)( struct vty *vty, struct route_map_index *index, const char *command, |