summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
Diffstat (limited to 'v3po')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizer.java12
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java34
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizer.java2
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizer.java6
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizerTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizerTest.java2
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizerTest.java3
7 files changed, 46 insertions, 15 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizer.java
index 70bc0c62b..fe04e5d80 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizer.java
@@ -16,6 +16,9 @@
package io.fd.hc2vpp.v3po.interfacesstate;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.v3po.DisabledInterfacesManager;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.ModificationCache;
@@ -23,9 +26,6 @@ import io.fd.honeycomb.translate.read.ReadContext;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.spi.read.Initialized;
import io.fd.honeycomb.translate.spi.read.InitializingListReaderCustomizer;
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDump;
@@ -86,10 +86,6 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
: (Map<Integer, SwInterfaceDetails>) ctx.get(DUMPED_IFCS_CONTEXT_KEY);
}
- private static boolean isRegularInterface(final SwInterfaceDetails iface) {
- return iface.subId == 0;
- }
-
@Nonnull
@Override
public InterfaceBuilder getBuilder(@Nonnull InstanceIdentifier<Interface> id) {
@@ -183,7 +179,7 @@ public class InterfaceCustomizer extends FutureJVppCustomizer
return elt;
})
// filter out sub-interfaces
- .filter(InterfaceCustomizer::isRegularInterface)
+ .filter(InterfaceDataTranslator.INSTANCE::isRegularInterface)
.map(elt -> elt.swIfIndex)
.collect(Collectors.toSet());
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
index cbffdd37c..f951d8fc2 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceDataTranslator.java
@@ -19,11 +19,11 @@ package io.fd.hc2vpp.v3po.interfacesstate;
import static com.google.common.base.Preconditions.checkArgument;
import static java.util.Objects.requireNonNull;
+import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.honeycomb.translate.ModificationCache;
import io.fd.honeycomb.translate.read.ReadFailedException;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.hc2vpp.common.translate.util.ByteDataTranslator;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDump;
@@ -50,6 +50,9 @@ import org.slf4j.Logger;
public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyConsumer {
+ InterfaceDataTranslator INSTANCE = new InterfaceDataTranslator() {
+ };
+
Gauge64 vppLinkSpeed0 = new Gauge64(BigInteger.ZERO);
Gauge64 vppLinkSpeed1 = new Gauge64(BigInteger.valueOf(10L * 1000000));
Gauge64 vppLinkSpeed2 = new Gauge64(BigInteger.valueOf(100L * 1000000));
@@ -259,4 +262,31 @@ public interface InterfaceDataTranslator extends ByteDataTranslator, JvppReplyCo
final SwInterfaceDetails cachedDetails) {
return ifcType.equals(getInterfaceType(toString(cachedDetails.interfaceName)));
}
+
+ /**
+ * Checks whether provided {@link SwInterfaceDetails} is detail of sub-interface<br>
+ * <li>subId == unique number of sub-interface within set of sub-interfaces of single interface
+ * <li>swIfIndex == unique index of interface/sub-interface within all interfaces
+ * <li>supSwIfIndex == unique index of parent interface
+ * <li>in case of interface , swIfIndex value equals supSwIfIndex
+ * <li>in case of subinterface, supSwIfIndex equals index of parent interface,
+ * swIfIndex is index of subinterface itselt
+ */
+ default boolean isSubInterface(@Nonnull final SwInterfaceDetails elt) {
+ //cant check by subId != 0, because you can pick 0 as value
+ return elt.supSwIfIndex != elt.swIfIndex;
+ }
+
+ /**
+ * Checks whether provided {@link SwInterfaceDetails} is detail of interface<br>
+ * <li>subId == unique number of subinterface within set of subinterfaces of single interface
+ * <li>swIfIndex == unique index of interface/subinterface within all interfaces
+ * <li>supSwIfIndex == unique index of parent interface
+ * <li>in case of interface , swIfIndex value equals supSwIfIndex
+ * <li>in case of subinterface, supSwIfIndex equals index of parent interface,
+ * swIfIndex is index of subinterface itselt
+ */
+ default boolean isRegularInterface(@Nonnull final SwInterfaceDetails elt) {
+ return !isSubInterface(elt);
+ }
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizer.java
index 3fd0445fb..bdb31d44a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizer.java
@@ -93,7 +93,7 @@ public class RewriteCustomizer extends FutureJVppCustomizer
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache(), LOG);
LOG.debug("VPP sub-interface details: {}", iface);
- checkState(iface.subId != 0, "Interface returned by the VPP is not a sub-interface");
+ checkState(isSubInterface(iface), "Interface returned by the VPP is not a sub-interface");
final TagRewriteOperation operation = TagRewriteOperation.get(iface.vtrOp);
if (TagRewriteOperation.disabled == operation) {
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizer.java
index 41a3c704b..0bed15683 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizer.java
@@ -144,7 +144,7 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
final List<SubInterfaceKey> interfacesKeys = ifaces.swInterfaceDetails.stream()
.filter(elt -> elt != null)
// accept only sub-interfaces for current iface:
- .filter(elt -> elt.subId != 0 && elt.supSwIfIndex == ifaceId)
+ .filter(elt -> isSubInterface(elt) && elt.supSwIfIndex == ifaceId)
.map(details -> new SubInterfaceKey(new Long(details.subId)))
.collect(Collectors.toList());
@@ -175,9 +175,9 @@ public class SubInterfaceCustomizer extends FutureJVppCustomizer
interfaceContext.getIndex(subInterfaceName, ctx.getMappingContext()), ctx.getModificationCache(), LOG);
LOG.debug("VPP sub-interface details: {}", iface);
- checkState(iface.subId != 0, "Interface returned by the VPP is not a sub-interface");
+ checkState(isSubInterface(iface), "Interface returned by the VPP is not a sub-interface");
- builder.setIdentifier(Long.valueOf(iface.subId));
+ builder.setIdentifier((long) iface.subId);
builder.setKey(new SubInterfaceKey(builder.getIdentifier()));
// sub-interface-base-attributes:
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizerTest.java
index 295805114..2f8a30b84 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/InterfaceCustomizerTest.java
@@ -155,9 +155,11 @@ public class InterfaceCustomizerTest extends ListReaderCustomizerTest<Interface,
final SwInterfaceDetails swIf0 = new SwInterfaceDetails();
swIf0.swIfIndex = 0;
+ swIf0.supSwIfIndex = 0;
swIf0.interfaceName = IFACE0_NAME.getBytes();
final SwInterfaceDetails swIf1 = new SwInterfaceDetails();
swIf1.swIfIndex = 1;
+ swIf1.supSwIfIndex = 1;
swIf1.interfaceName = IFACE1_NAME.getBytes();
final SwInterfaceDetails swSubIf1 = new SwInterfaceDetails();
swSubIf1.swIfIndex = 2;
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizerTest.java
index 0ae22b505..c9f9320be 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/RewriteCustomizerTest.java
@@ -97,6 +97,8 @@ public class RewriteCustomizerTest extends ReaderCustomizerTest<Rewrite, Rewrite
ifaceDetails.vtrTag1 = 123;
ifaceDetails.vtrTag2 = 321;
ifaceDetails.vtrPushDot1Q = 1;
+ ifaceDetails.swIfIndex= VLAN_IF_INDEX;
+ ifaceDetails.supSwIfIndex = 2;
cachedInterfaceDump.put(VLAN_IF_INDEX, ifaceDetails);
cache.put(InterfaceCustomizer.DUMPED_IFCS_CONTEXT_KEY, cachedInterfaceDump);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizerTest.java
index 94f6db43c..5065d4a25 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/SubInterfaceCustomizerTest.java
@@ -87,7 +87,8 @@ public class SubInterfaceCustomizerTest extends ListReaderCustomizerTest<SubInte
final SwInterfaceDetails ifaceDetails = new SwInterfaceDetails();
ifaceDetails.subId = VLAN_IF_ID;
ifaceDetails.interfaceName = VLAN_IF_NAME.getBytes();
- ifaceDetails.subDot1Ad = 1;
+ ifaceDetails.swIfIndex = 2;
+ ifaceDetails.supSwIfIndex = SUPER_IF_INDEX;
defineMapping(mappingContext, SUPER_IF_NAME, SUPER_IF_INDEX, IFC_CTX_NAME);
defineMapping(mappingContext, VLAN_IF_NAME, VLAN_IF_INDEX, IFC_CTX_NAME);
ifaceDetails.subNumberOfTags = 2;