summaryrefslogtreecommitdiffstats
path: root/nat
diff options
context:
space:
mode:
authorMichal Cmarada <mcmarada@cisco.com>2019-05-17 10:31:23 +0200
committerMichal Cmarada <mcmarada@cisco.com>2019-05-17 10:31:23 +0200
commit0d5d328b1d0e9de2d1c7ab957139846c2feb8038 (patch)
treef414dd8fa3cfe40d0b1ffbd74dd6172ac4e8c7f8 /nat
parent68f67ac93942800eb09efa92f222cb8ac592bacc (diff)
fix flags and Tag in NAT implementation
- tag being null causes crashes when vpp API is called - null flags causes crashes, flags should be set at least to default value (0) Change-Id: If4e116212b1a85b312837830501ec226cec37bfa Signed-off-by: Michal Cmarada <mcmarada@cisco.com>
Diffstat (limited to 'nat')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java4
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java1
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java2
-rw-r--r--nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java1
4 files changed, 8 insertions, 0 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
index 8b9d9dd41..2df0c7e2d 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizer.java
@@ -28,6 +28,7 @@ import io.fd.honeycomb.translate.write.WriteFailedException;
import io.fd.jvpp.nat.dto.Nat44AddDelAddressRange;
import io.fd.jvpp.nat.dto.Nat64AddDelPoolAddrRange;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import javax.annotation.Nonnull;
import org.opendaylight.yang.gen.v1.http.fd.io.hc2vpp.yang.vpp.nat.rev180510.ExternalIpAddressPoolAugmentation;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Prefix;
@@ -81,6 +82,9 @@ final class ExternalIpPoolCustomizer implements ListWriterCustomizer<ExternalIpA
getReplyForWrite(jvppNat.nat64AddDelPoolAddrRange(request).toCompletableFuture(), id);
} else {
final Nat44AddDelAddressRange request = getNat44Request(addressPool.getExternalIpPool(), isAdd);
+ if (request.flags == null) {
+ request.flags = new NatConfigFlags();
+ }
getReplyForWrite(jvppNat.nat44AddDelAddressRange(request).toCompletableFuture(), id);
}
}
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
index bf7811852..00bd77483 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizer.java
@@ -162,6 +162,7 @@ final class MappingEntryCustomizer implements ListWriterCustomizer<MappingEntry,
request.localPort = internalPortNumber.shortValue();
request.externalPort = externalPortNumber.shortValue();
}
+ request.tag = "";
return request;
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
index 0ad81977f..8a55abc66 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/ExternalIpPoolCustomizerTest.java
@@ -34,6 +34,7 @@ import io.fd.jvpp.nat.dto.Nat64AddDelPoolAddrRange;
import io.fd.jvpp.nat.dto.Nat64AddDelPoolAddrRangeReply;
import io.fd.jvpp.nat.future.FutureJVppNatFacade;
import io.fd.jvpp.nat.types.Ip4Address;
+import io.fd.jvpp.nat.types.NatConfigFlags;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
@@ -123,6 +124,7 @@ public class ExternalIpPoolCustomizerTest extends WriterCustomizerTest implement
expectedRequest.firstIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 0};
expectedRequest.lastIpAddress = new Ip4Address();
expectedRequest.lastIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, (byte) 255};
+ expectedRequest.flags = new NatConfigFlags();
return expectedRequest;
}
diff --git a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
index d67552b4a..b5c6b5a8b 100644
--- a/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
+++ b/nat/nat2vpp/src/test/java/io/fd/hc2vpp/nat/write/MappingEntryCustomizerTest.java
@@ -137,6 +137,7 @@ public class MappingEntryCustomizerTest extends WriterCustomizerTest implements
expectedRequest.localIpAddress.ip4Address = new byte[]{(byte) 192, (byte) 168, 1, 87};
expectedRequest.externalIpAddress = new Ip4Address();
expectedRequest.externalIpAddress.ip4Address = new byte[]{45, 1, 5, 7};
+ expectedRequest.tag = "";
return expectedRequest;
}