Skip to content

Commit

Permalink
cumulus frr route-map set community support well-known (#6657)
Browse files Browse the repository at this point in the history
  • Loading branch information
arifogel committed Feb 24, 2021
1 parent 13d9e3f commit 8514c0f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
Expand Up @@ -466,7 +466,7 @@ LE

LOCAL_AS
:
'local-as'
[Ll][Oo][Cc][Aa][Ll]'-'[Aa][Ss]
;

LOCAL_PREFERENCE
Expand Down
Expand Up @@ -240,7 +240,7 @@ rms_comm_list

rms_community
:
COMMUNITY communities += literal_standard_community+ ADDITIVE? NEWLINE
COMMUNITY communities += standard_community+ ADDITIVE? NEWLINE
;

rms_local_preference
Expand Down
Expand Up @@ -1512,13 +1512,12 @@ public void exitRms_community(Rms_communityContext ctx) {
if (old != null) {
_w.addWarning(ctx, getFullText(ctx), _parser, "overwriting set community");
}
Optional<Set<StandardCommunity>> communities = toStandardCommunitySet(ctx.communities);
if (!communities.isPresent()) {
return;
}
boolean additive = ctx.ADDITIVE() != null;
_currentRouteMapEntry.setSetCommunity(
new RouteMapSetCommunity(
ctx.communities.stream()
.map(this::toStandardCommunity)
.collect(ImmutableList.toImmutableList()),
additive));
_currentRouteMapEntry.setSetCommunity(new RouteMapSetCommunity(communities.get(), additive));
}

@Override
Expand Down
Expand Up @@ -1398,12 +1398,23 @@ public void testCumulusFrrVrfRouteMapSetIpNextHop() {
public void testCumulusFrrVrfRouteMapSetCommunity() {
String name = "ROUTE-MAP-NAME";

parse(String.format("route-map %s permit 10\nset community 10000:1 20000:2\n", name));
parse(
String.format(
"route-map %s permit 10\n"
+ "set community 10000:1 20000:2 local-AS no-advertise no-export internet\n",
name));

RouteMapEntry entry = _frr.getRouteMaps().get(name).getEntries().get(10);
assertThat(
entry.getSetCommunity().getCommunities(),
equalTo(ImmutableList.of(StandardCommunity.of(10000, 1), StandardCommunity.of(20000, 2))));
equalTo(
ImmutableList.of(
StandardCommunity.of(10000, 1),
StandardCommunity.of(20000, 2),
StandardCommunity.NO_EXPORT_SUBCONFED,
StandardCommunity.NO_ADVERTISE,
StandardCommunity.NO_EXPORT,
StandardCommunity.INTERNET)));
}

@Test
Expand Down

0 comments on commit 8514c0f

Please sign in to comment.