aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44_cli.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/nat44_cli.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/nat44_cli.c')
-rw-r--r--src/plugins/nat/nat44_cli.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c
index 68ed0cb7207..ffc5fd43618 100644
--- a/src/plugins/nat/nat44_cli.c
+++ b/src/plugins/nat/nat44_cli.c
@@ -674,7 +674,7 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (now >= sess_timeout_time)
timed_out++;
- switch (s->in2out.protocol)
+ switch (s->nat_proto)
{
case NAT_PROTOCOL_ICMP:
icmp_sessions++;
@@ -720,7 +720,7 @@ nat44_show_summary_command_fn (vlib_main_t * vm, unformat_input_t * input,
if (now >= sess_timeout_time)
timed_out++;
- switch (s->in2out.protocol)
+ switch (s->nat_proto)
{
case NAT_PROTOCOL_ICMP:
icmp_sessions++;
@@ -1071,7 +1071,8 @@ add_static_mapping_command_fn (vlib_main_t * vm,
goto done;
}
- rv = snat_add_static_mapping (l_addr, e_addr, (u16) l_port, (u16) e_port,
+ rv = snat_add_static_mapping (l_addr, e_addr, clib_host_to_net_u16 (l_port),
+ clib_host_to_net_u16 (e_port),
vrf_id, addr_only, sw_if_index, proto, is_add,
twice_nat, out2in_only, 0, 0);
@@ -1155,9 +1156,10 @@ add_identity_mapping_command_fn (vlib_main_t * vm,
}
}
- rv = snat_add_static_mapping (addr, addr, (u16) port, (u16) port,
- vrf_id, addr_only, sw_if_index, proto, is_add,
- 0, 0, 0, 1);
+ rv =
+ snat_add_static_mapping (addr, addr, clib_host_to_net_u16 (port),
+ clib_host_to_net_u16 (port), vrf_id, addr_only,
+ sw_if_index, proto, is_add, 0, 0, 0, 1);
switch (rv)
{
@@ -1730,10 +1732,13 @@ nat44_del_session_command_fn (vlib_main_t * vm,
if (is_ed)
rv =
- nat44_del_ed_session (sm, &addr, port, &eh_addr, eh_port,
+ nat44_del_ed_session (sm, &addr, clib_host_to_net_u16 (port), &eh_addr,
+ clib_host_to_net_u16 (eh_port),
nat_proto_to_ip_proto (proto), vrf_id, is_in);
else
- rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in);
+ rv =
+ nat44_del_session (sm, &addr, clib_host_to_net_u16 (port), proto,
+ vrf_id, is_in);
switch (rv)
{