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

Parsing for prefix and route-map in EIGRP distribute-list #6271

Merged
merged 2 commits into from
Oct 2, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,7 @@ variable_community_name

variable_distribute_list
:
~( NEWLINE | IN | OUT )+
~( NEWLINE | GATEWAY | IN | OUT | PREFIX | ROUTE_MAP )+
;

variable_hostname
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@ re_default_metric

re_distribute_list
:
DISTRIBUTE_LIST name = variable_distribute_list
DISTRIBUTE_LIST
(
IN
| OUT
redl_acl
| redl_gateway
| redl_prefix
| redl_route_map
)
(iname = interface_name_unstructured)? NEWLINE
;

re_eigrp_null
Expand Down Expand Up @@ -344,6 +345,47 @@ rec_null
) null_rest_of_line
;

redl_acl
:
name = variable_distribute_list
(
IN
| OUT
)
(iname = interface_name_unstructured)? NEWLINE
;

redl_gateway
:
GATEWAY name = variable_distribute_list
(
IN
| OUT
)
NEWLINE
;

redl_prefix
:
PREFIX name = variable_distribute_list
( GATEWAY gwname = variable_distribute_list)?
(
IN
| OUT
)
NEWLINE
;

redl_route_map
:
ROUTE_MAP name = variable_distribute_list
(
IN
| OUT
)
NEWLINE
;

ren_address_family
:
ADDRESS_FAMILY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,12 @@
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_AF_INTERFACE;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_IN;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_OUT;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_GATEWAY_IN;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_GATEWAY_OUT;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_IN;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_OUT;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_IN;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_OUT;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_PASSIVE_INTERFACE;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_REDISTRIBUTE_BGP_MAP;
import static org.batfish.representation.cisco.CiscoStructureUsage.EIGRP_REDISTRIBUTE_CONNECTED_MAP;
Expand Down Expand Up @@ -762,7 +768,6 @@
import org.batfish.grammar.cisco.CiscoParser.Re_autonomous_systemContext;
import org.batfish.grammar.cisco.CiscoParser.Re_classicContext;
import org.batfish.grammar.cisco.CiscoParser.Re_default_metricContext;
import org.batfish.grammar.cisco.CiscoParser.Re_distribute_listContext;
import org.batfish.grammar.cisco.CiscoParser.Re_eigrp_router_idContext;
import org.batfish.grammar.cisco.CiscoParser.Re_networkContext;
import org.batfish.grammar.cisco.CiscoParser.Re_passive_interfaceContext;
Expand All @@ -787,6 +792,10 @@
import org.batfish.grammar.cisco.CiscoParser.Redistribute_rip_bgp_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Redistribute_static_bgp_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Redistribute_static_is_stanzaContext;
import org.batfish.grammar.cisco.CiscoParser.Redl_aclContext;
import org.batfish.grammar.cisco.CiscoParser.Redl_gatewayContext;
import org.batfish.grammar.cisco.CiscoParser.Redl_prefixContext;
import org.batfish.grammar.cisco.CiscoParser.Redl_route_mapContext;
import org.batfish.grammar.cisco.CiscoParser.Remote_as_bgp_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Remove_private_as_bgp_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Ren_address_familyContext;
Expand Down Expand Up @@ -7644,7 +7653,7 @@ public void exitRo_default_metric(Ro_default_metricContext ctx) {
}

@Override
public void exitRe_distribute_list(Re_distribute_listContext ctx) {
public void exitRedl_acl(Redl_aclContext ctx) {
if (_currentEigrpProcess == null) {
warn(ctx, "No EIGRP process available");
return;
Expand All @@ -7654,8 +7663,7 @@ public void exitRe_distribute_list(Re_distribute_listContext ctx) {
String filterName = ctx.name.getText();
int line = ctx.name.getStart().getLine();
if (ctx.IN() != null) {
_w.addWarning(
ctx, getFullText(ctx), _parser, "Inbound distribute-list is not supported for EIGRP");
warn(ctx.getParent(), "Inbound distribute-list is not supported for EIGRP");
_configuration.referenceStructure(
IP_ACCESS_LIST, filterName, EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_IN, line);
if (ifaceName != null) {
Expand All @@ -7667,8 +7675,7 @@ public void exitRe_distribute_list(Re_distribute_listContext ctx) {
_configuration.referenceStructure(
IP_ACCESS_LIST, filterName, EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_OUT, line);
if (ifaceName == null) {
_w.addWarning(
ctx, getFullText(ctx), _parser, "Global distribute-list not supported for EIGRP");
warn(ctx.getParent(), "Global distribute-list not supported for EIGRP");
return;
}
_configuration.referenceStructure(
Expand All @@ -7678,6 +7685,57 @@ public void exitRe_distribute_list(Re_distribute_listContext ctx) {
.put(ifaceName, new DistributeList(filterName, DistributeListFilterType.ACCESS_LIST));
}

@Override
public void exitRedl_prefix(Redl_prefixContext ctx) {
if (_currentEigrpProcess == null) {
warn(ctx, "No EIGRP process available");
return;
}
warn(ctx.getParent(), "Prefix lists in distribute-list are not supported for EIGRP");
_configuration.referenceStructure(
PREFIX_LIST,
ctx.name.getText(),
ctx.IN() == null
? EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_OUT
: EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_IN,
ctx.name.getStart().getLine());
if (ctx.gwname != null) {
_configuration.referenceStructure(
PREFIX_LIST,
ctx.gwname.getText(),
ctx.IN() == null ? EIGRP_DISTRIBUTE_LIST_GATEWAY_OUT : EIGRP_DISTRIBUTE_LIST_GATEWAY_IN,
ctx.gwname.getStart().getLine());
}
}

@Override
public void exitRedl_gateway(Redl_gatewayContext ctx) {
if (_currentEigrpProcess == null) {
warn(ctx, "No EIGRP process available");
return;
}
warn(ctx.getParent(), "Gateways in distribute-list are not supported for EIGRP");
_configuration.referenceStructure(
PREFIX_LIST,
ctx.name.getText(),
ctx.IN() == null ? EIGRP_DISTRIBUTE_LIST_GATEWAY_OUT : EIGRP_DISTRIBUTE_LIST_GATEWAY_IN,
ctx.name.getStart().getLine());
}

@Override
public void exitRedl_route_map(Redl_route_mapContext ctx) {
if (_currentEigrpProcess == null) {
warn(ctx, "No EIGRP process available");
return;
}
warn(ctx.getParent(), "Route maps in distribute-list are not supported for EIGRP");
_configuration.referenceStructure(
ROUTE_MAP,
ctx.name.getText(),
ctx.IN() == null ? EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_OUT : EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_IN,
ctx.name.getStart().getLine());
}

@Override
public void exitRo_distance_distance(Ro_distance_distanceContext ctx) {
todo(ctx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3512,6 +3512,10 @@ public List<Configuration> toVendorIndependentConfigurations() {
CiscoStructureType.PREFIX_LIST,
CiscoStructureUsage.BGP_INBOUND_PREFIX_LIST,
CiscoStructureUsage.BGP_OUTBOUND_PREFIX_LIST,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_GATEWAY_IN,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_GATEWAY_OUT,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_IN,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_OUT,
CiscoStructureUsage.OSPF_DISTRIBUTE_LIST_PREFIX_LIST_IN,
CiscoStructureUsage.OSPF_DISTRIBUTE_LIST_PREFIX_LIST_OUT,
CiscoStructureUsage.ROUTE_MAP_MATCH_IPV4_PREFIX_LIST);
Expand Down Expand Up @@ -3548,6 +3552,8 @@ public List<Configuration> toVendorIndependentConfigurations() {
CiscoStructureUsage.BGP_ROUTE_MAP_ADVERTISE,
CiscoStructureUsage.BGP_ROUTE_MAP_UNSUPPRESS,
CiscoStructureUsage.BGP_VRF_AGGREGATE_ROUTE_MAP,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_IN,
CiscoStructureUsage.EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_OUT,
CiscoStructureUsage.EIGRP_REDISTRIBUTE_BGP_MAP,
CiscoStructureUsage.EIGRP_REDISTRIBUTE_CONNECTED_MAP,
CiscoStructureUsage.EIGRP_REDISTRIBUTE_EIGRP_MAP,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public enum CiscoStructureUsage implements StructureUsage {
EIGRP_AF_INTERFACE("eigrp address-family af-interface"),
EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_IN("router eigrp distribute-list in"),
EIGRP_DISTRIBUTE_LIST_ACCESS_LIST_OUT("router eigrp distribute-list out"),
EIGRP_DISTRIBUTE_LIST_GATEWAY_IN("router eigrp distribute-list gateway in"),
EIGRP_DISTRIBUTE_LIST_GATEWAY_OUT("router eigrp distribute-list gateway out"),
EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_IN("router eigrp distribute-list prefix in"),
EIGRP_DISTRIBUTE_LIST_PREFIX_LIST_OUT("router eigrp distribute-list prefix out"),
EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_IN("router eigrp distribute-list route-map in"),
EIGRP_DISTRIBUTE_LIST_ROUTE_MAP_OUT("router eigrp distribute-list route-map out"),
EIGRP_PASSIVE_INTERFACE("eigrp passive-interface"),
EIGRP_REDISTRIBUTE_BGP_MAP("eigrp redistribute bgp route-map"),
EIGRP_REDISTRIBUTE_CONNECTED_MAP("eigrp redistribute connected route-map"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2799,6 +2799,14 @@ public void testIosEigrpDistributeListRefsAndWarnings() throws IOException {
assertThat(ccae, hasNumReferrers(filename, IPV4_ACCESS_LIST_STANDARD, "2", 2));
assertThat(ccae, hasNumReferrers(filename, INTERFACE, "GigabitEthernet0/0", 3));

assertThat(ccae, hasNumReferrers(filename, PREFIX_LIST, "PL_IN", 2));
assertThat(ccae, hasNumReferrers(filename, PREFIX_LIST, "PL_OUT", 2));
assertThat(ccae, hasNumReferrers(filename, PREFIX_LIST, "PL_GW_IN", 2));
assertThat(ccae, hasNumReferrers(filename, PREFIX_LIST, "PL_GW_OUT", 2));

assertThat(ccae, hasNumReferrers(filename, ROUTE_MAP, "RM_IN", 1));
assertThat(ccae, hasNumReferrers(filename, ROUTE_MAP, "RM_OUT", 1));

ParseVendorConfigurationAnswerElement pvcae =
batfish.loadParseVendorConfigurationAnswerElement(batfish.getSnapshot());

Expand All @@ -2810,6 +2818,20 @@ public void testIosEigrpDistributeListRefsAndWarnings() throws IOException {
pvcae,
hasParseWarning(
filename, containsString("Global distribute-list not supported for EIGRP")));

assertThat(
pvcae,
hasParseWarning(
filename,
containsString("Prefix lists in distribute-list are not supported for EIGRP")));
assertThat(
pvcae,
hasParseWarning(
filename, containsString("Gateways in distribute-list are not supported for EIGRP")));
assertThat(
pvcae,
hasParseWarning(
filename, containsString("Route maps in distribute-list are not supported for EIGRP")));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,31 @@ router eigrp 1
distribute-list 1 in GigabitEthernet0/0
distribute-list 2 in
!
!
ip prefix-list PL_IN permit 0.0.0.0/0 le 32
!
ip prefix-list PL_OUT permit 0.0.0.0/0 le 32
!
ip prefix-list PL_GW_IN permit 0.0.0.0/0 le 32
!
ip prefix-list PL_GW_OUT permit 0.0.0.0/0 le 32
!
router eigrp 2
distribute-list prefix PL_IN in
distribute-list prefix PL_IN gateway PL_GW_IN in
distribute-list gateway PL_GW_IN in

distribute-list prefix PL_OUT out
distribute-list prefix PL_OUT gateway PL_GW_OUT out
distribute-list gateway PL_GW_OUT out
!
!
route-map RM_IN permit 10
!
route-map RM_OUT permit 10
!
router eigrp 3
distribute-list route-map RM_IN in

distribute-list route-map RM_OUT out
!