summaryrefslogtreecommitdiffstats
path: root/v3po/v3po2vpp/src
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2016-12-15 11:37:42 +0100
committerJan Srnicek <jsrnicek@cisco.com>2016-12-16 08:35:08 +0000
commitce6b6c8c20db7c56b6b97835852d6d4cb3807c13 (patch)
tree031ba25955ffdeef19941dd4582f8876de0f3e36 /v3po/v3po2vpp/src
parentdf4a0a7e3ef449fee3916e7cfd874a3ab2a8c11b (diff)
HONEYCOMB-320: move ace-ip-and-eth case nodes into container
Change-Id: I6193d84363d60123571a72021ed8ad6e1d334a9b Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'v3po/v3po2vpp/src')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java6
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AbstractIetfAclWriter.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriter.java37
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriterTest.java7
4 files changed, 32 insertions, 26 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java
index 2b72cd058..235e7da2a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/factory/AclWriterFactory.java
@@ -20,8 +20,8 @@ import static io.fd.hc2vpp.v3po.factory.InterfacesClassifierIetfAclWriterFactory
import static io.fd.hc2vpp.v3po.factory.SubInterfacesClassifierIetfAclWriterFactory.SUBIF_IETF_ACL_ID;
import com.google.common.collect.Sets;
-import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.hc2vpp.v3po.interfaces.acl.IetfAclWriter;
+import io.fd.honeycomb.translate.impl.write.GenericListWriter;
import io.fd.honeycomb.translate.write.WriterFactory;
import io.fd.honeycomb.translate.write.registry.ModifiableWriterRegistryBuilder;
import javax.annotation.Nonnull;
@@ -33,6 +33,7 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.cont
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.Matches;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160708.acl.transport.header.fields.DestinationPortRange;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.packet.fields.rev160708.acl.transport.header.fields.SourcePortRange;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.AceIpAndEthNodes;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public final class AclWriterFactory implements WriterFactory {
@@ -48,10 +49,11 @@ public final class AclWriterFactory implements WriterFactory {
final InstanceIdentifier<Ace> aceId = aclIdRelative.child(AccessListEntries.class).child(Ace.class);
final InstanceIdentifier<Actions> actionsId = aceId.child(Actions.class);
final InstanceIdentifier<Matches> matchesId = aceId.child(Matches.class);
+ final InstanceIdentifier<AceIpAndEthNodes> aceIpAndEthId = matchesId.child(AceIpAndEthNodes.class);
final InstanceIdentifier<SourcePortRange> srcPortId = matchesId.child((Class)SourcePortRange.class);
final InstanceIdentifier<DestinationPortRange> dstPortId = matchesId.child((Class)DestinationPortRange.class);
- registry.subtreeAddBefore(Sets.newHashSet(aceId, actionsId, matchesId, srcPortId, dstPortId),
+ registry.subtreeAddBefore(Sets.newHashSet(aceId, actionsId, matchesId, aceIpAndEthId, srcPortId, dstPortId),
new GenericListWriter<>(ACL_ID, new IetfAclWriter()),
Sets.newHashSet(IETF_ACL_ID, SUBIF_IETF_ACL_ID));
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AbstractIetfAclWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AbstractIetfAclWriter.java
index fff93eda4..331db10dc 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AbstractIetfAclWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AbstractIetfAclWriter.java
@@ -123,8 +123,8 @@ public abstract class AbstractIetfAclWriter implements IetfAclWriter, JvppReplyC
if (aclType == AclType.ETH) {
return true; // L2 only rules are possible for IP4 traffic
}
- if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType)
- .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv4) {
+ if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType).getAceIpAndEthNodes()
+ .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.ace.ip.version.AceIpv4) {
return true;
}
return false;
@@ -139,8 +139,8 @@ public abstract class AbstractIetfAclWriter implements IetfAclWriter, JvppReplyC
if (aclType == AclType.ETH) {
return true; // L2 only rules are possible for IP6 traffic
}
- if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType)
- .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv6) {
+ if (aclType == AclType.ETH_AND_IP && ((AceIpAndEth) aceType).getAceIpAndEthNodes()
+ .getAceIpVersion() instanceof org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.ace.ip.version.AceIpv6) {
return true;
}
return false;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriter.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriter.java
index 24457fee2..fcc657189 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriter.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriter.java
@@ -27,9 +27,10 @@ import javax.annotation.Nullable;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160708.access.lists.acl.access.list.entries.ace.actions.PacketHandling;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.InterfaceMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpAndEth;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.AceIpVersion;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv4;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.AceIpAndEthNodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.AceIpVersion;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.ace.ip.version.AceIpv4;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.ace.ip.version.AceIpv6;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -39,8 +40,8 @@ public final class AceIpAndEthWriter
private static final Logger LOG = LoggerFactory.getLogger(AceIpAndEthWriter.class);
private static int maskLength(@Nonnull final AceIpAndEth ace, final int vlanTags) {
- if (ace.getAceIpVersion() != null) {
- if (ace.getAceIpVersion() instanceof AceIpv4) {
+ if (ace.getAceIpAndEthNodes().getAceIpVersion() != null) {
+ if (ace.getAceIpAndEthNodes().getAceIpVersion() instanceof AceIpv4) {
return 48;
} else {
return vlanTags == 2
@@ -54,7 +55,8 @@ public final class AceIpAndEthWriter
@Override
public ClassifyAddDelTable createTable(@Nonnull final AceIpAndEth ace, @Nullable final InterfaceMode mode,
final int nextTableIndex, final int vlanTags) {
- final int numberOfSessions = PortPair.fromRange(ace.getSourcePortRange(), ace.getDestinationPortRange()).size();
+ final AceIpAndEthNodes nodes = ace.getAceIpAndEthNodes();
+ final int numberOfSessions = PortPair.fromRange(nodes.getSourcePortRange(), nodes.getDestinationPortRange()).size();
final ClassifyAddDelTable request = createTable(nextTableIndex, numberOfSessions);
final int maskLength = maskLength(ace, vlanTags);
request.mask = new byte[maskLength];
@@ -62,20 +64,20 @@ public final class AceIpAndEthWriter
request.matchNVectors = maskLength / 16;
boolean aceIsEmpty =
- destinationMacAddressMask(ace.getDestinationMacAddressMask(), ace.getDestinationMacAddress(), request);
- aceIsEmpty &= sourceMacAddressMask(ace.getSourceMacAddressMask(), ace.getSourceMacAddress(), request);
+ destinationMacAddressMask(nodes.getDestinationMacAddressMask(), nodes.getDestinationMacAddress(), request);
+ aceIsEmpty &= sourceMacAddressMask(nodes.getSourceMacAddressMask(), nodes.getSourceMacAddress(), request);
// if we use classifier API, we need to know ip version (fields common for ip4 and ip6 have different offsets):
- final AceIpVersion aceIpVersion = ace.getAceIpVersion();
+ final AceIpVersion aceIpVersion = nodes.getAceIpVersion();
checkArgument(aceIpVersion != null, "AceIpAndEth have to define IpVersion");
final int baseOffset = getVlanTagsLen(vlanTags);
if (aceIpVersion instanceof AceIpv4) {
final AceIpv4 ipVersion = (AceIpv4) aceIpVersion;
- aceIsEmpty &= ip4Mask(baseOffset, mode, ace, ipVersion, request);
+ aceIsEmpty &= ip4Mask(baseOffset, mode, nodes, ipVersion, request);
} else if (aceIpVersion instanceof AceIpv6) {
final AceIpv6 ipVersion = (AceIpv6) aceIpVersion;
- aceIsEmpty &= ip6Mask(baseOffset, mode, ace, ipVersion, request);
+ aceIsEmpty &= ip6Mask(baseOffset, mode, nodes, ipVersion, request);
} else {
throw new IllegalArgumentException(String.format("Unsupported IP version %s", aceIpVersion));
}
@@ -94,25 +96,26 @@ public final class AceIpAndEthWriter
@Nonnull final AceIpAndEth ace,
@Nullable final InterfaceMode mode, final int tableIndex,
final int vlanTags) {
- final List<PortPair> portPairs = PortPair.fromRange(ace.getSourcePortRange(), ace.getDestinationPortRange());
+ final AceIpAndEthNodes nodes = ace.getAceIpAndEthNodes();
+ final List<PortPair> portPairs = PortPair.fromRange(nodes.getSourcePortRange(), nodes.getDestinationPortRange());
final List<ClassifyAddDelSession> requests = new ArrayList<>(portPairs.size());
for (final PortPair pair : portPairs) {
final ClassifyAddDelSession request = createSession(action, tableIndex);
request.match = new byte[maskLength(ace, vlanTags)];
- boolean noMatch = destinationMacAddressMatch(ace.getDestinationMacAddress(), request);
- noMatch &= sourceMacAddressMatch(ace.getSourceMacAddress(), request);
+ boolean noMatch = destinationMacAddressMatch(nodes.getDestinationMacAddress(), request);
+ noMatch &= sourceMacAddressMatch(nodes.getSourceMacAddress(), request);
- final AceIpVersion aceIpVersion = ace.getAceIpVersion();
+ final AceIpVersion aceIpVersion = nodes.getAceIpVersion();
checkArgument(aceIpVersion != null, "AceIpAndEth have to define IpVersion");
final int baseOffset = getVlanTagsLen(vlanTags);
if (aceIpVersion instanceof AceIpv4) {
final AceIpv4 ipVersion = (AceIpv4) aceIpVersion;
- noMatch &= ip4Match(baseOffset, mode, ace, ipVersion, pair.getSrc(), pair.getDst(), request);
+ noMatch &= ip4Match(baseOffset, mode, nodes, ipVersion, pair.getSrc(), pair.getDst(), request);
} else if (aceIpVersion instanceof AceIpv6) {
final AceIpv6 ipVersion = (AceIpv6) aceIpVersion;
- noMatch &= ip6Match(baseOffset, mode, ace, ipVersion, pair.getSrc(), pair.getDst(), request);
+ noMatch &= ip6Match(baseOffset, mode, nodes, ipVersion, pair.getSrc(), pair.getDst(), request);
} else {
throw new IllegalArgumentException(String.format("Unsupported IP version %s", aceIpVersion));
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriterTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriterTest.java
index 2bbe3a573..4d155b2f3 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriterTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfaces/acl/common/AceIpAndEthWriterTest.java
@@ -34,7 +34,8 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.InterfaceMode;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpAndEth;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.AceIpAndEthBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.version.AceIpv4Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.AceIpAndEthNodesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.classfier.acl.rev161214.access.lists.acl.access.list.entries.ace.matches.ace.type.ace.ip.and.eth.ace.ip.and.eth.nodes.ace.ip.version.AceIpv4Builder;
public class AceIpAndEthWriterTest {
@@ -47,14 +48,14 @@ public class AceIpAndEthWriterTest {
initMocks(this);
writer = new AceIpAndEthWriter();
action = new DenyBuilder().setDeny(true).build();
- ace = new AceIpAndEthBuilder()
+ ace = new AceIpAndEthBuilder().setAceIpAndEthNodes(new AceIpAndEthNodesBuilder()
.setDestinationMacAddress(new MacAddress("11:22:33:44:55:66"))
.setSourceMacAddress(new MacAddress("aa:bb:cc:dd:ee:ff"))
.setAceIpVersion(new AceIpv4Builder()
.setSourceIpv4Network(new Ipv4Prefix("1.2.3.4/32")).build())
.setSourcePortRange(new SourcePortRangeBuilder().setLowerPort(new PortNumber(0x1111)).build())
.setDestinationPortRange(new DestinationPortRangeBuilder().setLowerPort(new PortNumber(0x2222)).build())
- .build();
+ .build()).build();
}
@Test