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

Cisco: parse and track refs in ip[v6] local policy route-map #6341

Merged
merged 1 commit into from
Oct 20, 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 @@ -2660,6 +2660,12 @@ s_interface_line
NO? INTERFACE BREAKOUT null_rest_of_line
;

s_ip
:
IP
ip_local
;

s_ip_default_gateway
:
NO? IP DEFAULT_GATEWAY
Expand Down Expand Up @@ -2701,6 +2707,16 @@ s_ip_domain_name
)? NEWLINE
;

ip_local
:
LOCAL ipl_policy
;

ipl_policy
:
POLICY ROUTE_MAP name = variable NEWLINE
;

s_ip_name_server
:
IP NAME_SERVER
Expand Down Expand Up @@ -2806,6 +2822,22 @@ s_ipsla
)*
;

s_ipv6
:
IPV6
ipv6_local
;

ipv6_local
:
LOCAL ipv6l_policy
;

ipv6l_policy
:
POLICY ROUTE_MAP name = variable NEWLINE
;

s_l2
:
NO? L2 null_rest_of_line
Expand Down Expand Up @@ -3708,6 +3740,7 @@ stanza
// do not move below s_interface
s_interface_line
| s_interface
| s_ip
| s_ip_access_list_eth
| s_ip_access_list_session
| s_ip_default_gateway
Expand All @@ -3726,8 +3759,9 @@ stanza
| s_ip_tacacs_source_interface
| s_ip_wccp
| s_ipc
| s_ipv6_router_ospf
| s_ipsla
| s_ipv6
| s_ipv6_router_ospf
| s_key
| s_l2
| s_l2tp_class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,6 @@ null_single
| ICMP
| IGMP
| LOAD_SHARING
| LOCAL
| MFIB
| MFWD
| MOBILE
Expand Down Expand Up @@ -725,7 +724,6 @@ null_single
| FIREWALL
| HOP_LIMIT
| HOST
| LOCAL
| MFIB
| MFIB_MODE
| MLD
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,9 @@
import static org.batfish.representation.cisco.CiscoStructureUsage.INTERFACE_ZONE_MEMBER;
import static org.batfish.representation.cisco.CiscoStructureUsage.IPSEC_PROFILE_ISAKMP_PROFILE;
import static org.batfish.representation.cisco.CiscoStructureUsage.IPSEC_PROFILE_TRANSFORM_SET;
import static org.batfish.representation.cisco.CiscoStructureUsage.IPV6_LOCAL_POLICY_ROUTE_MAP;
import static org.batfish.representation.cisco.CiscoStructureUsage.IP_DOMAIN_LOOKUP_INTERFACE;
import static org.batfish.representation.cisco.CiscoStructureUsage.IP_LOCAL_POLICY_ROUTE_MAP;
import static org.batfish.representation.cisco.CiscoStructureUsage.IP_NAT_SOURCE_ACCESS_LIST;
import static org.batfish.representation.cisco.CiscoStructureUsage.IP_NAT_SOURCE_POOL;
import static org.batfish.representation.cisco.CiscoStructureUsage.IP_ROUTE_NHINT;
Expand Down Expand Up @@ -652,11 +654,13 @@
import org.batfish.grammar.cisco.CiscoParser.Ip_route_stanzaContext;
import org.batfish.grammar.cisco.CiscoParser.Ip_route_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Ip_ssh_versionContext;
import org.batfish.grammar.cisco.CiscoParser.Ipl_policyContext;
import org.batfish.grammar.cisco.CiscoParser.Ipsec_authenticationContext;
import org.batfish.grammar.cisco.CiscoParser.Ipsec_encryptionContext;
import org.batfish.grammar.cisco.CiscoParser.Ipsec_encryption_arubaContext;
import org.batfish.grammar.cisco.CiscoParser.Ipv6_prefix_list_stanzaContext;
import org.batfish.grammar.cisco.CiscoParser.Ipv6_prefix_list_tailContext;
import org.batfish.grammar.cisco.CiscoParser.Ipv6l_policyContext;
import org.batfish.grammar.cisco.CiscoParser.Is_type_is_stanzaContext;
import org.batfish.grammar.cisco.CiscoParser.L_access_classContext;
import org.batfish.grammar.cisco.CiscoParser.L_exec_timeoutContext;
Expand Down Expand Up @@ -6013,6 +6017,22 @@ public void exitIp_domain_name(Ip_domain_nameContext ctx) {
}
}

@Override
public void exitIpl_policy(Ipl_policyContext ctx) {
todo(ctx);
String name = ctx.name.getText();
_configuration.referenceStructure(
ROUTE_MAP, name, IP_LOCAL_POLICY_ROUTE_MAP, ctx.name.start.getLine());
}

@Override
public void exitIpv6l_policy(Ipv6l_policyContext ctx) {
todo(ctx);
String name = ctx.name.getText();
_configuration.referenceStructure(
ROUTE_MAP, name, IPV6_LOCAL_POLICY_ROUTE_MAP, ctx.name.start.getLine());
}

@Override
public void exitIp_nat_pool(Ip_nat_poolContext ctx) {
String name = ctx.name.getText();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ public enum CiscoStructureUsage implements StructureUsage {
IP_NAT_DESTINATION_ACCESS_LIST("ip nat destination acl"),
IP_NAT_SOURCE_ACCESS_LIST("ip nat source dynamic access-list"),
IP_NAT_SOURCE_POOL("ip nat source pool"),
IP_LOCAL_POLICY_ROUTE_MAP("ip local policy route-map"),
IPV6_LOCAL_POLICY_ROUTE_MAP("ipv6 local policy route-map"),
IP_TACACS_SOURCE_INTERFACE("ip tacacs source-interface"),
IPSEC_PROFILE_ISAKMP_PROFILE("ipsec profile set isakmp-profile"),
IPSEC_PROFILE_TRANSFORM_SET("ipsec profile set transform-set"),
Expand Down
2 changes: 2 additions & 0 deletions tests/parsing-tests/networks/unit-tests/configs/cisco_misc
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ ip flow-aggregation cache source-prefix
!
ip inspect WAAS flush-timeout 10
ip internal event-history static-rt size small
ip local policy route-map V4POLICY
ipv6 local policy route-map V6POLICY
ip mfwd event-history packet size small
ip ospf name-lookup
ip spd queue max-threshold 123
Expand Down
34 changes: 29 additions & 5 deletions tests/parsing-tests/unit-tests-undefined.ref
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,7 @@
"Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
206
208
]
}
},
Expand All @@ -1637,7 +1637,7 @@
"Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
208
210
]
}
},
Expand All @@ -1649,7 +1649,7 @@
"Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
195
197
]
}
},
Expand All @@ -1665,6 +1665,30 @@
]
}
},
{
"File_Name" : "configs/cisco_misc",
"Struct_Type" : "route-map",
"Ref_Name" : "V4POLICY",
"Context" : "ip local policy route-map",
"Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
107
]
}
},
{
"File_Name" : "configs/cisco_misc",
"Struct_Type" : "route-map",
"Ref_Name" : "V6POLICY",
"Context" : "ipv6 local policy route-map",
"Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
108
]
}
},
{
"File_Name" : "configs/cisco_ntp",
"Struct_Type" : "interface",
Expand Down Expand Up @@ -4410,10 +4434,10 @@
}
],
"summary" : {
"notes" : "Found 358 results",
"notes" : "Found 360 results",
"numFailed" : 0,
"numPassed" : 0,
"numResults" : 358
"numResults" : 360
}
}
]
4 changes: 2 additions & 2 deletions tests/parsing-tests/unit-tests-unused.ref
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,8 @@
"Source_Lines" : {
"filename" : "configs/cisco_misc",
"lines" : [
177,
178
179,
180
]
}
},
Expand Down
18 changes: 16 additions & 2 deletions tests/parsing-tests/unit-tests-warnings.ref
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,20 @@
"Parser_Context" : "[extended_ipv6_access_list_tail extended_ipv6_access_list_stanza stanza cisco_configuration]",
"Comment" : "Unsupported clause in IPv6 extended access list: mldv2"
},
{
"Filename" : "configs/cisco_misc",
"Line" : 107,
"Text" : "policy route-map V4POLICY",
"Parser_Context" : "[ipl_policy ip_local s_ip stanza cisco_configuration]",
"Comment" : "This feature is not currently supported"
},
{
"Filename" : "configs/cisco_misc",
"Line" : 108,
"Text" : "policy route-map V6POLICY",
"Parser_Context" : "[ipv6l_policy ipv6_local s_ipv6 stanza cisco_configuration]",
"Comment" : "This feature is not currently supported"
},
{
"Filename" : "configs/cisco_ospf",
"Line" : 26,
Expand Down Expand Up @@ -1493,10 +1507,10 @@
}
],
"summary" : {
"notes" : "Found 207 results",
"notes" : "Found 209 results",
"numFailed" : 0,
"numPassed" : 0,
"numResults" : 207
"numResults" : 209
}
}
]