summaryrefslogtreecommitdiffstats
path: root/nsh
diff options
context:
space:
mode:
Diffstat (limited to 'nsh')
-rw-r--r--nsh/api/src/main/yang/vpp-nsh.yang31
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java11
-rwxr-xr-xnsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java18
-rw-r--r--nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizerTest.java5
-rw-r--r--nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java5
5 files changed, 70 insertions, 0 deletions
diff --git a/nsh/api/src/main/yang/vpp-nsh.yang b/nsh/api/src/main/yang/vpp-nsh.yang
index 47565ce49..a3313bad4 100644
--- a/nsh/api/src/main/yang/vpp-nsh.yang
+++ b/nsh/api/src/main/yang/vpp-nsh.yang
@@ -60,6 +60,34 @@ module vpp-nsh {
}
/*
+ * Defines the supported nsh header action.
+ */
+ identity action-type {
+ description "nsh header action type";
+ }
+
+ identity swap {
+ base "action-type";
+ description "swap action type";
+ }
+
+ identity push {
+ base "action-type";
+ description "push action type";
+ }
+
+ identity pop {
+ base "action-type";
+ description "pop action type";
+ }
+
+ typedef nsh-action-type {
+ type identityref {
+ base "action-type";
+ }
+ }
+
+ /*
* Defines the supported encap type.
*/
identity encap-type {
@@ -180,6 +208,9 @@ module vpp-nsh {
range "1..255";
}
}
+ leaf nsh-action {
+ type nsh-action-type;
+ }
leaf encap-type {
type nsh-encap-type;
}
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
index 7ca208110..c272e0e34 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizer.java
@@ -33,6 +33,9 @@ import io.fd.vpp.jvpp.nsh.future.FutureJVppNsh;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Swap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Push;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Pop;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.maps.NshMapKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -114,6 +117,14 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
request.nspNsi = (map.getNsp().intValue() << 8) | map.getNsi();
request.mappedNspNsi = (map.getMappedNsp().intValue() << 8) | map.getMappedNsi();
+ if (map.getNshAction() == Swap.class) {
+ request.nshAction = 0;
+ } else if (map.getNshAction() == Push.class) {
+ request.nshAction = 1;
+ } else if (map.getNshAction() == Pop.class) {
+ request.nshAction = 2;
+ }
+
if (map.getEncapType() == VxlanGpe.class) {
request.nextNode = 2;
}
diff --git a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
index 47c408d2c..8e9b7793b 100755
--- a/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizer.java
@@ -36,6 +36,9 @@ import java.util.List;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Swap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Push;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Pop;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMapsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.nsh.maps.NshMapBuilder;
@@ -115,6 +118,21 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
builder.setMappedNsp((long) ((nshMapDetails.mappedNspNsi >> 8) & 0xFFFFFF));
builder.setMappedNsi((short) (nshMapDetails.mappedNspNsi & 0xFF));
+ switch (nshMapDetails.nshAction) {
+ case 0:
+ builder.setNshAction(Swap.class);
+ break;
+ case 1:
+ builder.setNshAction(Push.class);
+ break;
+ case 2:
+ builder.setNshAction(Pop.class);
+ break;
+ default:
+ LOG.trace("Unsupported nsh_action for nsh map: {}", nshMapDetails.nshAction);
+ return;
+ }
+
switch (nshMapDetails.nextNode) {
case 2:
builder.setEncapType(VxlanGpe.class);
diff --git a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizerTest.java b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizerTest.java
index e15e9c6e8..30f4c488c 100644
--- a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizerTest.java
+++ b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/config/NshMapWriterCustomizerTest.java
@@ -33,6 +33,9 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import io.fd.honeycomb.translate.MappingContext;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Swap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Push;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Pop;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.NshMaps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.NshMapsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.nsh.maps.NshMap;
@@ -81,6 +84,7 @@ public class NshMapWriterCustomizerTest extends WriterCustomizerTest {
builder.setNsi((short) 255);
builder.setMappedNsp(183L);
builder.setMappedNsi((short) 254);
+ builder.setNshAction(Swap.class);
builder.setEncapType(VxlanGpe.class);
builder.setEncapIfName("vxlanGpeTun3");
@@ -107,6 +111,7 @@ public class NshMapWriterCustomizerTest extends WriterCustomizerTest {
request.isAdd = isAdd;
request.nspNsi = 184<<8 | 255;
request.mappedNspNsi = 183<<8 | 254;
+ request.nshAction = 0;
request.swIfIndex = ITF_INDEX;
request.nextNode = 2;
diff --git a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java
index 67db740aa..8e2add961 100644
--- a/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java
+++ b/nsh/impl/src/test/java/io/fd/honeycomb/vppnsh/impl/oper/NshMapReaderCustomizerTest.java
@@ -37,6 +37,9 @@ import org.mockito.Mock;
import io.fd.honeycomb.translate.vpp.util.NamingContext;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VxlanGpe;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Swap;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Push;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.Pop;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshState;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.VppNshStateBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev160624.vpp.nsh.state.NshMaps;
@@ -104,6 +107,7 @@ public class NshMapReaderCustomizerTest extends
final NshMapDetails nshMapDetails = new NshMapDetails();
nshMapDetails.nspNsi = (184<<8 | 255);
nshMapDetails.mappedNspNsi = (183<<8 | 254);
+ nshMapDetails.nshAction = 0;
nshMapDetails.swIfIndex = ITF_INDEX;
nshMapDetails.nextNode = 2;
reply.nshMapDetails = Lists.newArrayList(nshMapDetails);
@@ -120,6 +124,7 @@ public class NshMapReaderCustomizerTest extends
assertEquals(255, builder.getNsi().intValue());
assertEquals(183, builder.getMappedNsp().intValue());
assertEquals(254, builder.getMappedNsi().intValue());
+ assertEquals(Swap.class, builder.getNshAction());
assertEquals(VxlanGpe.class, builder.getEncapType());
assertEquals("vxlanGpeTun3", builder.getEncapIfName());