HONEYCOMB-146 : Unable to create adjacencies in Lisp 09/2609/2
authorJan Srnicek <jsrnicek@cisco.com>
Fri, 2 Sep 2016 11:40:53 +0000 (13:40 +0200)
committerMaros Marsalek <mmarsale@cisco.com>
Mon, 5 Sep 2016 11:38:47 +0000 (11:38 +0000)
Fixed setting of prefix lenghts for Eid's
Change-Id: I78dd4672f8b3227cc09c4d01abce537a67b8913a
Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/read/LocalMappingCustomizer.java
lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/util/EidConverter.java
lisp/lisp2vpp/src/main/java/io/fd/honeycomb/lisp/translate/write/AdjacencyCustomizer.java

index 0381df0..8762066 100755 (executable)
@@ -139,7 +139,8 @@ public class LocalMappingCustomizer
                             RWUtils.singleItemCollector());
 
             //in case of local mappings,locator_set_index stands for interface index
-            checkState(locatorSetContext.containsName(details.locatorSetIndex, ctx.getMappingContext()));
+            checkState(locatorSetContext.containsName(details.locatorSetIndex, ctx.getMappingContext()),
+                    "No Locator Set name found for index %s", details.locatorSetIndex);
             builder.setLocatorSet(locatorSetContext.getName(details.locatorSetIndex, ctx.getMappingContext()));
             builder.setKey(new LocalMappingKey(new MappingId(id.firstKeyOf(LocalMapping.class).getId())));
             builder.setEid(getArrayAsEidLocal(valueOf(details.eidType), details.eid));
index 4c8fa69..39d0fe7 100755 (executable)
@@ -50,6 +50,14 @@ public final class EidConverter {
         throw new UnsupportedOperationException("Cannot instantiate utility class " + EidConverter.class.getName());
     }
 
+    public static byte getPrefixLength(LocalEid address) {
+        return resolverPrefixLength(address.getAddress());
+    }
+
+    public static byte getPrefixLength(RemoteEid address) {
+        return resolverPrefixLength(address.getAddress());
+    }
+
     public static byte getPrefixLength(
             org.opendaylight.yang.gen.v1.urn.honeycomb.params.xml.ns.yang.eid.mapping.context.rev160801.contexts.eid.mapping.context.mappings.mapping.Eid address) {
         return resolverPrefixLength(address.getAddress());
index d321510..3eedf29 100755 (executable)
@@ -20,6 +20,7 @@ package io.fd.honeycomb.lisp.translate.write;
 import static com.google.common.base.Preconditions.checkArgument;
 import static com.google.common.base.Preconditions.checkState;
 import static io.fd.honeycomb.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType;
+import static io.fd.honeycomb.lisp.translate.util.EidConverter.*;
 
 import io.fd.honeycomb.lisp.translate.util.EidConverter;
 import io.fd.honeycomb.translate.spi.write.ListWriterCustomizer;
@@ -80,8 +81,8 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWri
         checkState(id.firstKeyOf(VniTable.class) != null, "Unable to find parent VNI for {}", id);
         final int vni = id.firstKeyOf(VniTable.class).getVirtualNetworkIdentifier().intValue();
 
-        EidType localEidType = EidConverter.getEidType(data.getLocalEid());
-        EidType remoteEidType = EidConverter.getEidType(data.getRemoteEid());
+        EidType localEidType = getEidType(data.getLocalEid());
+        EidType remoteEidType = getEidType(data.getRemoteEid());
 
         checkArgument(localEidType ==
                 remoteEidType, "Local[%s] and Remote[%s] eid types must be the same", localEidType, remoteEidType);
@@ -89,10 +90,10 @@ public class AdjacencyCustomizer extends FutureJVppCustomizer implements ListWri
         LispAddDelAdjacency request = new LispAddDelAdjacency();
 
         request.isAdd = TranslateUtils.booleanToByte(add);
-        request.seid = EidConverter.getEidAsByteArray(data.getLocalEid());
-        request.seidLen = (byte) request.seid.length;
-        request.deid = EidConverter.getEidAsByteArray(data.getRemoteEid());
-        request.seidLen = (byte) request.deid.length;
+        request.seid = getEidAsByteArray(data.getLocalEid());
+        request.seidLen = getPrefixLength(data.getLocalEid());
+        request.deid = getEidAsByteArray(data.getRemoteEid());
+        request.deidLen = getPrefixLength(data.getRemoteEid());
         request.eidType = (byte) localEidType.getValue();
         request.vni = vni;