summaryrefslogtreecommitdiffstats
path: root/nsh
diff options
context:
space:
mode:
Diffstat (limited to 'nsh')
-rw-r--r--nsh/api/src/main/yang/vpp-nsh.yang5
-rwxr-xr-xnsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/config/NshMapWriterCustomizer.java37
-rwxr-xr-xnsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/oper/NshMapReaderCustomizer.java58
3 files changed, 58 insertions, 42 deletions
diff --git a/nsh/api/src/main/yang/vpp-nsh.yang b/nsh/api/src/main/yang/vpp-nsh.yang
index 2efdbcf6b..14ea06d6f 100644
--- a/nsh/api/src/main/yang/vpp-nsh.yang
+++ b/nsh/api/src/main/yang/vpp-nsh.yang
@@ -115,6 +115,11 @@ module vpp-nsh {
description "ipv6 vxlan encap type";
}
+ identity none {
+ base "encap-type";
+ description "encap-none";
+ }
+
typedef nsh-encap-type {
type identityref {
base "encap-type";
diff --git a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/config/NshMapWriterCustomizer.java b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/config/NshMapWriterCustomizer.java
index 8b77ad66b..486655cd3 100755
--- a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/config/NshMapWriterCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/config/NshMapWriterCustomizer.java
@@ -38,6 +38,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.VxlanGpe;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.Vxlan4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.Vxlan6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.None;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMapKey;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -48,15 +49,15 @@ import org.slf4j.LoggerFactory;
* Writer customizer responsible for NshMap create/delete.
*/
public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
- implements ListWriterCustomizer<NshMap, NshMapKey>, ByteDataTranslator, JvppReplyConsumer {
+implements ListWriterCustomizer<NshMap, NshMapKey>, ByteDataTranslator, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshMapWriterCustomizer.class);
private final NamingContext nshMapContext;
private final NamingContext interfaceContext;
public NshMapWriterCustomizer(@Nonnull final FutureJVppNsh futureJVppNsh,
- @Nonnull final NamingContext nshMapContext,
- @Nonnull final NamingContext interfaceContext) {
+ @Nonnull final NamingContext nshMapContext,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppNsh);
this.nshMapContext = checkNotNull(nshMapContext, "nshMapContext should not be null");
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
@@ -64,8 +65,8 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
@Override
public void writeCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMap dataAfter, @Nonnull final WriteContext writeContext)
- throws WriteFailedException {
+ @Nonnull final NshMap dataAfter, @Nonnull final WriteContext writeContext)
+ throws WriteFailedException {
LOG.debug("Creating nsh map: iid={} dataAfter={}", id, dataAfter);
final int newMapIndex =
nshAddDelMap(true, id, dataAfter, ~0 /* value not present */, writeContext.getMappingContext());
@@ -77,15 +78,15 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
@Override
public void updateCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMap dataBefore, @Nonnull final NshMap dataAfter,
- @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ @Nonnull final NshMap dataBefore, @Nonnull final NshMap dataAfter,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
throw new UnsupportedOperationException("Nsh map update is not supported");
}
@Override
public void deleteCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMap dataBefore,
- @Nonnull final WriteContext writeContext) throws WriteFailedException {
+ @Nonnull final NshMap dataBefore,
+ @Nonnull final WriteContext writeContext) throws WriteFailedException {
LOG.debug("Removing nsh map: iid={} dataBefore={}", id, dataBefore);
final String mapName = dataBefore.getName();
checkState(nshMapContext.containsIndex(mapName, writeContext.getMappingContext()),
@@ -100,8 +101,8 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
}
private int nshAddDelMap(final boolean isAdd, @Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMap map, final int mapId, final MappingContext ctx)
- throws WriteFailedException {
+ @Nonnull final NshMap map, final int mapId, final MappingContext ctx)
+ throws WriteFailedException {
final CompletionStage<NshAddDelMapReply> createNshMapReplyCompletionStage =
getFutureJVppNsh().nshAddDelMap(getNshAddDelMapRequest(isAdd, mapId, map, ctx));
@@ -111,8 +112,8 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
}
private NshAddDelMap getNshAddDelMapRequest(final boolean isAdd, final int mapIndex,
- @Nonnull final NshMap map,
- @Nonnull final MappingContext ctx) {
+ @Nonnull final NshMap map,
+ @Nonnull final MappingContext ctx) {
final NshAddDelMap request = new NshAddDelMap();
request.isAdd = booleanToByte(isAdd);
@@ -133,11 +134,15 @@ public class NshMapWriterCustomizer extends FutureJVppNshCustomizer
request.nextNode = 3;
} else if (map.getEncapType() == Vxlan6.class) {
request.nextNode = 4;
+ } else if (map.getEncapType() == None.class) {
+ request.nextNode = 5;
}
- checkState(interfaceContext.containsIndex(map.getEncapIfName(), ctx),
- "Mapping does not contains mapping for provider interface Name ".concat(map.getEncapIfName()));
- request.swIfIndex = interfaceContext.getIndex(map.getEncapIfName(), ctx);
+ if (map.getEncapType() != None.class) {
+ checkState(interfaceContext.containsIndex(map.getEncapIfName(), ctx),
+ "Mapping does not contains mapping for provider interface Name ".concat(map.getEncapIfName()));
+ request.swIfIndex = interfaceContext.getIndex(map.getEncapIfName(), ctx);
+ }
return request;
}
diff --git a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/oper/NshMapReaderCustomizer.java b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/oper/NshMapReaderCustomizer.java
index 6e0406ff6..d06d1505f 100755
--- a/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/oper/NshMapReaderCustomizer.java
+++ b/nsh/impl/src/main/java/io/fd/hc2vpp/vppnsh/impl/oper/NshMapReaderCustomizer.java
@@ -43,6 +43,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.VxlanGpe;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.Vxlan4;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.Vxlan6;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.None;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.state.NshMapsBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.state.nsh.maps.NshMap;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.state.nsh.maps.NshMapBuilder;
@@ -57,15 +58,15 @@ import org.slf4j.LoggerFactory;
* Reader customizer responsible for nsh map read.<br> to VPP.
*/
public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
- implements InitializingListReaderCustomizer<NshMap, NshMapKey, NshMapBuilder>, JvppReplyConsumer {
+implements InitializingListReaderCustomizer<NshMap, NshMapKey, NshMapBuilder>, JvppReplyConsumer {
private static final Logger LOG = LoggerFactory.getLogger(NshMapReaderCustomizer.class);
private final NamingContext nshMapContext;
private final NamingContext interfaceContext;
public NshMapReaderCustomizer(@Nonnull final FutureJVppNsh futureJVppNsh,
- @Nonnull final NamingContext nshMapContext,
- @Nonnull final NamingContext interfaceContext) {
+ @Nonnull final NamingContext nshMapContext,
+ @Nonnull final NamingContext interfaceContext) {
super(futureJVppNsh);
this.nshMapContext = checkNotNull(nshMapContext, "nshMapContext should not be null");
this.interfaceContext = checkNotNull(interfaceContext, "interfaceContext should not be null");
@@ -74,7 +75,7 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
@Override
public void merge(@Nonnull final Builder<? extends DataObject> builder,
- @Nonnull final List<NshMap> readData) {
+ @Nonnull final List<NshMap> readData) {
((NshMapsBuilder) builder).setNshMap(readData);
}
@@ -86,8 +87,8 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
@Override
public void readCurrentAttributes(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final NshMapBuilder builder, @Nonnull final ReadContext ctx)
- throws ReadFailedException {
+ @Nonnull final NshMapBuilder builder, @Nonnull final ReadContext ctx)
+ throws ReadFailedException {
LOG.debug("Reading attributes for nsh map: {}", id);
final NshMapKey key = id.firstKeyOf(NshMap.class);
checkArgument(key != null, "could not find NshMap key in {}", id);
@@ -135,27 +136,32 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
default:
LOG.trace("Unsupported nsh_action for nsh map: {}", nshMapDetails.nshAction);
return;
- }
+ }
switch (nshMapDetails.nextNode) {
- case 2:
- builder.setEncapType(VxlanGpe.class);
- break;
- case 3:
- builder.setEncapType(Vxlan4.class);
- break;
- case 4:
- builder.setEncapType(Vxlan6.class);
- break;
- default:
- LOG.trace("Unsupported encap type for nsh map: {}", nshMapDetails.nextNode);
- return;
+ case 2:
+ builder.setEncapType(VxlanGpe.class);
+ break;
+ case 3:
+ builder.setEncapType(Vxlan4.class);
+ break;
+ case 4:
+ builder.setEncapType(Vxlan6.class);
+ break;
+ case 5:
+ builder.setEncapType(None.class);
+ break;
+ default:
+ LOG.trace("Unsupported encap type for nsh map: {}", nshMapDetails.nextNode);
+ return;
}
- checkState(interfaceContext.containsName(nshMapDetails.swIfIndex, ctx.getMappingContext()),
- "Mapping does not contains mapping for provider interface Index ");
- final String interfaceName = interfaceContext.getName(nshMapDetails.swIfIndex, ctx.getMappingContext());
- builder.setEncapIfName(interfaceName);
+ if (nshMapDetails.nextNode != 5) {
+ checkState(interfaceContext.containsName(nshMapDetails.swIfIndex, ctx.getMappingContext()),
+ "Mapping does not contains mapping for provider interface Index ");
+ final String interfaceName = interfaceContext.getName(nshMapDetails.swIfIndex, ctx.getMappingContext());
+ builder.setEncapIfName(interfaceName);
+ }
if (LOG.isTraceEnabled()) {
LOG.trace("Attributes for nsh map {} successfully read: {}", id, builder.build());
@@ -165,7 +171,7 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
@Nonnull
@Override
public List<NshMapKey> getAllIds(@Nonnull final InstanceIdentifier<NshMap> id,
- @Nonnull final ReadContext context) throws ReadFailedException {
+ @Nonnull final ReadContext context) throws ReadFailedException {
LOG.debug("Reading list of keys for nsh map: {}", id);
final NshMapDump request = new NshMapDump();
@@ -206,8 +212,8 @@ public class NshMapReaderCustomizer extends FutureJVppNshCustomizer
return Initialized.create(
InstanceIdentifier.create(VppNsh.class).child(
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.NshMaps.class).child(
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMap.class,
- new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMapKey(id.firstKeyOf(NshMap.class).getName())),
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMap.class,
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMapKey(id.firstKeyOf(NshMap.class).getName())),
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpp.nsh.rev161214.vpp.nsh.nsh.maps.NshMapBuilder(readValue).setName(readValue.getName()).build());
}
}