summaryrefslogtreecommitdiffstats
path: root/v3po
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-06-24 13:59:04 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-06-24 13:59:04 +0200
commitb078f1d28cddc07da5bcad076b872113b9383ab4 (patch)
tree46b940292bd5f269d569aa5e804422e2e4ddb2a8 /v3po
parent590fdfed2ae071f731e8795ac7ac80c65d43feb1 (diff)
Fix V3PO for api changesHEADmaster
- VPP introduced changes to GRE tunnels and ArpTermination - this updates the api calls for both. Change-Id: I9dd268a14a88ee701512453ce81d6ae15988832c Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'v3po')
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java8
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/GreCustomizer.java10
-rw-r--r--v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/write/GreCustomizer.java14
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java14
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/GreCustomizerTest.java5
-rw-r--r--v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/write/GreCustomizerTest.java16
6 files changed, 39 insertions, 28 deletions
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
index a7770c5be..a4603ac2a 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizer.java
@@ -31,6 +31,7 @@ import io.fd.jvpp.core.future.FutureJVppCore;
import io.fd.jvpp.core.types.Address;
import io.fd.jvpp.core.types.AddressFamily;
import io.fd.jvpp.core.types.AddressUnion;
+import io.fd.jvpp.core.types.BdIpMac;
import io.fd.jvpp.core.types.Ip4Address;
import io.fd.jvpp.core.types.MacAddress;
import java.util.concurrent.CompletionStage;
@@ -97,18 +98,19 @@ public class ArpTerminationTableEntryCustomizer extends FutureJVppCustomizer
private BdIpMacAddDel createRequest(final ArpTerminationTableEntry entry, final int bdId, boolean isAdd) {
final BdIpMacAddDel request = new BdIpMacAddDel();
- request.bdId = bdId;
+ request.entry = new BdIpMac();
+ request.entry.bdId = bdId;
request.isAdd = booleanToByte(isAdd);
MacAddress macAddress = new MacAddress();
macAddress.macaddress = parseMac(entry.getPhysAddress().getValue());
- request.mac = macAddress;
+ request.entry.mac = macAddress;
final IpAddressNoZone ipAddress = entry.getIpAddress();
Ip4Address ip4Address = new Ip4Address();
ip4Address.ip4Address = ipAddressToArray(ipAddress);
Address address = new Address();
address.af = AddressFamily.ADDRESS_IP4;
address.un = new AddressUnion(ip4Address);
- request.ip = address;
+ request.entry.ip = address;
return request;
}
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/GreCustomizer.java
index af21856fd..1a8d6b3e4 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/read/GreCustomizer.java
@@ -32,6 +32,8 @@ import io.fd.jvpp.core.dto.GreTunnelDetails;
import io.fd.jvpp.core.dto.GreTunnelDetailsReplyDump;
import io.fd.jvpp.core.dto.GreTunnelDump;
import io.fd.jvpp.core.future.FutureJVppCore;
+import io.fd.jvpp.core.types.AddressFamily;
+import io.fd.jvpp.core.types.InterfaceIndex;
import java.util.concurrent.CompletionStage;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.GreTunnel;
@@ -89,7 +91,8 @@ public class GreCustomizer extends FutureJVppCustomizer
LOG.debug("Reading attributes for gre tunnel: {}", key.getName());
// Dump just a single
final GreTunnelDump request = new GreTunnelDump();
- request.swIfIndex = index;
+ request.swIfIndex = new InterfaceIndex();
+ request.swIfIndex.interfaceindex = index;
final CompletionStage<GreTunnelDetailsReplyDump> swInterfaceGreDetailsReplyDumpCompletionStage =
getFutureJVpp().greTunnelDump(request);
@@ -112,9 +115,9 @@ public class GreCustomizer extends FutureJVppCustomizer
LOG.trace("Gre tunnel: {} attributes returned from VPP: {}", key.getName(), reply);
final GreTunnelDetails swInterfaceGreDetails = reply.greTunnelDetails.get(0);
- if (swInterfaceGreDetails.tunnel.isIpv6 == 1) {
+ if (swInterfaceGreDetails.tunnel.dst.af.equals(AddressFamily.ADDRESS_IP6)) {
builder.setDst(new IpAddressNoZone(
- arrayToIpv4AddressNoZone(swInterfaceGreDetails.tunnel.dst.un.getIp6().ip6Address)));
+ arrayToIpv6AddressNoZone(swInterfaceGreDetails.tunnel.dst.un.getIp6().ip6Address)));
builder.setSrc(new IpAddressNoZone(
arrayToIpv6AddressNoZone(swInterfaceGreDetails.tunnel.src.un.getIp6().ip6Address)));
} else {
@@ -128,6 +131,7 @@ public class GreCustomizer extends FutureJVppCustomizer
}
@Override
+ @Nonnull
public Initialized<Gre> init(@Nonnull final InstanceIdentifier<Gre> id, @Nonnull final Gre readValue,
@Nonnull final ReadContext ctx) {
return Initialized.create(getCfgId(id),
diff --git a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/write/GreCustomizer.java b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/write/GreCustomizer.java
index 3d048d47f..6a15072fe 100644
--- a/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/write/GreCustomizer.java
+++ b/v3po/v3po2vpp/src/main/java/io/fd/hc2vpp/v3po/write/GreCustomizer.java
@@ -46,7 +46,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
this.interfaceContext = interfaceContext;
}
- private static GreTunnelAddDel getGreTunnelRequest(final byte isAdd, final IpAddressNoZone srcAddr,
+ private static GreTunnelAddDel getGreTunnelRequest(final boolean isAdd, final IpAddressNoZone srcAddr,
final IpAddressNoZone dstAddr, final int outerFibId,
final byte isIpv6) {
final GreTunnelAddDel greTunnelAddDel = new GreTunnelAddDel();
@@ -64,7 +64,6 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
AddressTranslator.INSTANCE.ipv6AddressToAddress(dstAddr.getIpv6AddressNoZone());
}
greTunnelAddDel.tunnel.outerFibId = outerFibId;
- greTunnelAddDel.tunnel.isIpv6 = isIpv6;
return greTunnelAddDel;
}
@@ -99,13 +98,13 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
LOG.debug("Setting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
final CompletionStage<GreTunnelAddDelReply> greAddDelTunnelReplyCompletionStage =
- getFutureJVpp().greTunnelAddDel(getGreTunnelRequest((byte) 1 /* is add */, gre.getSrc(),
+ getFutureJVpp().greTunnelAddDel(getGreTunnelRequest(true, gre.getSrc(),
gre.getDst(), outerFibId, isIpv6));
final GreTunnelAddDelReply reply =
getReplyForCreate(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id, gre);
LOG.debug("Gre tunnel set successfully for: {}, gre: {}", swIfName, gre);
- if (interfaceContext.containsName(reply.swIfIndex, writeContext.getMappingContext())) {
+ if (interfaceContext.containsName(reply.swIfIndex.interfaceindex, writeContext.getMappingContext())) {
// VPP keeps gre tunnels present even after they are delete(reserving ID for next tunnel)
// This may cause inconsistencies in mapping context when configuring tunnels like this:
// 1. Add tunnel 2. Delete tunnel 3. Read interfaces (reserved mapping e.g. gre_tunnel0 -> 6
@@ -113,13 +112,14 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
// reserved ID and context is invalid)
// That's why a check has to be performed here removing mapping gre_tunnel0 -> 6 mapping and storing
// new name for that ID
- final String formerName = interfaceContext.getName(reply.swIfIndex, writeContext.getMappingContext());
+ final String formerName =
+ interfaceContext.getName(reply.swIfIndex.interfaceindex, writeContext.getMappingContext());
LOG.debug("Removing updated mapping of a gre tunnel, id: {}, former name: {}, new name: {}",
reply.swIfIndex, formerName, swIfName);
interfaceContext.removeName(formerName, writeContext.getMappingContext());
}
// Add new interface to our interface context
- interfaceContext.addName(reply.swIfIndex, swIfName, writeContext.getMappingContext());
+ interfaceContext.addName(reply.swIfIndex.interfaceindex, swIfName, writeContext.getMappingContext());
}
private boolean isIpv6(final Gre gre) {
@@ -136,7 +136,7 @@ public class GreCustomizer extends AbstractInterfaceTypeCustomizer<Gre> implemen
LOG.debug("Deleting gre tunnel for interface: {}. Gre: {}", swIfName, gre);
final CompletionStage<GreTunnelAddDelReply> greAddDelTunnelReplyCompletionStage =
- getFutureJVpp().greTunnelAddDel(getGreTunnelRequest((byte) 0 /* is add */, gre.getSrc(),
+ getFutureJVpp().greTunnelAddDel(getGreTunnelRequest(false, gre.getSrc(),
gre.getDst(), outerFibId, isIpv6));
getReplyForDelete(greAddDelTunnelReplyCompletionStage.toCompletableFuture(), id);
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
index c419e5c55..ce6ad9fd6 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/l2/ArpTerminationTableEntryCustomizerTest.java
@@ -35,6 +35,7 @@ import io.fd.jvpp.core.dto.BdIpMacAddDelReply;
import io.fd.jvpp.core.types.Address;
import io.fd.jvpp.core.types.AddressFamily;
import io.fd.jvpp.core.types.AddressUnion;
+import io.fd.jvpp.core.types.BdIpMac;
import io.fd.jvpp.core.types.Ip4Address;
import io.fd.jvpp.core.types.MacAddress;
import org.junit.Test;
@@ -109,16 +110,17 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
private BdIpMacAddDel generateBdIpMacAddDelRequest(final byte[] ipAddress, final byte[] macAddress,
final byte isAdd) {
final BdIpMacAddDel request = new BdIpMacAddDel();
+ request.entry = new BdIpMac();
Address address = new Address();
address.af = AddressFamily.ADDRESS_IP4;
Ip4Address ip4Address = new Ip4Address();
ip4Address.ip4Address = ipAddress;
address.un = new AddressUnion(ip4Address);
- request.ip = address;
+ request.entry.ip = address;
MacAddress macAddr = new MacAddress();
macAddr.macaddress = macAddress;
- request.mac = macAddr;
- request.bdId = BD_ID;
+ request.entry.mac = macAddr;
+ request.entry.bdId = BD_ID;
request.isAdd = isAdd;
return request;
}
@@ -136,9 +138,9 @@ public class ArpTerminationTableEntryCustomizerTest extends WriterCustomizerTest
ArgumentCaptor<BdIpMacAddDel> argumentCaptor = ArgumentCaptor.forClass(BdIpMacAddDel.class);
verify(api).bdIpMacAddDel(argumentCaptor.capture());
final BdIpMacAddDel actual = argumentCaptor.getValue();
- assertArrayEquals(expected.mac.macaddress, actual.mac.macaddress);
- assertArrayEquals(expected.ip.un.getIp4().ip4Address, actual.ip.un.getIp4().ip4Address);
- assertEquals(expected.bdId, actual.bdId);
+ assertArrayEquals(expected.entry.mac.macaddress, actual.entry.mac.macaddress);
+ assertArrayEquals(expected.entry.ip.un.getIp4().ip4Address, actual.entry.ip.un.getIp4().ip4Address);
+ assertEquals(expected.entry.bdId, actual.entry.bdId);
assertEquals(expected.isAdd, actual.isAdd);
}
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/GreCustomizerTest.java
index e29c1f191..d42daf83f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/read/GreCustomizerTest.java
@@ -38,6 +38,7 @@ import io.fd.jvpp.core.dto.GreTunnelDetailsReplyDump;
import io.fd.jvpp.core.dto.GreTunnelDump;
import io.fd.jvpp.core.dto.SwInterfaceDetails;
import io.fd.jvpp.core.types.GreTunnel;
+import io.fd.jvpp.core.types.InterfaceIndex;
import org.junit.Test;
import org.mockito.Mock;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.VppInterfaceAugmentation;
@@ -81,11 +82,11 @@ public class GreCustomizerTest extends ReaderCustomizerTest<Gre, GreBuilder> imp
final GreTunnelDetailsReplyDump value = new GreTunnelDetailsReplyDump();
final GreTunnelDetails greTunnelDetails = new GreTunnelDetails();
greTunnelDetails.tunnel = new GreTunnel();
- greTunnelDetails.tunnel.isIpv6 = 0;
greTunnelDetails.tunnel.dst = ipv4AddressToAddress(new Ipv4Address("1.2.3.4"));
greTunnelDetails.tunnel.src = ipv4AddressToAddress(new Ipv4Address("1.2.3.5"));
greTunnelDetails.tunnel.outerFibId = 55;
- greTunnelDetails.tunnel.swIfIndex = 0;
+ greTunnelDetails.tunnel.swIfIndex = new InterfaceIndex();
+ greTunnelDetails.tunnel.swIfIndex.interfaceindex = 0;
value.greTunnelDetails = Lists.newArrayList(greTunnelDetails);
doReturn(future(value)).when(api).greTunnelDump(any(GreTunnelDump.class));
diff --git a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/write/GreCustomizerTest.java b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/write/GreCustomizerTest.java
index 9707eb3a1..a88b6c72f 100644
--- a/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/write/GreCustomizerTest.java
+++ b/v3po/v3po2vpp/src/test/java/io/fd/hc2vpp/v3po/write/GreCustomizerTest.java
@@ -18,6 +18,7 @@ package io.fd.hc2vpp.v3po.write;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
@@ -34,6 +35,8 @@ import io.fd.jvpp.VppBaseCallException;
import io.fd.jvpp.VppInvocationException;
import io.fd.jvpp.core.dto.GreTunnelAddDel;
import io.fd.jvpp.core.dto.GreTunnelAddDelReply;
+import io.fd.jvpp.core.types.AddressFamily;
+import io.fd.jvpp.core.types.InterfaceIndex;
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.v3po.rev190527.VppInterfaceAugmentation;
@@ -49,8 +52,6 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class GreCustomizerTest extends WriterCustomizerTest implements AddressTranslator {
private static final String IFC_TEST_INSTANCE = "ifc-test-instance";
- private static final byte ADD_GRE = 1;
- private static final byte DEL_GRE = 0;
private final String IFACE_NAME = "eth0";
private final int IFACE_ID = 1;
private InstanceIdentifier<Gre> id = InstanceIdentifier.create(Interfaces.class).child(Interface.class, new InterfaceKey(IFACE_NAME))
@@ -61,7 +62,7 @@ public class GreCustomizerTest extends WriterCustomizerTest implements AddressTr
final GreBuilder builder = new GreBuilder();
builder.setSrc(new IpAddressNoZone(new Ipv4AddressNoZone("192.168.20.10")));
builder.setDst(new IpAddressNoZone(new Ipv4AddressNoZone("192.168.20.11")));
- builder.setOuterFibId(Long.valueOf(123));
+ builder.setOuterFibId(123L);
return builder.build();
}
@@ -74,7 +75,8 @@ public class GreCustomizerTest extends WriterCustomizerTest implements AddressTr
private void whenGreAddDelTunnelThenSuccess() {
final GreTunnelAddDelReply reply = new GreTunnelAddDelReply();
- reply.swIfIndex = IFACE_ID;
+ reply.swIfIndex = new InterfaceIndex();
+ reply.swIfIndex.interfaceindex = IFACE_ID;
doReturn(future(reply)).when(api).greTunnelAddDel(any(GreTunnelAddDel.class));
}
@@ -86,7 +88,7 @@ public class GreCustomizerTest extends WriterCustomizerTest implements AddressTr
ArgumentCaptor<GreTunnelAddDel> argumentCaptor = ArgumentCaptor.forClass(GreTunnelAddDel.class);
verify(api).greTunnelAddDel(argumentCaptor.capture());
final GreTunnelAddDel actual = argumentCaptor.getValue();
- assertEquals(0, actual.tunnel.isIpv6);
+ assertEquals(AddressFamily.ADDRESS_IP4, actual.tunnel.src.af);
assertArrayEquals(ipAddressToArray(gre.getSrc()), actual.tunnel.src.un.getIp4().ip4Address);
assertArrayEquals(ipAddressToArray(gre.getDst()), actual.tunnel.dst.un.getIp4().ip4Address);
assertEquals(gre.getOuterFibId().intValue(), actual.tunnel.outerFibId);
@@ -95,12 +97,12 @@ public class GreCustomizerTest extends WriterCustomizerTest implements AddressTr
private void verifyGreAddWasInvoked(final Gre gre) throws VppInvocationException {
final GreTunnelAddDel actual = verifyGreAddDelTunnelWasInvoked(gre);
- assertEquals(ADD_GRE, actual.isAdd);
+ assertTrue(actual.isAdd);
}
private void verifyGreDeleteWasInvoked(final Gre gre) throws VppInvocationException {
final GreTunnelAddDel actual = verifyGreAddDelTunnelWasInvoked(gre);
- assertEquals(DEL_GRE, actual.isAdd);
+ assertFalse(actual.isAdd);
}
@Test