aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_det_in2out.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-05-19 17:47:23 +0000
committerOle Trøan <otroan@employees.org>2020-06-08 13:46:35 +0000
commite3621518046ad7f37ccf77c549a93375ab89da19 (patch)
treeaab4446172fe661f3a2eaa58c1fc4cc1d209219b /src/plugins/nat/nat_det_in2out.c
parentc1f0d9c105c25c67d9ef86a53c10d43d40b61fe0 (diff)
nat: more long read after short write optimization
Replace whitespread (mis)use of snat_session_key_t by proper function arguments where applicable and inline functions to calculate hash keys instead of using structs for that. Make all hash tables use same network byte order port so that there is no longer a discrepancy between static mappings using host byte order while in2out/out2in tables using network byte order. Type: improvement Signed-off-by: Klement Sekera <ksekera@cisco.com> Change-Id: I80786d2f947c67824c101a13bb608f1fe1080f34
Diffstat (limited to 'src/plugins/nat/nat_det_in2out.c')
-rw-r--r--src/plugins/nat/nat_det_in2out.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/plugins/nat/nat_det_in2out.c b/src/plugins/nat/nat_det_in2out.c
index 8628fcc42f7..b9b940559b6 100644
--- a/src/plugins/nat/nat_det_in2out.c
+++ b/src/plugins/nat/nat_det_in2out.c
@@ -96,17 +96,17 @@ format_nat_det_in2out_trace (u8 * s, va_list * args)
u32
icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
u32 thread_index, vlib_buffer_t * b0,
- ip4_header_t * ip0, u8 * p_proto,
- snat_session_key_t * p_value, u8 * p_dont_translate,
- void *d, void *e)
+ ip4_header_t * ip0, ip4_address_t * addr,
+ u16 * port, u32 * fib_index,
+ nat_protocol_t * proto, void *d, void *e,
+ u8 * dont_translate)
{
vlib_main_t *vm = vlib_get_main ();
icmp46_header_t *icmp0;
u32 sw_if_index0;
u32 rx_fib_index0;
- u8 protocol;
+ nat_protocol_t protocol;
snat_det_out_key_t key0;
- u8 dont_translate = 0;
u32 next0 = ~0;
icmp_echo_header_t *echo0, *inner_echo0 = 0;
ip4_header_t *inner_ip0;
@@ -118,6 +118,7 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
snat_det_session_t *ses0 = 0;
ip4_address_t in_addr;
u16 in_port;
+ *dont_translate = 0;
icmp0 = (icmp46_header_t *) ip4_next_header (ip0);
echo0 = (icmp_echo_header_t *) (icmp0 + 1);
@@ -165,7 +166,7 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
IP_PROTOCOL_ICMP,
rx_fib_index0)))
{
- dont_translate = 1;
+ *dont_translate = 1;
goto out;
}
next0 = NAT_DET_IN2OUT_NEXT_DROP;
@@ -185,7 +186,7 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
IP_PROTOCOL_ICMP,
rx_fib_index0)))
{
- dont_translate = 1;
+ *dont_translate = 1;
goto out;
}
if (icmp0->type != ICMP4_echo_request)
@@ -234,14 +235,13 @@ icmp_match_in2out_det (snat_main_t * sm, vlib_node_runtime_t * node,
ses0->expire = now + sm->icmp_timeout;
out:
- *p_proto = protocol;
+ *proto = protocol;
if (ses0)
{
- p_value->addr = new_addr0;
- p_value->fib_index = sm->outside_fib_index;
- p_value->port = ses0->out.out_port;
+ *addr = new_addr0;
+ *fib_index = sm->outside_fib_index;
+ *port = ses0->out.out_port;
}
- *p_dont_translate = dont_translate;
if (d)
*(snat_det_session_t **) d = ses0;
if (e)