nat: perf improvement - replace branchy code
[vpp.git] / src / plugins / nat / nat_det_in2out.c
index dc2873e..cf50805 100644 (file)
@@ -126,7 +126,7 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
   if (!icmp_type_is_error_message
       (vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags))
     {
-      protocol = SNAT_PROTOCOL_ICMP;
+      protocol = NAT_PROTOCOL_ICMP;
       in_addr = ip0->src_address;
       in_port = vnet_buffer (b0)->ip.reass.l4_src_port;
     }
@@ -135,17 +135,17 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
       /* if error message, then it's not fragmented and we can access it */
       inner_ip0 = (ip4_header_t *) (echo0 + 1);
       l4_header = ip4_next_header (inner_ip0);
-      protocol = ip_proto_to_snat_proto (inner_ip0->protocol);
+      protocol = ip_proto_to_nat_proto (inner_ip0->protocol);
       in_addr = inner_ip0->dst_address;
       switch (protocol)
        {
-       case SNAT_PROTOCOL_ICMP:
+       case NAT_PROTOCOL_ICMP:
          inner_icmp0 = (icmp46_header_t *) l4_header;
          inner_echo0 = (icmp_echo_header_t *) (inner_icmp0 + 1);
          in_port = inner_echo0->identifier;
          break;
-       case SNAT_PROTOCOL_UDP:
-       case SNAT_PROTOCOL_TCP:
+       case NAT_PROTOCOL_UDP:
+       case NAT_PROTOCOL_TCP:
          in_port = ((tcp_udp_header_t *) l4_header)->dst_port;
          break;
        default:
@@ -334,9 +334,9 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
              goto trace0;
            }
 
-         proto0 = ip_proto_to_snat_proto (ip0->protocol);
+         proto0 = ip_proto_to_nat_proto (ip0->protocol);
 
-         if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP))
+         if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_ICMP))
            {
              rx_fib_index0 =
                ip4_fib_table_get_index_for_sw_if_index (sw_if_index0);
@@ -411,7 +411,7 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
                                 src_address /* changed member */ );
          ip0->checksum = ip_csum_fold (sum0);
 
-         if (PREDICT_TRUE (proto0 == SNAT_PROTOCOL_TCP))
+         if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
            {
              if (tcp0->flags & TCP_FLAG_SYN)
                ses0->state = SNAT_SESSION_TCP_SYN_SENT;
@@ -507,9 +507,9 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
              goto trace1;
            }
 
-         proto1 = ip_proto_to_snat_proto (ip1->protocol);
+         proto1 = ip_proto_to_nat_proto (ip1->protocol);
 
-         if (PREDICT_FALSE (proto1 == SNAT_PROTOCOL_ICMP))
+         if (PREDICT_FALSE (proto1 == NAT_PROTOCOL_ICMP))
            {
              rx_fib_index1 =
                ip4_fib_table_get_index_for_sw_if_index (sw_if_index1);
@@ -584,7 +584,7 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
                                 src_address /* changed member */ );
          ip1->checksum = ip_csum_fold (sum1);
 
-         if (PREDICT_TRUE (proto1 == SNAT_PROTOCOL_TCP))
+         if (PREDICT_TRUE (proto1 == NAT_PROTOCOL_TCP))
            {
              if (tcp1->flags & TCP_FLAG_SYN)
                ses1->state = SNAT_SESSION_TCP_SYN_SENT;
@@ -716,9 +716,9 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
              goto trace00;
            }
 
-         proto0 = ip_proto_to_snat_proto (ip0->protocol);
+         proto0 = ip_proto_to_nat_proto (ip0->protocol);
 
-         if (PREDICT_FALSE (proto0 == SNAT_PROTOCOL_ICMP))
+         if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_ICMP))
            {
              rx_fib_index0 =
                ip4_fib_table_get_index_for_sw_if_index (sw_if_index0);
@@ -793,7 +793,7 @@ VLIB_NODE_FN (snat_det_in2out_node) (vlib_main_t * vm,
                                 src_address /* changed member */ );
          ip0->checksum = ip_csum_fold (sum0);
 
-         if (PREDICT_TRUE (proto0 == SNAT_PROTOCOL_TCP))
+         if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
            {
              if (tcp0->flags & TCP_FLAG_SYN)
                ses0->state = SNAT_SESSION_TCP_SYN_SENT;