misc: move to new pool_foreach macros
[vpp.git] / src / plugins / nat / in2out_ed.c
index 2af0ba7..776efdf 100644 (file)
@@ -28,7 +28,7 @@
 #include <nat/lib/ipfix_logging.h>
 #include <nat/nat_inlines.h>
 #include <nat/nat44/inlines.h>
-#include <nat/nat_syslog.h>
+#include <nat/lib/nat_syslog.h>
 #include <nat/nat_ha.h>
 #include <nat/nat44/ed_inlines.h>
 #include <nat/lib/nat_inlines.h>
@@ -586,7 +586,7 @@ static_always_inline int
 nat44_ed_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip,
                                       u16 src_port, u16 dst_port,
                                       u32 thread_index, u32 rx_sw_if_index,
-                                      u32 tx_sw_if_index)
+                                      u32 tx_sw_if_index, f64 now)
 {
   clib_bihash_kv_16_8_t kv, value;
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
@@ -604,13 +604,12 @@ nat44_ed_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip,
       s =
        pool_elt_at_index (tsm->sessions,
                           ed_value_get_session_index (&value));
-      if (nat44_is_ses_closed (s))
+      if (nat44_is_ses_closed (s)
+         && (!s->tcp_closed_timestamp || now >= s->tcp_closed_timestamp))
        {
          nat_free_session_data (sm, s, thread_index, 0);
          nat_ed_session_delete (sm, s, thread_index, 1);
        }
-      else
-       s->flags |= SNAT_SESSION_FLAG_OUTPUT_FEATURE;
       return 1;
     }
 
@@ -628,11 +627,11 @@ nat44_ed_not_translate_output_feature (snat_main_t * sm, ip4_header_t * ip,
 
       /* hairpinning */
       /* *INDENT-OFF* */
-      pool_foreach (i, sm->output_feature_interfaces,
-      ({
+      pool_foreach (i, sm->output_feature_interfaces)
+       {
         if ((nat_interface_is_inside (i)) && (rx_sw_if_index == i->sw_if_index))
            return 0;
-      }));
+      }
       /* *INDENT-ON* */
       return 1;
     }
@@ -658,6 +657,7 @@ icmp_match_in2out_ed (snat_main_t * sm, vlib_node_runtime_t * node,
   vlib_main_t *vm = vlib_get_main ();
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
   *dont_translate = 0;
+  f64 now = vlib_time_now (vm);
 
   sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
   rx_fib_index = ip4_fib_table_get_index_for_sw_if_index (sw_if_index);
@@ -679,7 +679,7 @@ icmp_match_in2out_ed (snat_main_t * sm, vlib_node_runtime_t * node,
          if (PREDICT_FALSE
              (nat44_ed_not_translate_output_feature
               (sm, ip, l_port, r_port, thread_index,
-               sw_if_index, vnet_buffer (b)->sw_if_index[VLIB_TX])))
+               sw_if_index, vnet_buffer (b)->sw_if_index[VLIB_TX], now)))
            {
              *dont_translate = 1;
              goto out;
@@ -826,7 +826,7 @@ nat44_ed_in2out_unknown_proto (snat_main_t * sm,
       else
        {
          /* *INDENT-OFF* */
-         pool_foreach (s, tsm->sessions, {
+         pool_foreach (s, tsm->sessions) {
            if (s->ext_host_addr.as_u32 == ip->dst_address.as_u32)
              {
                new_addr = ip->src_address.as_u32 = s->out2in.addr.as_u32;
@@ -837,7 +837,7 @@ nat44_ed_in2out_unknown_proto (snat_main_t * sm,
 
                break;
              }
-         });
+         }
          /* *INDENT-ON* */
 
          for (i = 0; i < vec_len (sm->addresses); i++)
@@ -1311,7 +1311,8 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t * vm,
                  (nat44_ed_not_translate_output_feature
                   (sm, ip0, vnet_buffer (b0)->ip.reass.l4_src_port,
                    vnet_buffer (b0)->ip.reass.l4_dst_port, thread_index,
-                   sw_if_index0, vnet_buffer (b0)->sw_if_index[VLIB_TX])))
+                   sw_if_index0, vnet_buffer (b0)->sw_if_index[VLIB_TX],
+                   now)))
                goto trace0;
 
              /*