diff options
-rw-r--r-- | nat/nat2vpp/src/main/java/io/fd/hc2vpp/nat/write/NatInstaceCustomizer.java | 7 |
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.")); + } } } |