nat: nat44-ed i2o & o2i trace fix
[vpp.git] / src / plugins / nat / nat44-ed / nat44_ed_out2in.c
index 90f2ec3..f46433c 100644 (file)
@@ -63,12 +63,13 @@ format_nat44_ed_out2in_trace (u8 * s, va_list * args)
     t->is_slow_path ? "NAT44_OUT2IN_ED_SLOW_PATH" :
     "NAT44_OUT2IN_ED_FAST_PATH";
 
-  s = format (s, "%s: sw_if_index %d, next index %d, session %d", tag,
-             t->sw_if_index, t->next_index, t->session_index);
+  s = format (s, "%s: sw_if_index %d, next index %d", tag, t->sw_if_index,
+             t->next_index);
   if (~0 != t->session_index)
     {
-      s = format (s, ", translation result '%U' via %s",
-                 format_nat_ed_translation_error, t->translation_error,
+      s = format (s, ", session %d, translation result '%U' via %s",
+                 t->session_index, format_nat_ed_translation_error,
+                 t->translation_error,
                  t->translation_via_i2of ? "i2of" : "o2if");
       s = format (s, "\n  i2of %U", format_nat_6t_flow, &t->i2of);
       s = format (s, "\n  o2if %U", format_nat_6t_flow, &t->o2if);
@@ -149,7 +150,7 @@ icmp_out2in_ed_slow_path (snat_main_t *sm, vlib_buffer_t *b, ip4_header_t *ip,
     }
 
   if (snat_static_mapping_match (
-       sm, ip->dst_address, lookup_sport, rx_fib_index,
+       vm, sm, ip->dst_address, lookup_sport, rx_fib_index,
        ip_proto_to_nat_proto (ip->protocol), &sm_addr, &sm_port,
        &sm_fib_index, 1, &is_addr_only, 0, 0, 0, &identity_nat, &m))
     {
@@ -372,7 +373,6 @@ create_session_for_static_mapping_ed (
 {
   snat_session_t *s;
   ip4_header_t *ip;
-  udp_header_t *udp;
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
 
   if (PREDICT_FALSE
@@ -392,10 +392,10 @@ create_session_for_static_mapping_ed (
     }
 
   ip = vlib_buffer_get_current (b);
-  udp = ip4_next_header (ip);
 
   s->ext_host_addr.as_u32 = ip->src_address.as_u32;
-  s->ext_host_port = nat_proto == NAT_PROTOCOL_ICMP ? 0 : udp->src_port;
+  s->ext_host_port =
+    nat_proto == NAT_PROTOCOL_ICMP ? 0 : vnet_buffer (b)->ip.reass.l4_src_port;
   s->flags |= SNAT_SESSION_FLAG_STATIC_MAPPING;
   if (lb_nat)
     s->flags |= SNAT_SESSION_FLAG_LOAD_BALANCING;
@@ -574,7 +574,6 @@ create_bypass_for_fwd (snat_main_t *sm, vlib_buffer_t *b, snat_session_t *s,
                       ip4_header_t *ip, u32 rx_fib_index, u32 thread_index)
 {
   clib_bihash_kv_16_8_t kv, value;
-  udp_header_t *udp;
   snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
   vlib_main_t *vm = vlib_get_main ();
   f64 now = vlib_time_now (vm);
@@ -593,9 +592,8 @@ create_bypass_for_fwd (snat_main_t *sm, vlib_buffer_t *b, snat_session_t *s,
     {
       if (ip->protocol == IP_PROTOCOL_UDP || ip->protocol == IP_PROTOCOL_TCP)
        {
-         udp = ip4_next_header (ip);
-         lookup_sport = udp->dst_port;
-         lookup_dport = udp->src_port;
+         lookup_sport = vnet_buffer (b)->ip.reass.l4_dst_port;
+         lookup_dport = vnet_buffer (b)->ip.reass.l4_src_port;
        }
       else
        {
@@ -1201,11 +1199,11 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
          /* Try to match static mapping by external address and port,
             destination address and port in packet */
 
-         if (snat_static_mapping_match
-             (sm, ip0->dst_address,
-              vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0,
-              proto0, &sm_addr, &sm_port, &sm_fib_index, 1, 0,
-              &twice_nat0, &lb_nat0, &ip0->src_address, &identity_nat0, &m))
+         if (snat_static_mapping_match (
+               vm, sm, ip0->dst_address,
+               vnet_buffer (b0)->ip.reass.l4_dst_port, rx_fib_index0, proto0,
+               &sm_addr, &sm_port, &sm_fib_index, 1, 0, &twice_nat0, &lb_nat0,
+               &ip0->src_address, &identity_nat0, &m))
            {
              /*
               * Send DHCP packets to the ipv4 stack, or we won't