Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FRR: Parse route map in l2vpn evpn address family #6604

Merged
merged 1 commit into from Jan 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -178,6 +178,7 @@ sbafl_neighbor
NEIGHBOR neighbor = (IP_ADDRESS | WORD)
(
sbafln_activate
| sbafln_route_map
| sbafln_route_reflector_client
)
;
Expand Down Expand Up @@ -241,6 +242,11 @@ sbafln_activate
ACTIVATE NEWLINE
;

sbafln_route_map
:
ROUTE_MAP name=word (IN | OUT) NEWLINE
;

sbafln_route_reflector_client
:
ROUTE_REFLECTOR_CLIENT NEWLINE
Expand Down
Expand Up @@ -127,6 +127,7 @@
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbafla_ipv4_unicastContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbafla_ipv6_unicastContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbafln_activateContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbafln_route_mapContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbafln_route_reflector_clientContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbb_cluster_idContext;
import org.batfish.grammar.cumulus_frr.CumulusFrrParser.Sbb_confederationContext;
Expand Down Expand Up @@ -895,6 +896,25 @@ public void exitSbafln_activate(Sbafln_activateContext ctx) {
_currentBgpNeighborL2vpnEvpnAddressFamily.setActivated(true);
}

@Override
public void exitSbafln_route_map(Sbafln_route_mapContext ctx) {
String name = ctx.name.getText();
CumulusStructureUsage usage;
if (ctx.IN() != null) {
usage = CumulusStructureUsage.BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_IN;
} else if (ctx.OUT() != null) {
usage = CumulusStructureUsage.BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_OUT;
} else {
throw new IllegalStateException("only support in and out in route map");
}
_w.addWarning(
ctx,
getFullText(ctx.getParent()),
_parser,
"Routes maps on neighbors in address-family 'l2vpn evpn' are not supported");
_c.referenceStructure(ROUTE_MAP, name, usage, ctx.name.getStart().getLine());
}

@Override
public void exitSbafln_route_reflector_client(Sbafln_route_reflector_clientContext ctx) {
if (_currentBgpNeighborL2vpnEvpnAddressFamily == null) {
Expand Down
Expand Up @@ -16,6 +16,8 @@ public enum CumulusStructureUsage implements StructureUsage {
BGP_IPV4_UNICAST_REDISTRIBUTE_OSPF_ROUTE_MAP("bgp ipv4 unicast redistribute ospf route-map"),
BGP_IPV4_UNICAST_NEIGHBOR_ROUTE_MAP_IN("bgp ipv4 unicast neighbor route-map in"),
BGP_IPV4_UNICAST_NEIGHBOR_ROUTE_MAP_OUT("bgp ipv4 unicast neighbor route-map out"),
BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_IN("bgp l2vpn evpn neighbor route-map in"),
BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_OUT("bgp l2vpn evpn neighbor route-map out"),
BGP_NEIGHBOR_INTERFACE("bgp neighbor interface"),
BGP_NETWORK("bgp network"),
BGP_VRF("bgp vrf"),
Expand Down
Expand Up @@ -489,6 +489,32 @@ public void testBgpAdressFamilyL2vpnEvpnNeighborActivate() {
assertTrue(neighbors.get("1.2.3.4").getL2vpnEvpnAddressFamily().getActivated());
}

@Test
public void testBgpAdressFamilyL2vpnEvpnNeighborRouteMap() {
parseLines(
"router bgp 1",
" neighbor n interface description a",
" address-family l2vpn evpn",
" neighbor n route-map rm in",
" neighbor n route-map rm out",
" exit-address-family");
assertThat(
getStructureReferences(
ROUTE_MAP, "rm", CumulusStructureUsage.BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_IN),
contains(4));
assertThat(
getStructureReferences(
ROUTE_MAP, "rm", CumulusStructureUsage.BGP_L2VPN_EVPN_NEIGHBOR_ROUTE_MAP_OUT),
contains(5));
assertThat(
_warnings.getParseWarnings(),
contains(
hasComment(
"Routes maps on neighbors in address-family 'l2vpn evpn' are not supported"),
hasComment(
"Routes maps on neighbors in address-family 'l2vpn evpn' are not supported")));
}

@Test
public void testBgpAdressFamilyL2vpnEvpnNeighborRouteReflectorClient() {
parseLines(
Expand Down