summaryrefslogtreecommitdiffstats
path: root/zebra/zebra_routemap.c
diff options
context:
space:
mode:
authorDonald Sharp <sharpd@cumulusnetworks.com>2017-11-03 15:33:09 +0100
committerDonald Sharp <sharpd@cumulusnetworks.com>2017-11-06 16:05:55 +0100
commit5165d46fda52111035f12d611978ef56f360d9c5 (patch)
tree5e7c553812ae69e9f758ea960350da70fd19de79 /zebra/zebra_routemap.c
parentMerge pull request #1405 from dslicenc/cm18634-bgp-default (diff)
downloadfrr-5165d46fda52111035f12d611978ef56f360d9c5.tar.xz
frr-5165d46fda52111035f12d611978ef56f360d9c5.zip
doc, zebra: Add 'match ipv6 address prefix-len (0-128)' command
Add the ability to match a specific prefix-length in zebra. This command behaves in the same manner that the v4 version of the command behaves. Fixes: #1398 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Diffstat (limited to 'zebra/zebra_routemap.c')
-rw-r--r--zebra/zebra_routemap.c53
1 files changed, 43 insertions, 10 deletions
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c
index 7bfaf8e27..61af60b5d 100644
--- a/zebra/zebra_routemap.c
+++ b/zebra/zebra_routemap.c
@@ -229,6 +229,33 @@ DEFUN (no_match_ip_address_prefix_len,
RMAP_EVENT_MATCH_DELETED);
}
+DEFUN (match_ipv6_address_prefix_len,
+ match_ipv6_address_prefix_len_cmd,
+ "match ipv6 address prefix-len (0-128)",
+ MATCH_STR
+ IPV6_STR
+ "Match prefix length of ipv6 address\n"
+ "Match prefix length of ipv6 address\n"
+ "Prefix length\n")
+{
+ return zebra_route_match_add(vty, "ipv6 address prefix-len", argv[4]->arg,
+ RMAP_EVENT_MATCH_ADDED);
+}
+
+DEFUN (no_match_ipv6_address_prefix_len,
+ no_match_ipv6_address_prefix_len_cmd,
+ "no match ipv6 address prefix-len [(0-128)]",
+ NO_STR
+ MATCH_STR
+ IPV6_STR
+ "Match prefix length of ip address\n"
+ "Match prefix length of ip address\n"
+ "Prefix length\n")
+{
+ char *plen = (argc == 6) ? argv[5]->arg : NULL;
+ return zebra_route_match_delete(vty, "ipv6 address prefix-len", plen,
+ RMAP_EVENT_MATCH_DELETED);
+}
DEFUN (match_ip_nexthop_prefix_len,
match_ip_nexthop_prefix_len_cmd,
@@ -258,7 +285,6 @@ DEFUN (no_match_ip_nexthop_prefix_len,
RMAP_EVENT_MATCH_DELETED);
}
-
DEFUN (match_source_protocol,
match_source_protocol_cmd,
"match source-protocol <bgp|ospf|rip|ripng|isis|ospf6|pim|nhrp|eigrp|babel|connected|system|kernel|static>",
@@ -1012,8 +1038,8 @@ static struct route_map_rule_cmd route_match_ip_address_prefix_list_cmd = {
/* `match ip address prefix-len PREFIXLEN' */
static route_map_result_t
-route_match_ip_address_prefix_len(void *rule, struct prefix *prefix,
- route_map_object_t type, void *object)
+route_match_address_prefix_len(void *rule, struct prefix *prefix,
+ route_map_object_t type, void *object)
{
u_int32_t *prefixlen = (u_int32_t *)rule;
@@ -1024,7 +1050,7 @@ route_match_ip_address_prefix_len(void *rule, struct prefix *prefix,
return RMAP_NOMATCH;
}
-static void *route_match_ip_address_prefix_len_compile(const char *arg)
+static void *route_match_address_prefix_len_compile(const char *arg)
{
u_int32_t *prefix_len;
char *endptr = NULL;
@@ -1048,16 +1074,20 @@ static void *route_match_ip_address_prefix_len_compile(const char *arg)
return prefix_len;
}
-static void route_match_ip_address_prefix_len_free(void *rule)
+static void route_match_address_prefix_len_free(void *rule)
{
XFREE(MTYPE_ROUTE_MAP_COMPILED, rule);
}
static struct route_map_rule_cmd route_match_ip_address_prefix_len_cmd = {
- "ip address prefix-len", route_match_ip_address_prefix_len,
- route_match_ip_address_prefix_len_compile,
- route_match_ip_address_prefix_len_free};
+ "ip address prefix-len", route_match_address_prefix_len,
+ route_match_address_prefix_len_compile,
+ route_match_address_prefix_len_free};
+static struct route_map_rule_cmd route_match_ipv6_address_prefix_len_cmd = {
+ "ipv6 address prefix-len", route_match_address_prefix_len,
+ route_match_address_prefix_len_compile,
+ route_match_address_prefix_len_free};
/* `match ip nexthop prefix-len PREFIXLEN' */
@@ -1095,8 +1125,8 @@ route_match_ip_nexthop_prefix_len(void *rule, struct prefix *prefix,
static struct route_map_rule_cmd route_match_ip_nexthop_prefix_len_cmd = {
"ip next-hop prefix-len", route_match_ip_nexthop_prefix_len,
- route_match_ip_address_prefix_len_compile, /* reuse */
- route_match_ip_address_prefix_len_free /* reuse */
+ route_match_address_prefix_len_compile, /* reuse */
+ route_match_address_prefix_len_free /* reuse */
};
/* `match source-protocol PROTOCOL' */
@@ -1438,6 +1468,7 @@ void zebra_route_map_init()
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_ip_address_prefix_len_cmd);
+ route_map_install_match(&route_match_ipv6_address_prefix_len_cmd);
route_map_install_match(&route_match_ip_nexthop_prefix_len_cmd);
route_map_install_match(&route_match_source_protocol_cmd);
/* */
@@ -1446,6 +1477,8 @@ void zebra_route_map_init()
install_element(RMAP_NODE, &match_ip_nexthop_prefix_len_cmd);
install_element(RMAP_NODE, &no_match_ip_nexthop_prefix_len_cmd);
install_element(RMAP_NODE, &match_ip_address_prefix_len_cmd);
+ install_element(RMAP_NODE, &match_ipv6_address_prefix_len_cmd);
+ install_element(RMAP_NODE, &no_match_ipv6_address_prefix_len_cmd);
install_element(RMAP_NODE, &no_match_ip_address_prefix_len_cmd);
install_element(RMAP_NODE, &match_source_protocol_cmd);
install_element(RMAP_NODE, &no_match_source_protocol_cmd);