summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat64_in2out.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-05-11 08:58:05 +0000
committerOle Trøan <otroan@employees.org>2020-05-13 11:36:42 +0000
commitbc752e432ff3e252f6e1a3f0372c9532f14909cd (patch)
tree5399347c1e469d21529a0bc20ffd2d0783434e40 /src/plugins/nat/nat64_in2out.c
parent1d61c2194d21df2003ff07ff5feae4130de6277e (diff)
nat: perf improvement - replace branchy code
Use a lookup table instead. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: Ia8461099828bb8824bf016201f135e6b69c444d1
Diffstat (limited to 'src/plugins/nat/nat64_in2out.c')
-rw-r--r--src/plugins/nat/nat64_in2out.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/src/plugins/nat/nat64_in2out.c b/src/plugins/nat/nat64_in2out.c
index 8d4b1a89cad..38e98340b8c 100644
--- a/src/plugins/nat/nat64_in2out.c
+++ b/src/plugins/nat/nat64_in2out.c
@@ -224,7 +224,7 @@ nat64_in2out_tcp_udp (vlib_main_t * vm, vlib_buffer_t * p, u16 l4_offset,
u16 out_port;
ip4_address_t out_addr;
if (nat64_alloc_out_addr_and_port
- (fib_index, ip_proto_to_snat_proto (proto), &out_addr,
+ (fib_index, ip_proto_to_nat_proto (proto), &out_addr,
&out_port, ctx->thread_index))
return -1;
@@ -335,7 +335,7 @@ nat64_in2out_icmp_set_cb (ip6_header_t * ip6, ip4_header_t * ip4, void *arg)
u16 out_id;
ip4_address_t out_addr;
if (nat64_alloc_out_addr_and_port
- (fib_index, SNAT_PROTOCOL_ICMP, &out_addr, &out_id,
+ (fib_index, NAT_PROTOCOL_ICMP, &out_addr, &out_id,
ctx->thread_index))
return -1;
@@ -715,7 +715,7 @@ nat64_in2out_tcp_udp_hairpinning (vlib_main_t * vm, vlib_buffer_t * b,
u16 out_port;
ip4_address_t out_addr;
if (nat64_alloc_out_addr_and_port
- (fib_index, ip_proto_to_snat_proto (proto), &out_addr,
+ (fib_index, ip_proto_to_nat_proto (proto), &out_addr,
&out_port, thread_index))
return -1;
@@ -1112,11 +1112,11 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
goto trace0;
}
- proto0 = ip_proto_to_snat_proto (l4_protocol0);
+ proto0 = ip_proto_to_nat_proto (l4_protocol0);
if (is_slow_path)
{
- if (PREDICT_TRUE (proto0 == ~0))
+ if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_OTHER))
{
other_packets++;
if (is_hairpinning (&ip60->dst_address))
@@ -1146,14 +1146,14 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
}
else
{
- if (PREDICT_FALSE (proto0 == ~0))
+ if (PREDICT_FALSE (proto0 == NAT_PROTOCOL_OTHER))
{
next0 = NAT64_IN2OUT_NEXT_SLOWPATH;
goto trace0;
}
}
- if (proto0 == SNAT_PROTOCOL_ICMP)
+ if (proto0 == NAT_PROTOCOL_ICMP)
{
icmp_packets++;
if (is_hairpinning (&ip60->dst_address))
@@ -1178,9 +1178,9 @@ nat64_in2out_node_fn_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
goto trace0;
}
}
- else if (proto0 == SNAT_PROTOCOL_TCP || proto0 == SNAT_PROTOCOL_UDP)
+ else if (proto0 == NAT_PROTOCOL_TCP || proto0 == NAT_PROTOCOL_UDP)
{
- if (proto0 == SNAT_PROTOCOL_TCP)
+ if (proto0 == NAT_PROTOCOL_TCP)
tcp_packets++;
else
udp_packets++;