summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat_format.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-12-15 18:47:05 +0100
committerOle Tr�an <otroan@employees.org>2021-01-18 08:36:26 +0000
commit4881cb4c6f0d9c6276eb7a45ed355f9fc3d729b3 (patch)
tree07959eb6fc99b88b30e6f81f4620d8d6c70110e2 /src/plugins/nat/nat_format.c
parent4a58e49cfe03150034a65e147a2ffe8d24391b86 (diff)
nat: deal with flows instead of sessions
This change introduces flow concept to endpoint-dependent NAT. Instead of having a session and a plethora of special cases in code for e.g. hairpinning, twice-nat and others, figure all this out and store it in flow logic. Every flow has a match and a rewrite part. This unifies all the NAT packet processing cases into one - match a flow and rewrite the packet based on that flow. It also provides a cure for hairpinning dilemma where one part of the flow is on one worker and another on a different one. These cases are also sped up by not requiring destination adress lookup every single time to be able to rewrite source nat as this is now part of flow rewrite logic. Type: improvement Change-Id: Ib60c992e16792ea4d4129bc10202ebb99a73b5be Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat_format.c')
-rw-r--r--src/plugins/nat/nat_format.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/nat/nat_format.c b/src/plugins/nat/nat_format.c
index 90faeb96e9b..2fbd7498f49 100644
--- a/src/plugins/nat/nat_format.c
+++ b/src/plugins/nat/nat_format.c
@@ -121,9 +121,9 @@ format_snat_session (u8 * s, va_list * args)
s = format (s, " i2o %U proto %u fib %u\n",
format_ip4_address, &sess->in2out.addr,
sess->in2out.port, sess->in2out.fib_index);
- s = format (s, " o2i %U proto %u fib %u\n",
- format_ip4_address, &sess->out2in.addr,
- sess->out2in.port, sess->out2in.fib_index);
+ s =
+ format (s, " o2i %U proto %u fib %u\n", format_ip4_address,
+ &sess->out2in.addr, sess->out2in.port, sess->out2in.fib_index);
}
else
{
@@ -132,10 +132,9 @@ format_snat_session (u8 * s, va_list * args)
format_nat_protocol, sess->nat_proto,
clib_net_to_host_u16 (sess->in2out.port),
sess->in2out.fib_index);
- s = format (s, " o2i %U proto %U port %d fib %d\n",
- format_ip4_address, &sess->out2in.addr,
- format_nat_protocol, sess->nat_proto,
- clib_net_to_host_u16 (sess->out2in.port),
+ s = format (s, " o2i %U proto %U port %d fib %d\n",
+ format_ip4_address, &sess->out2in.addr, format_nat_protocol,
+ sess->nat_proto, clib_net_to_host_u16 (sess->out2in.port),
sess->out2in.fib_index);
}
if (is_ed_session (sess) || is_fwd_bypass_session (sess))
@@ -155,6 +154,8 @@ format_snat_session (u8 * s, va_list * args)
format_ip4_address, &sess->ext_host_addr,
clib_net_to_host_u16 (sess->ext_host_port));
}
+ s = format (s, " i2o flow: %U\n", format_nat_6t_flow, &sess->i2o);
+ s = format (s, " o2i flow: %U\n", format_nat_6t_flow, &sess->o2i);
}
s = format (s, " index %llu\n", sess - tsm->sessions);
s = format (s, " last heard %.2f\n", sess->last_heard);