summaryrefslogtreecommitdiffstats
path: root/ripd
diff options
context:
space:
mode:
authorDonatas Abraitis <donatas.abraitis@gmail.com>2019-06-21 17:51:33 +0200
committerDonatas Abraitis <donatas.abraitis@gmail.com>2019-06-21 23:07:20 +0200
commitb6c0e91356c612c269a1a50555c12c12bc038310 (patch)
tree954a4e5d8d47326735853153283012549b86af44 /ripd
parentPrefix list count (#4578) (diff)
downloadfrr-b6c0e91356c612c269a1a50555c12c12bc038310.tar.xz
frr-b6c0e91356c612c269a1a50555c12c12bc038310.zip
rmap: Add hooks into zebra,ospf,rip for `match ip next-hop type blackhole`
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
Diffstat (limited to 'ripd')
-rw-r--r--ripd/rip_routemap.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/ripd/rip_routemap.c b/ripd/rip_routemap.c
index 3216b8f89..85d83c61d 100644
--- a/ripd/rip_routemap.c
+++ b/ripd/rip_routemap.c
@@ -231,6 +231,40 @@ static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = {
route_match_ip_next_hop_prefix_list_compile,
route_match_ip_next_hop_prefix_list_free};
+/* `match ip next-hop type <blackhole>' */
+
+static route_map_result_t
+route_match_ip_next_hop_type(void *rule, const struct prefix *prefix,
+ route_map_object_t type, void *object)
+{
+ struct rip_info *rinfo;
+
+ if (type == RMAP_RIP && prefix->family == AF_INET) {
+ rinfo = (struct rip_info *)object;
+ if (!rinfo)
+ return RMAP_DENYMATCH;
+
+ if (rinfo->nh.type == NEXTHOP_TYPE_BLACKHOLE)
+ return RMAP_MATCH;
+ }
+ return RMAP_NOMATCH;
+}
+
+static void *route_match_ip_next_hop_type_compile(const char *arg)
+{
+ return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg);
+}
+
+static void route_match_ip_next_hop_type_free(void *rule)
+{
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
+}
+
+static struct route_map_rule_cmd route_match_ip_next_hop_type_cmd = {
+ "ip next-hop type", route_match_ip_next_hop_type,
+ route_match_ip_next_hop_type_compile,
+ route_match_ip_next_hop_type_free};
+
/* `match ip address IP_ACCESS_LIST' */
/* Match function should return 1 if match is success else return
@@ -537,6 +571,9 @@ void rip_route_map_init(void)
route_map_match_ip_next_hop_prefix_list_hook(generic_match_add);
route_map_no_match_ip_next_hop_prefix_list_hook(generic_match_delete);
+ route_map_match_ip_next_hop_type_hook(generic_match_add);
+ route_map_no_match_ip_next_hop_type_hook(generic_match_delete);
+
route_map_match_metric_hook(generic_match_add);
route_map_no_match_metric_hook(generic_match_delete);
@@ -556,6 +593,7 @@ void rip_route_map_init(void)
route_map_install_match(&route_match_interface_cmd);
route_map_install_match(&route_match_ip_next_hop_cmd);
route_map_install_match(&route_match_ip_next_hop_prefix_list_cmd);
+ route_map_install_match(&route_match_ip_next_hop_type_cmd);
route_map_install_match(&route_match_ip_address_cmd);
route_map_install_match(&route_match_ip_address_prefix_list_cmd);
route_map_install_match(&route_match_tag_cmd);