summaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJan Srnicek <jsrnicek@cisco.com>2017-03-23 14:11:54 +0100
committerJan Srnicek <jsrnicek@cisco.com>2017-03-23 14:11:54 +0100
commit66f5caa2704503335cbce2a42bad3d99bd205f88 (patch)
treea80557d67b0a2deb3a71aeefdd680b7866cc5eae /lisp
parentd474f0648427615a70c81f40d4bfdd2ec8c76b74 (diff)
HC2VPP-58 - Reduced unnecessary dump
By internal behaviour change in vpp, its now to possible to distinguish between negative/positive mapping Change-Id: I13981bdc2d5fc6d660874587679aaf076f0c6a86 Signed-off-by: Jan Srnicek <jsrnicek@cisco.com>
Diffstat (limited to 'lisp')
-rwxr-xr-xlisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java36
-rw-r--r--lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java8
2 files changed, 16 insertions, 28 deletions
diff --git a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
index 8341f4071..a81b37d65 100755
--- a/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
+++ b/lisp/lisp2vpp/src/main/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizer.java
@@ -16,6 +16,12 @@
package io.fd.hc2vpp.lisp.translate.read;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.valueOf;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
+import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
+
import com.google.common.base.Optional;
import com.google.common.collect.ImmutableSet;
import io.fd.hc2vpp.common.translate.util.AddressTranslator;
@@ -45,6 +51,10 @@ import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.LispLocatorDetails;
import io.fd.vpp.jvpp.core.dto.LispLocatorDetailsReplyDump;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapReplyAction;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MappingId;
@@ -72,18 +82,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.annotation.Nonnull;
-import java.util.Collections;
-import java.util.List;
-import java.util.stream.Collectors;
-
-import static com.google.common.base.Preconditions.checkNotNull;
-import static com.google.common.base.Preconditions.checkState;
-import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.EidType.valueOf;
-import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.FilterType;
-import static io.fd.hc2vpp.lisp.translate.read.dump.executor.params.MappingsDumpParams.MappingsDumpParamsBuilder;
-import static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.lisp.rev170315.MapReplyAction.NoAction;
-
/**
* Customizer for reading {@code RemoteMapping}<br>
*/
@@ -236,13 +234,9 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
final ModificationCache cache,
final MappingContext mappingContext) throws ReadFailedException {
- if (details.action != 0) {
- // in this case ,negative action was defined
+ if (details.locatorSetIndex == -1) {
bindNegativeMapping(builder, MapReplyAction.forValue(details.action));
} else {
- // in this case, there is no clear determination whether negative action with NO_ACTION(value == 0) was defined,
- // or if its default value and remote locators, are defined, so only chance to determine so, is to dump locators for this mapping
-
// cache key needs to have locator set scope to not mix with cached data
final Optional<LispLocatorDetailsReplyDump> reply;
@@ -260,13 +254,7 @@ public class RemoteMappingCustomizer extends FutureJVppCustomizer
e.getCause()));
}
- if (!reply.isPresent() || reply.get().lispLocatorDetails.isEmpty()) {
- // no remote locators exist, therefore there was NO_ACTION defined
- bindNegativeMapping(builder, NoAction);
- } else {
- // bind remote locators
- bindPositiveMapping(builder, reply.get());
- }
+ bindPositiveMapping(builder, reply.or(new LispLocatorDetailsReplyDump()));
}
}
diff --git a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java
index a3b344584..e00ab5095 100644
--- a/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java
+++ b/lisp/lisp2vpp/src/test/java/io/fd/hc2vpp/lisp/translate/read/RemoteMappingCustomizerTest.java
@@ -23,12 +23,12 @@ import static org.mockito.Matchers.any;
import static org.mockito.Mockito.when;
import com.google.common.collect.ImmutableList;
+import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.hc2vpp.lisp.context.util.EidMappingContext;
import io.fd.hc2vpp.lisp.translate.util.EidTranslator;
import io.fd.honeycomb.translate.MappingContext;
import io.fd.honeycomb.translate.spi.read.ReaderCustomizer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
-import io.fd.hc2vpp.common.test.read.ListReaderCustomizerTest;
import io.fd.vpp.jvpp.core.dto.LispEidTableDetails;
import io.fd.vpp.jvpp.core.dto.LispEidTableDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.LispLocatorDetails;
@@ -97,7 +97,7 @@ public class RemoteMappingCustomizerTest
detail.eid = new byte[]{-64, -88, 2, 1};
detail.eidPrefixLen = 32;
detail.isLocal = 0;
- detail.locatorSetIndex = 1;
+ detail.locatorSetIndex = -1;
detail.ttl = 7;
detail.vni = 12;
@@ -119,7 +119,7 @@ public class RemoteMappingCustomizerTest
detail.eid = new byte[]{-64, -88, 2, 1};
detail.eidPrefixLen = 32;
detail.isLocal = 0;
- detail.locatorSetIndex = 1;
+ detail.locatorSetIndex = -1 ;
detail.ttl = 7;
detail.vni = 12;