nat: remove unnecessary code 01/29701/2
authorKlement Sekera <ksekera@cisco.com>
Fri, 30 Oct 2020 16:17:00 +0000 (16:17 +0000)
committerMatthew Smith <mgsmith@netgate.com>
Thu, 5 Nov 2020 18:53:50 +0000 (18:53 +0000)
Type: improvement

Signed-off-by: Klement Sekera <ksekera@cisco.com>
Change-Id: I478f5dcbf7595c62611d25a40aa356d8ce09d216

src/plugins/nat/in2out_ed.c
src/plugins/nat/nat_inlines.h
src/plugins/nat/out2in_ed.c

index f0bb0f9..2af0ba7 100644 (file)
@@ -565,9 +565,7 @@ nat_not_translate_output_feature_fwd (snat_main_t * sm, ip4_header_t * ip,
        {
          if (ip->protocol == IP_PROTOCOL_TCP)
            {
-             if (nat44_set_tcp_session_state_i2o
-                 (sm, now, s, b, thread_index))
-               return 1;
+             nat44_set_tcp_session_state_i2o (sm, now, s, b, thread_index);
            }
          /* Accounting */
          nat44_session_update_counters (s, now,
@@ -1114,8 +1112,7 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t * vm,
            }
          vlib_increment_simple_counter (&sm->counters.fastpath.in2out_ed.tcp,
                                         thread_index, sw_if_index0, 1);
-         if (nat44_set_tcp_session_state_i2o (sm, now, s0, b0, thread_index))
-           goto trace0;
+         nat44_set_tcp_session_state_i2o (sm, now, s0, b0, thread_index);
        }
       else if (!vnet_buffer (b0)->ip.reass.is_non_first_fragment
               && udp0->checksum)
@@ -1400,8 +1397,7 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t * vm,
            }
          vlib_increment_simple_counter (&sm->counters.slowpath.in2out_ed.tcp,
                                         thread_index, sw_if_index0, 1);
-         if (nat44_set_tcp_session_state_i2o (sm, now, s0, b0, thread_index))
-           goto trace0;
+         nat44_set_tcp_session_state_i2o (sm, now, s0, b0, thread_index);
        }
       else if (!vnet_buffer (b0)->ip.reass.is_non_first_fragment
               && udp0->checksum)
index 3c6c84b..8f9be6f 100644 (file)
@@ -309,10 +309,7 @@ nat44_delete_session (snat_main_t * sm, snat_session_t * ses,
     }
 }
 
-/** \brief Set TCP session state.
-    @return 1 if session was closed, otherwise 0
-*/
-always_inline int
+always_inline void
 nat44_set_tcp_session_state_i2o (snat_main_t * sm, f64 now,
                                 snat_session_t * ses, vlib_buffer_t * b,
                                 u32 thread_index)
@@ -359,10 +356,9 @@ nat44_set_tcp_session_state_i2o (snat_main_t * sm, f64 now,
     }
   clib_dlist_remove (tsm->lru_pool, ses->lru_index);
   clib_dlist_addtail (tsm->lru_pool, ses->lru_head_index, ses->lru_index);
-  return 0;
 }
 
-always_inline int
+always_inline void
 nat44_set_tcp_session_state_o2i (snat_main_t * sm, f64 now,
                                 snat_session_t * ses, u8 tcp_flags,
                                 u32 tcp_ack_number, u32 tcp_seq_number,
@@ -404,7 +400,6 @@ nat44_set_tcp_session_state_o2i (snat_main_t * sm, f64 now,
     }
   clib_dlist_remove (tsm->lru_pool, ses->lru_index);
   clib_dlist_addtail (tsm->lru_pool, ses->lru_head_index, ses->lru_index);
-  return 0;
 }
 
 always_inline u32
index 703c854..2f515d0 100644 (file)
@@ -502,10 +502,9 @@ create_bypass_for_fwd (snat_main_t * sm, vlib_buffer_t * b, ip4_header_t * ip,
   if (ip->protocol == IP_PROTOCOL_TCP)
     {
       tcp_header_t *tcp = ip4_next_header (ip);
-      if (nat44_set_tcp_session_state_o2i
-         (sm, now, s, tcp->flags, tcp->ack_number, tcp->seq_number,
-          thread_index))
-       return;
+      nat44_set_tcp_session_state_o2i (sm, now, s, tcp->flags,
+                                      tcp->ack_number, tcp->seq_number,
+                                      thread_index);
     }
 
   /* Accounting */
@@ -969,11 +968,14 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
            }
          vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.tcp,
                                         thread_index, sw_if_index0, 1);
-         if (nat44_set_tcp_session_state_o2i
-             (sm, now, s0, vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
-              vnet_buffer (b0)->ip.reass.tcp_ack_number,
-              vnet_buffer (b0)->ip.reass.tcp_seq_number, thread_index))
-           goto trace0;
+         nat44_set_tcp_session_state_o2i (sm, now, s0,
+                                          vnet_buffer (b0)->ip.
+                                          reass.icmp_type_or_tcp_flags,
+                                          vnet_buffer (b0)->ip.
+                                          reass.tcp_ack_number,
+                                          vnet_buffer (b0)->ip.
+                                          reass.tcp_seq_number,
+                                          thread_index);
        }
       else if (!vnet_buffer (b0)->ip.reass.is_non_first_fragment
               && udp0->checksum)
@@ -1291,11 +1293,14 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
            }
          vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.tcp,
                                         thread_index, sw_if_index0, 1);
-         if (nat44_set_tcp_session_state_o2i
-             (sm, now, s0, vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
-              vnet_buffer (b0)->ip.reass.tcp_ack_number,
-              vnet_buffer (b0)->ip.reass.tcp_seq_number, thread_index))
-           goto trace0;
+         nat44_set_tcp_session_state_o2i (sm, now, s0,
+                                          vnet_buffer (b0)->ip.
+                                          reass.icmp_type_or_tcp_flags,
+                                          vnet_buffer (b0)->ip.
+                                          reass.tcp_ack_number,
+                                          vnet_buffer (b0)->ip.
+                                          reass.tcp_seq_number,
+                                          thread_index);
        }
       else if (!vnet_buffer (b0)->ip.reass.is_non_first_fragment
               && udp0->checksum)