diff options
Diffstat (limited to 'zebra/zebra_routemap.c')
| -rw-r--r-- | zebra/zebra_routemap.c | 59 |
1 files changed, 41 insertions, 18 deletions
diff --git a/zebra/zebra_routemap.c b/zebra/zebra_routemap.c index bacef49836..6d52e5f9e6 100644 --- a/zebra/zebra_routemap.c +++ b/zebra/zebra_routemap.c @@ -389,7 +389,7 @@ static int ip_nht_rm_add(struct zebra_vrf *zvrf, const char *rmap, int rtype, route_map_lookup_by_name(NHT_RM_NAME(zvrf, afi, rtype)); if (NHT_RM_MAP(zvrf, afi, rtype)) - zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE, NULL); + zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); return CMD_SUCCESS; } @@ -409,7 +409,7 @@ static int ip_nht_rm_del(struct zebra_vrf *zvrf, const char *rmap, int rtype, zvrf->vrf->vrf_id, rtype); NHT_RM_MAP(zvrf, afi, rtype) = NULL; - zebra_evaluate_rnh(zvrf, AF_INET, 1, RNH_NEXTHOP_TYPE, + zebra_evaluate_rnh(zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); } XFREE(MTYPE_ROUTE_MAP_NAME, NHT_RM_NAME(zvrf, afi, rtype)); @@ -1116,15 +1116,15 @@ static struct route_map_rule_cmd route_match_ip_next_hop_prefix_list_cmd = { /* Match function should return 1 if match is success else return zero. */ -static route_map_result_t route_match_ip_address(void *rule, - const struct prefix *prefix, - route_map_object_t type, - void *object) +static route_map_result_t route_match_address(afi_t afi, void *rule, + const struct prefix *prefix, + route_map_object_t type, + void *object) { struct access_list *alist; if (type == RMAP_ZEBRA) { - alist = access_list_lookup(AFI_IP, (char *)rule); + alist = access_list_lookup(afi, (char *)rule); if (alist == NULL) return RMAP_NOMATCH; @@ -1135,23 +1135,45 @@ static route_map_result_t route_match_ip_address(void *rule, return RMAP_NOMATCH; } +static route_map_result_t route_match_ip_address(void *rule, + const struct prefix *prefix, + route_map_object_t type, + void *object) +{ + return route_match_address(AFI_IP, rule, prefix, type, object); +} + +static route_map_result_t route_match_ipv6_address(void *rule, + const struct prefix *prefix, + route_map_object_t type, + void *object) + +{ + return route_match_address(AFI_IP6, rule, prefix, type, object); +} + /* Route map `ip address' match statement. `arg' should be access-list name. */ -static void *route_match_ip_address_compile(const char *arg) +static void *route_match_address_compile(const char *arg) { return XSTRDUP(MTYPE_ROUTE_MAP_COMPILED, arg); } /* Free route map's compiled `ip address' value. */ -static void route_match_ip_address_free(void *rule) +static void route_match_address_free(void *rule) { XFREE(MTYPE_ROUTE_MAP_COMPILED, rule); } /* Route map commands for ip address matching. */ static struct route_map_rule_cmd route_match_ip_address_cmd = { - "ip address", route_match_ip_address, route_match_ip_address_compile, - route_match_ip_address_free}; + "ip address", route_match_ip_address, route_match_address_compile, + route_match_address_free}; + +/* Route map commands for ipv6 address matching. */ +static struct route_map_rule_cmd route_match_ipv6_address_cmd = { + "ipv6 address", route_match_ipv6_address, route_match_address_compile, + route_match_address_free}; /* `match ip address prefix-list PREFIX_LIST' */ @@ -1534,7 +1556,7 @@ static void zebra_nht_rm_update(const char *rmap) afi_ip = 1; zebra_evaluate_rnh( - zvrf, AF_INET, 1, + zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); } } @@ -1560,7 +1582,7 @@ static void zebra_nht_rm_update(const char *rmap) afi_ipv6 = 1; zebra_evaluate_rnh( - zvrf, AF_INET, 1, + zvrf, AFI_IP, 1, RNH_NEXTHOP_TYPE, NULL); } } @@ -1691,7 +1713,7 @@ zebra_import_table_route_map_check(int family, int re_type, uint8_t instance, return (ret); } -route_map_result_t zebra_nht_route_map_check(int family, int client_proto, +route_map_result_t zebra_nht_route_map_check(afi_t afi, int client_proto, const struct prefix *p, struct zebra_vrf *zvrf, struct route_entry *re, @@ -1709,9 +1731,9 @@ route_map_result_t zebra_nht_route_map_check(int family, int client_proto, nh_obj.tag = re->tag; if (client_proto >= 0 && client_proto < ZEBRA_ROUTE_MAX) - rmap = NHT_RM_MAP(zvrf, family, client_proto); - if (!rmap && NHT_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX)) - rmap = NHT_RM_MAP(zvrf, family, ZEBRA_ROUTE_MAX); + rmap = NHT_RM_MAP(zvrf, afi, client_proto); + if (!rmap && NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX)) + rmap = NHT_RM_MAP(zvrf, afi, ZEBRA_ROUTE_MAX); if (rmap) ret = route_map_apply(rmap, p, RMAP_ZEBRA, &nh_obj); @@ -1809,7 +1831,7 @@ void zebra_routemap_config_write_protocol(struct vty *vty, zebra_rmap_update_timer); } -void zebra_route_map_init() +void zebra_route_map_init(void) { install_element(CONFIG_NODE, &ip_protocol_cmd); install_element(CONFIG_NODE, &no_ip_protocol_cmd); @@ -1869,6 +1891,7 @@ void zebra_route_map_init() 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_address_cmd); + route_map_install_match(&route_match_ipv6_address_cmd); route_map_install_match(&route_match_ip_address_prefix_list_cmd); route_map_install_match(&route_match_ipv6_address_prefix_list_cmd); route_map_install_match(&route_match_ip_address_prefix_len_cmd); |
