From 36a62702c5454d0a3f7e7aafc5b95d6ca0a7d703 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Wed, 4 Apr 2018 03:27:43 -0700 Subject: [PATCH] NAT44: prohibit multiple static mappings for a single local address (VPP-1224) Change-Id: I32b30210c2f1aec10a1b614d04f427662326a3d2 Signed-off-by: Matus Fabian --- src/plugins/nat/nat.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index a2b4010df0b..9a620472b86 100644 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -785,6 +785,17 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, vrf_id = sm->inside_vrf_id; } + if (!out2in_only) + { + m_key.addr = l_addr; + m_key.port = addr_only ? 0 : l_port; + m_key.protocol = addr_only ? 0 : proto; + m_key.fib_index = fib_index; + kv.key = m_key.as_u64; + if (!clib_bihash_search_8_8 (&sm->static_mapping_by_local, &kv, &value)) + return VNET_API_ERROR_VALUE_EXIST; + } + /* Find external address in allocated addresses and reserve port for address and port pair mapping when dynamic translations enabled */ if (!(addr_only || sm->static_mapping_only || out2in_only)) -- 2.16.6