summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
Diffstat (limited to 'v3po')
-rw-r--r--v3po/api/src/main/yang/v3po.yang13
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizer.java14
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizer.java5
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizer.java16
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java13
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java1
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizerTest.java1
7 files changed, 56 insertions, 7 deletions
diff --git a/v3po/api/src/main/yang/v3po.yang b/v3po/api/src/main/yang/v3po.yang
index d1af6114c..828a095b0 100644
--- a/v3po/api/src/main/yang/v3po.yang
+++ b/v3po/api/src/main/yang/v3po.yang
@@ -257,12 +257,24 @@ module v3po {
}
}
+ grouping interface-tag {
+ leaf tag {
+ type string {
+ length 1..63;
+ }
+ description
+ "ASCII string placeholder for interface metadata. Value is stored in vpp,
+ and returned in read requests. No processing involved.";
+ }
+ }
+
grouping tap-interface-base-attributes {
leaf tap-name {
type string{
pattern "[a-zA-Z0-9\-;.+@$#^&*!_()=\[\]]*";
}
}
+ uses interface-tag;
}
grouping tap-interface-config-attributes {
@@ -335,6 +347,7 @@ module v3po {
type vhost-user-role;
default "server";
}
+ uses interface-tag;
description "vhost-user settings";
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizer.java
index 220fb95e8..a22a0d429 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/TapCustomizer.java
@@ -29,6 +29,7 @@ import io.fd.vpp.jvpp.core.dto.TapDeleteReply;
import io.fd.vpp.jvpp.core.dto.TapModify;
import io.fd.vpp.jvpp.core.dto.TapModifyReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
@@ -98,7 +99,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen
final WriteContext writeContext) throws WriteFailedException {
LOG.debug("Setting tap interface: {}. Tap: {}", swIfName, tap);
final CompletionStage<TapConnectReply> tapConnectFuture = getFutureJVpp()
- .tapConnect(getTapConnectRequest(tap.getTapName(), tap.getMac(), tap.getDeviceInstance()));
+ .tapConnect(getTapConnectRequest(tap));
final TapConnectReply reply = getReplyForCreate(tapConnectFuture.toCompletableFuture(), id, tap);
LOG.debug("Tap set successfully for: {}, tap: {}", swIfName, tap);
// Add new interface to our interface context
@@ -128,10 +129,11 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen
interfaceContext.removeName(swIfName, writeContext.getMappingContext());
}
- private TapConnect getTapConnectRequest(final String tapName, final PhysAddress mac, final Long deviceInstance) {
+ private TapConnect getTapConnectRequest(final Tap tap) {
final TapConnect tapConnect = new TapConnect();
- tapConnect.tapName = tapName.getBytes();
+ tapConnect.tapName = tap.getTapName().getBytes();
+ final PhysAddress mac = tap.getMac();
if (mac == null) {
tapConnect.useRandomMac = 1;
tapConnect.macAddress = new byte[6];
@@ -140,6 +142,7 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen
tapConnect.macAddress = parseMac(mac.getValue());
}
+ final Long deviceInstance = tap.getDeviceInstance();
if (deviceInstance == null) {
tapConnect.renumber = 0;
} else {
@@ -147,6 +150,11 @@ public class TapCustomizer extends AbstractInterfaceTypeCustomizer<Tap> implemen
tapConnect.customDevInstance = Math.toIntExact(deviceInstance);
}
+ final String tag = tap.getTag();
+ if (tag != null) {
+ tapConnect.tag = tag.getBytes(StandardCharsets.US_ASCII);
+ }
+
return tapConnect;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizer.java
index 152e6d1c0..ba869b347 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfaces/VhostUserCustomizer.java
@@ -30,6 +30,7 @@ import io.fd.vpp.jvpp.core.dto.DeleteVhostUserIfReply;
import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIf;
import io.fd.vpp.jvpp.core.dto.ModifyVhostUserIfReply;
import io.fd.vpp.jvpp.core.future.FutureJVppCore;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfaceType;
@@ -92,6 +93,10 @@ public class VhostUserCustomizer extends AbstractInterfaceTypeCustomizer<VhostUs
request.renumber = 1;
request.customDevInstance = Math.toIntExact(deviceInstance);
}
+ final String tag = vhostUser.getTag();
+ if (tag != null) {
+ request.tag = tag.getBytes(StandardCharsets.US_ASCII);
+ }
request.useCustomMac = 0;
request.macAddress = new byte[]{};
return request;
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizer.java
index 683450da3..5cfd05859 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizer.java
@@ -16,14 +16,14 @@
package io.fd.hc2vpp.v3po.interfacesstate;
+import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
+import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
+import io.fd.hc2vpp.common.translate.util.NamingContext;
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.InitializingReaderCustomizer;
import io.fd.honeycomb.translate.util.RWUtils;
-import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
-import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
-import io.fd.hc2vpp.common.translate.util.NamingContext;
import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceTapDetailsReplyDump;
@@ -114,13 +114,20 @@ public class TapCustomizer extends FutureJVppCustomizer
LOG.trace("Tap interface: {} attributes returned from VPP: {}", key.getName(), swInterfaceTapDetails);
builder.setTapName(toString(swInterfaceTapDetails.devName));
+
+ final SwInterfaceDetails ifcDetails = getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache(), LOG);
+
+ if (ifcDetails.tag[0] != 0) { // tag supplied
+ builder.setTag(toString(ifcDetails.tag));
+ }
LOG.debug("Tap interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
@Override
public Initialized<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.Tap> init(
@Nonnull final InstanceIdentifier<Tap> id, @Nonnull final Tap readValue, @Nonnull final ReadContext ctx) {
- // The MAC address is set from interface details, those details are retrieved from cache
+ // The MAC address & tag is set from interface details, those details are retrieved from cache
final InterfaceKey key = id.firstKeyOf(Interface.class);
final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
final SwInterfaceDetails ifcDetails =
@@ -130,6 +137,7 @@ public class TapCustomizer extends FutureJVppCustomizer
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.TapBuilder()
.setMac(new PhysAddress(vppPhysAddrToYang(ifcDetails.l2Address)))
.setTapName(readValue.getTapName())
+ .setTag(ifcDetails.tag[0] == 0 ? null : toString(ifcDetails.tag))
// tapBuilder.setDeviceInstance();
.build());
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
index 6a918e842..623c7dbfa 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizer.java
@@ -24,6 +24,7 @@ import io.fd.honeycomb.translate.util.RWUtils;
import io.fd.hc2vpp.common.translate.util.FutureJVppCustomizer;
import io.fd.hc2vpp.common.translate.util.JvppReplyConsumer;
import io.fd.hc2vpp.common.translate.util.NamingContext;
+import io.fd.vpp.jvpp.core.dto.SwInterfaceDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetails;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDetailsReplyDump;
import io.fd.vpp.jvpp.core.dto.SwInterfaceVhostUserDump;
@@ -120,6 +121,9 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
LOG.trace("Vhost user interface: {} attributes returned from VPP: {}", key.getName(),
swInterfaceVhostUserDetails);
+ final SwInterfaceDetails ifcDetails = getVppInterfaceDetails(getFutureJVpp(), id, key.getName(),
+ interfaceContext.getIndex(key.getName(), ctx.getMappingContext()), ctx.getModificationCache(), LOG);
+
builder.setRole(swInterfaceVhostUserDetails.isServer == 1
? VhostUserRole.Server
: VhostUserRole.Client);
@@ -129,6 +133,9 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
builder.setVirtioNetHdrSize((long) swInterfaceVhostUserDetails.virtioNetHdrSz);
// TODO: map error code to meaningful message after VPP-436 is done
builder.setConnectError(Integer.toString(swInterfaceVhostUserDetails.sockErrno));
+ if (ifcDetails.tag[0] != 0) { // tag supplied
+ builder.setTag(toString(ifcDetails.tag));
+ }
LOG.debug("Vhost user interface: {}, id: {} attributes read as: {}", key.getName(), index, builder);
}
@@ -138,10 +145,16 @@ public class VhostUserCustomizer extends FutureJVppCustomizer
@Nonnull final InstanceIdentifier<VhostUser> id,
@Nonnull final VhostUser readValue,
@Nonnull final ReadContext ctx) {
+ // The tag is set from interface details, those details are retrieved from cache
+ final InterfaceKey key = id.firstKeyOf(Interface.class);
+ final int index = interfaceContext.getIndex(key.getName(), ctx.getMappingContext());
+ final SwInterfaceDetails ifcDetails =
+ InterfaceCustomizer.getCachedInterfaceDump(ctx.getModificationCache()).get(index);
return Initialized.create(getCfgId(id),
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.v3po.rev161214.interfaces._interface.VhostUserBuilder()
.setRole(readValue.getRole())
.setSocket(readValue.getSocket())
+ .setTag(ifcDetails.tag[0] == 0 ? null : toString(ifcDetails.tag))
.build());
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
index c9de7102a..5927797be 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/TapCustomizerTest.java
@@ -65,6 +65,7 @@ public class TapCustomizerTest extends ReaderCustomizerTest<Tap, TapBuilder> imp
final SwInterfaceDetails details = new SwInterfaceDetails();
details.swIfIndex = IF_INDEX;
details.interfaceName = IF_NAME.getBytes();
+ details.tag = new byte[64];
return details;
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizerTest.java
index 57655db73..ac517e052 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/interfacesstate/VhostUserCustomizerTest.java
@@ -67,6 +67,7 @@ public class VhostUserCustomizerTest extends ReaderCustomizerTest<VhostUser, Vho
final SwInterfaceDetails details = new SwInterfaceDetails();
details.swIfIndex = IF_INDEX;
details.interfaceName = IF_NAME.getBytes();
+ details.tag = new byte[64];
return details;
}