summaryrefslogtreecommitdiffstats
path: root/nat/nat2vpp/src/main
diff options
context:
space:
mode:
authorMarek Gradzki <mgradzki@cisco.com>2018-04-20 07:02:03 +0200
committerMarek Gradzki <mgradzki@cisco.com>2018-04-20 06:14:29 +0000
commit05d33f7324a18dea67816099a929a60e32c9224c (patch)
tree7caaa3584d676775ac40c4b792eebb44e170aef8 /nat/nat2vpp/src/main
parent61678b785d4ce560f5bfba470beca885524415a8 (diff)
Forbid delete of default NAT instance
NAT instances are mapped to VPP's VRFs. Default NAT instance (id=0) is mapped to default VRF, which is allways present in VPP. This patch forbids deleteion of default instance to be consistent with VPP behaviour and NAT instance reader implementation. Change-Id: I71aa6986395e4ba67baaa75d90905b450434aca4 Signed-off-by: Marek Gradzki <mgradzki@cisco.com>
Diffstat (limited to 'nat/nat2vpp/src/main')
-rw-r--r--nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java7
1 files changed, 7 insertions, 0 deletions
diff --git a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java
index fa5cfa8e2..8e5673003 100644
--- a/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java
+++ b/nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java
@@ -42,5 +42,12 @@ final class NatInstaceCustomizer implements ListWriterCustomizer<NatInstance, Na
@Nonnull final NatInstance dataBefore, @Nonnull final WriteContext writeContext)
throws WriteFailedException {
LOG.trace("Deleting nat-instance: {}", id);
+
+ // For consistency with reader, forbid removing default NAT instance:
+ final Long vrfId = id.firstKeyOf(NatInstance.class).getId();
+ if (vrfId == 0) {
+ throw new WriteFailedException.DeleteFailedException(id,
+ new UnsupportedOperationException("Removing default NAT instance (vrf=0) is not supported."));
+ }
}
}