aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_format.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_format.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_format.c')
-rw-r--r--src/plugins/nat/nat_format.c22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/plugins/nat/nat_format.c b/src/plugins/nat/nat_format.c
index 33e9655dc4e..8287968e029 100644
--- a/src/plugins/nat/nat_format.c
+++ b/src/plugins/nat/nat_format.c
@@ -76,23 +76,19 @@ format_nat_addr_and_port_alloc_alg (u8 * s, va_list * args)
u8 *
format_snat_key (u8 * s, va_list * args)
{
- snat_session_key_t *key = va_arg (*args, snat_session_key_t *);
+ u64 key = va_arg (*args, u64);
- s = format (s, "%U proto %U port %d fib %d",
- format_ip4_address, &key->addr,
- format_nat_protocol, key->protocol,
- clib_net_to_host_u16 (key->port), key->fib_index);
- return s;
-}
+ ip4_address_t addr;
+ u16 port;
+ nat_protocol_t protocol;
+ u32 fib_index;
-u8 *
-format_static_mapping_key (u8 * s, va_list * args)
-{
- snat_session_key_t *key = va_arg (*args, snat_session_key_t *);
+ split_nat_key (key, &addr, &port, &fib_index, &protocol);
s = format (s, "%U proto %U port %d fib %d",
- format_ip4_address, &key->addr,
- format_nat_protocol, key->protocol, key->port, key->fib_index);
+ format_ip4_address, &addr,
+ format_nat_protocol, protocol,
+ clib_net_to_host_u16 (port), fib_index);
return s;
}