summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_routemap.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_routemap.c')
-rw-r--r--bgpd/bgp_routemap.c60
1 files changed, 52 insertions, 8 deletions
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index e0db43f..d604a7a 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -2323,17 +2323,10 @@ static const struct route_map_rule_cmd route_set_aspath_prepend_cmd = {
route_set_aspath_prepend_free,
};
-/* `set as-path exclude ASn' */
-struct aspath_exclude {
- struct aspath *aspath;
- bool exclude_all;
- char *exclude_aspath_acl_name;
- struct as_list *exclude_aspath_acl;
-};
-
static void *route_aspath_exclude_compile(const char *arg)
{
struct aspath_exclude *ase;
+ struct aspath_exclude_list *ael;
const char *str = arg;
static const char asp_acl[] = "as-path-access-list";
@@ -2348,16 +2341,41 @@ static void *route_aspath_exclude_compile(const char *arg)
ase->exclude_aspath_acl = as_list_lookup(str);
} else
ase->aspath = aspath_str2aspath(str, bgp_get_asnotation(NULL));
+
+ if (ase->exclude_aspath_acl) {
+ ael = XCALLOC(MTYPE_ROUTE_MAP_COMPILED,
+ sizeof(struct aspath_exclude_list));
+ ael->bp_as_excl = ase;
+ ael->next = ase->exclude_aspath_acl->exclude_list;
+ ase->exclude_aspath_acl->exclude_list = ael;
+ }
+
return ase;
}
static void route_aspath_exclude_free(void *rule)
{
struct aspath_exclude *ase = rule;
+ struct aspath_exclude_list *cur_ael = NULL;
+ struct aspath_exclude_list *prev_ael = NULL;
aspath_free(ase->aspath);
if (ase->exclude_aspath_acl_name)
XFREE(MTYPE_TMP, ase->exclude_aspath_acl_name);
+ if (ase->exclude_aspath_acl)
+ cur_ael = ase->exclude_aspath_acl->exclude_list;
+ while (cur_ael) {
+ if (cur_ael->bp_as_excl == ase) {
+ if (prev_ael)
+ prev_ael->next = cur_ael->next;
+ else
+ ase->exclude_aspath_acl->exclude_list = NULL;
+ XFREE(MTYPE_ROUTE_MAP_COMPILED, cur_ael);
+ break;
+ }
+ prev_ael = cur_ael;
+ cur_ael = cur_ael->next;
+ }
XFREE(MTYPE_ROUTE_MAP_COMPILED, ase);
}
@@ -4442,6 +4460,13 @@ static void bgp_route_map_update_peer_group(const char *rmap_name,
filter->map[direct].name)
== 0))
filter->map[direct].map = map;
+
+ if (group->conf->default_rmap[afi][safi].name &&
+ strmatch(group->conf->default_rmap[afi][safi]
+ .name,
+ rmap_name))
+ group->conf->default_rmap[afi][safi].map =
+ map;
}
if (filter->usmap.name
@@ -4596,6 +4621,7 @@ static void bgp_route_map_process_update(struct bgp *bgp, const char *rmap_name,
route_map_counter_increment(map);
aggregate->rmap.map = map;
+ aggregate->rmap.changed = true;
matched = true;
}
@@ -4743,6 +4769,24 @@ static void bgp_route_map_delete(const char *rmap_name)
route_map_notify_dependencies(rmap_name, RMAP_EVENT_MATCH_DELETED);
}
+bool bgp_route_map_has_extcommunity_rt(const struct route_map *map)
+{
+ struct route_map_index *index = NULL;
+ struct route_map_rule *set = NULL;
+
+ assert(map);
+
+ for (index = map->head; index; index = index->next) {
+ for (set = index->set_list.head; set; set = set->next) {
+ if (set->cmd && set->cmd->str &&
+ (strmatch(set->cmd->str, "extcommunity rt") ||
+ strmatch(set->cmd->str, "extended-comm-list")))
+ return true;
+ }
+ }
+ return false;
+}
+
static void bgp_route_map_event(const char *rmap_name)
{
if (route_map_mark_updated(rmap_name) == 0)