Skip to content

Commit

Permalink
NX-OS: Allow ICMP ACL lines without l4 options (#8267)
Browse files Browse the repository at this point in the history
Fixes #8264
  • Loading branch information
ratulm committed Apr 26, 2022
1 parent 4aebc34 commit 538dff4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ packet_length
aclla_icmp
:
ICMP acllal3_src_address acllal3_dst_address
// NX-OS allows multiple l3 options but only one l4 option, interleaved in any order.
acllal3_option* acllal4icmp_option acllal3_option*
// NX-OS allows multiple l3 options but at most l4 option, interleaved in any order.
acllal3_option* acllal4icmp_option? acllal3_option*
NEWLINE
;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
Expand Down Expand Up @@ -487,6 +488,10 @@ public final class CiscoNxosGrammarTest {
return _aclToBdd.toPermitAndDenyBdds(aclLine).getMatchBdd();
}

private @Nonnull BDD toIcmpIfBDD() {
return toIfBDD(AclLineMatchExprs.and(matchFragmentOffset(0), matchIpProtocol(IpProtocol.ICMP)));
}

private @Nonnull BDD toIcmpIfBDD(AclLineMatchExpr aclLineMatchExpr) {
return toIfBDD(
AclLineMatchExprs.and(
Expand Down Expand Up @@ -3487,6 +3492,7 @@ public void testIpAccessListConversion() throws IOException {
assertThat(
acl.getLines().stream().map(this::toIfBDD).collect(ImmutableList.toImmutableList()),
contains(
toIcmpIfBDD(),
toIcmpIfBDD(matchIcmpType(0)),
toIcmpIfBDD(matchIcmp(1, 2)),
toIcmpIfBDD(matchIcmp(IcmpCode.COMMUNICATION_ADMINISTRATIVELY_PROHIBITED)),
Expand Down Expand Up @@ -3979,11 +3985,14 @@ public void testIpAccessListExtraction() {
}
{
IpAccessList acl = vc.getIpAccessLists().get("acl_icmp");
// check first line (with null L4 options), and then the rest
assertThat(((ActionIpAccessListLine) acl.getLines().get(10L)).getL4Options(), nullValue());
assertThat(
acl.getLines().values().stream()
.filter(ActionIpAccessListLine.class::isInstance) // filter ICMPv6
.map(ActionIpAccessListLine.class::cast)
.map(ActionIpAccessListLine::getL4Options)
.filter(Objects::nonNull)
.map(IcmpOptions.class::cast)
.map(icmpOptions -> immutableEntry(icmpOptions.getType(), icmpOptions.getCode()))
.collect(ImmutableList.toImmutableList()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ ip access-list acl_common_ip_options_ttl

!!! ICMP options
ip access-list acl_icmp
! without any options
permit icmp any any
! match ICMP type 0
! type can be 0-255
permit icmp any any 0
Expand Down

0 comments on commit 538dff4

Please sign in to comment.