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 <[email protected]>
@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."));
+ }
}
}