summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat64.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2017-10-24 04:13:49 -0700
committerOle Trøan <otroan@employees.org>2017-10-25 16:18:54 +0000
commit36ea2d6d3a67a60534a7c2b58551688858a1ce7f (patch)
tree1cb424c70e1f1557e2354eb50559a346adb3314b /src/plugins/nat/nat64.c
parentac1f96d7cdfb845c08400d27ec566b991e32e24b (diff)
One armed NAT (VPP-1035)
Use a single physical interface in order to accomplish NAT44/NAT64. Change-Id: I0c8138953a7a4075df306172e125abad771315e4 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat64.c')
-rw-r--r--src/plugins/nat/nat64.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/plugins/nat/nat64.c b/src/plugins/nat/nat64.c
index bfcfa9b3620..952ca8fb11b 100644
--- a/src/plugins/nat/nat64.c
+++ b/src/plugins/nat/nat64.c
@@ -136,7 +136,7 @@ nat64_add_del_pool_addr (ip4_address_t * addr, u32 vrf_id, u8 is_add)
/* *INDENT-OFF* */
pool_foreach (interface, nm->interfaces,
({
- if (interface->is_inside)
+ if (nat_interface_is_inside(interface))
continue;
snat_add_del_addr_to_fib (addr, 32, interface->sw_if_index, is_add);
@@ -170,7 +170,7 @@ nat64_add_del_interface (u32 sw_if_index, u8 is_inside, u8 is_add)
snat_address_t *ap;
const char *feature_name, *arc_name;
- /* Check if address already exists */
+ /* Check if interface already exists */
/* *INDENT-OFF* */
pool_foreach (i, nm->interfaces,
({
@@ -185,19 +185,29 @@ nat64_add_del_interface (u32 sw_if_index, u8 is_inside, u8 is_add)
if (is_add)
{
if (interface)
- return VNET_API_ERROR_VALUE_EXIST;
+ goto set_flags;
pool_get (nm->interfaces, interface);
interface->sw_if_index = sw_if_index;
- interface->is_inside = is_inside;
-
+ interface->flags = 0;
+ set_flags:
+ if (is_inside)
+ interface->flags |= NAT_INTERFACE_FLAG_IS_INSIDE;
+ else
+ interface->flags |= NAT_INTERFACE_FLAG_IS_OUTSIDE;
}
else
{
if (!interface)
return VNET_API_ERROR_NO_SUCH_ENTRY;
- pool_put (nm->interfaces, interface);
+ if ((nat_interface_is_inside (interface)
+ && nat_interface_is_outside (interface)))
+ interface->flags &=
+ is_inside ? ~NAT_INTERFACE_FLAG_IS_INSIDE :
+ ~NAT_INTERFACE_FLAG_IS_OUTSIDE;
+ else
+ pool_put (nm->interfaces, interface);
}
if (!is_inside)