From e038e92d86fce2df7e50071436ceac5cf0a9ba24 Mon Sep 17 00:00:00 2001 From: Marek Gradzki Date: Tue, 18 Oct 2016 09:48:01 +0200 Subject: Make ip-version mandatory for all ACEs - ip-version was mandatory only when mixing l2/l3 rules in one ACE (vpp api limitation). It needs to be provided also in case of ACEs that define l3 only rules (we allow mixing ip4/ip6 ACEs in one list). - updates postman collestion with example of L4 only acl Change-Id: Ifb863208c21a504cd61843f7540341bc35a6174a Signed-off-by: Marek Gradzki --- .../v3po/interfaces/acl/ingress/IetfAclWriter.java | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'v3po/v3po2vpp/src/main/java/io') diff --git a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclWriter.java index 58a72ab30..c74845ce7 100644 --- a/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclWriter.java +++ b/v3po/v3po2vpp/src/main/java/io/fd/honeycomb/translate/v3po/interfaces/acl/ingress/IetfAclWriter.java @@ -152,13 +152,14 @@ public final class IetfAclWriter implements JvppReplyConsumer, AclTranslator { private static boolean appliesToIp4Path(final Ace ace) { final AceType aceType = ace.getMatches().getAceType(); - if (aceType instanceof AceIp && ((AceIp) aceType).getAceIpVersion() instanceof AceIpv4) { + final AclType aclType = AclType.fromAce(ace); + if (aclType == AclType.IP4) { return true; } - if (aceType instanceof AceEth) { + if (aclType == AclType.ETH) { return true; // L2 only rules are possible for IP4 traffic } - if (aceType instanceof AceIpAndEth && ((AceIpAndEth) aceType) + if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType) .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv4) { return true; } @@ -167,13 +168,14 @@ public final class IetfAclWriter implements JvppReplyConsumer, AclTranslator { private static boolean appliesToIp6Path(final Ace ace) { final AceType aceType = ace.getMatches().getAceType(); - if (aceType instanceof AceIp && ((AceIp) aceType).getAceIpVersion() instanceof AceIpv6) { + final AclType aclType = AclType.fromAce(ace); + if (aclType == AclType.IP6) { return true; } - if (aceType instanceof AceEth) { - return true; // L2 only rules are possible for IP6 traffic + if (aclType == AclType.ETH) { + return true; // L2 only rules are possible for IP6 traffic } - if (aceType instanceof AceIpAndEth && ((AceIpAndEth) aceType) + if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType) .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv6) { return true; } @@ -291,9 +293,12 @@ public final class IetfAclWriter implements JvppReplyConsumer, AclTranslator { result = ETH; } else if (aceType instanceof AceIp) { final AceIpVersion aceIpVersion = ((AceIp) aceType).getAceIpVersion(); + if (aceIpVersion == null) { + throw new IllegalArgumentException("Incomplete ACE (ip-version was not provided): " + ace); + } if (aceIpVersion instanceof AceIpv4) { result = IP4; - } else { + } else if (aceIpVersion instanceof AceIpv6) { result = IP6; } } else if (aceType instanceof AceIpAndEth) { -- cgit 1.2.3-korg