XFREE(MTYPE_ROUTE_MAP_COMPILED, rcom);
}
+/*
+ * In routemap processing there is a need to add the
+ * name as a rule_key in the dependency table. Routemap
+ * lib is unaware of rule_key when exact-match clause
+ * is in use. routemap lib uses the compiled output to
+ * get the rule_key value.
+ */
+static void *route_match_get_community_key(void *rule)
+{
+ struct rmap_community *rcom;
+
+ rcom = rule;
+ return rcom->name;
+}
+
+
/* Route map commands for community matching. */
struct route_map_rule_cmd route_match_community_cmd = {
"community", route_match_community, route_match_community_compile,
- route_match_community_free};
+ route_match_community_free, route_match_get_community_key};
/* Match function for lcommunity match. */
static enum route_map_cmd_result_t
/* Route map commands for community matching. */
struct route_map_rule_cmd route_match_lcommunity_cmd = {
"large-community", route_match_lcommunity,
- route_match_lcommunity_compile, route_match_lcommunity_free};
+ route_match_lcommunity_compile, route_match_lcommunity_free,
+ route_match_get_community_key};
/* Match function for extcommunity match. */
path = object;
peer = path->peer;
- if ((CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
- || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT))
- && peer->su_remote
- && sockunion_family(peer->su_remote) == AF_INET6) {
+ if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IN)
+ || CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_IMPORT)) {
/* Set next hop preference to global */
path->attr->mp_nexthop_prefer_global = true;
SET_FLAG(path->attr->rmap_change_flags,
/* Set next hop value and length in attribute. */
if (IN6_IS_ADDR_LINKLOCAL(&peer_address)) {
path->attr->mp_nexthop_local = peer_address;
- if (path->attr->mp_nexthop_len != 32)
- path->attr->mp_nexthop_len = 32;
+ if (path->attr->mp_nexthop_len
+ != BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL)
+ path->attr->mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV6_GLOBAL_AND_LL;
} else {
path->attr->mp_nexthop_global = peer_address;
if (path->attr->mp_nexthop_len == 0)
- path->attr->mp_nexthop_len = 16;
+ path->attr->mp_nexthop_len =
+ BGP_ATTR_NHLEN_IPV6_GLOBAL;
}
} else if (CHECK_FLAG(peer->rmap_type, PEER_RMAP_TYPE_OUT)) {
/* Set next hop value. */
path->attr->mp_nexthop_global_in = *address;
- path->attr->mp_nexthop_len = 4;
+ path->attr->mp_nexthop_len = BGP_ATTR_NHLEN_IPV4;
}
return RMAP_OKAY;
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
- if (type != RMAP_EVENT_MATCH_ADDED) {
- route_map_upd8_dependency(type, arg, index->map->name);
- }
- break;
- case RMAP_DUPLICATE_RULE:
/*
* Intentionally doing nothing here.
*/
rmap_name = XSTRDUP(MTYPE_ROUTE_MAP_NAME, index->map->name);
}
- ret = route_map_delete_match(index, command, dep_name);
+ ret = route_map_delete_match(index, command, dep_name, type);
switch (ret) {
case RMAP_RULE_MISSING:
vty_out(vty, "%% BGP Can't find rule.\n");
retval = CMD_WARNING_CONFIG_FAILED;
break;
case RMAP_COMPILE_SUCCESS:
- if (type != RMAP_EVENT_MATCH_DELETED && dep_name)
- route_map_upd8_dependency(type, dep_name, rmap_name);
- break;
- case RMAP_DUPLICATE_RULE:
/*
* Nothing to do here
*/