NAT: interface fib fix (VPP-1691)
[vpp.git] / src / plugins / nat / nat.c
index 0d909ce..363c1c0 100755 (executable)
@@ -830,6 +830,7 @@ snat_add_static_mapping (ip4_address_t l_addr, ip4_address_t e_addr,
        {
          fib_index = sm->inside_fib_index;
          vrf_id = sm->inside_vrf_id;
+         fib_table_lock (fib_index, FIB_PROTOCOL_IP4, FIB_SOURCE_PLUGIN_LOW);
        }
 
       if (!(out2in_only || identity_nat))
@@ -2177,6 +2178,7 @@ snat_update_outside_fib (u32 sw_if_index, u32 new_fib_index,
   nat_outside_fib_t *outside_fib;
   snat_interface_t *i;
   u8 is_add = 1;
+  u8 match = 0;
 
   if (new_fib_index == old_fib_index)
     return;
@@ -2184,14 +2186,21 @@ snat_update_outside_fib (u32 sw_if_index, u32 new_fib_index,
   if (!vec_len (sm->outside_fibs))
     return;
 
-  pool_foreach (i, sm->interfaces, (
-                                    {
-                                    if (i->sw_if_index == sw_if_index)
-                                    {
-                                    if (!(nat_interface_is_outside (i)))
-                                    return;}
-                                    }
-               ));
+  /* *INDENT-OFF* */
+  pool_foreach (i, sm->interfaces,
+    ({
+      if (i->sw_if_index == sw_if_index)
+        {
+          if (!(nat_interface_is_outside (i)))
+           return;
+          match = 1;
+        }
+    }));
+  /* *INDENT-ON* */
+
+  if (!match)
+    return;
+
   vec_foreach (outside_fib, sm->outside_fibs)
   {
     if (outside_fib->fib_index == old_fib_index)