aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/in2out.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2019-02-26 09:05:23 -0800
committerMatus Fabian <matfabia@cisco.com>2019-02-27 00:56:32 -0800
commit34931eb47124ef78a3aa9575930e848a78c9618b (patch)
treedec97d4d04e0011fe49b7712d7deba5ef8f0e99c /src/plugins/nat/in2out.c
parent8343ee5665942353e57ee074da62b9d07c1c510b (diff)
NAT44: active-passive HA (VPP-1571)
session synchronization so that we can build a plain active-passive HA NAT pair Change-Id: I21db200491081ca46b7af3e82afc677c1985abf4 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/in2out.c')
-rwxr-xr-xsrc/plugins/nat/in2out.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/src/plugins/nat/in2out.c b/src/plugins/nat/in2out.c
index 7ed375d46e5..8bdb792442a 100755
--- a/src/plugins/nat/in2out.c
+++ b/src/plugins/nat/in2out.c
@@ -29,6 +29,7 @@
#include <nat/nat_reass.h>
#include <nat/nat_inlines.h>
#include <nat/nat_syslog.h>
+#include <nat/nat_ha.h>
#include <vppinfra/hash.h>
#include <vppinfra/error.h>
@@ -224,6 +225,10 @@ nat44_i2o_is_idle_session_cb (clib_bihash_kv_8_8_t * kv, void *arg)
&s->out2in.addr, s->out2in.port,
s->in2out.protocol);
+ nat_ha_sdel (&s->out2in.addr, s->out2in.port, &s->ext_host_addr,
+ s->ext_host_port, s->out2in.protocol, s->out2in.fib_index,
+ ctx->thread_index);
+
if (!snat_is_session_static (s))
snat_free_outside_address_and_port (sm->addresses, ctx->thread_index,
&s->out2in);
@@ -306,7 +311,7 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
return SNAT_IN2OUT_NEXT_DROP;
}
- s = nat_session_alloc_or_recycle (sm, u, thread_index);
+ s = nat_session_alloc_or_recycle (sm, u, thread_index, now);
if (!s)
{
nat44_delete_user_with_no_session (sm, u, thread_index);
@@ -380,6 +385,12 @@ slow_path (snat_main_t * sm, vlib_buffer_t * b0,
&s->in2out.addr, s->in2out.port, &s->out2in.addr,
s->out2in.port, s->in2out.protocol);
+ nat_ha_sadd (&s->in2out.addr, s->in2out.port, &s->out2in.addr,
+ s->out2in.port, &s->ext_host_addr, s->ext_host_port,
+ &s->ext_host_nat_addr, s->ext_host_nat_port,
+ s->in2out.protocol, s->in2out.fib_index, s->flags,
+ thread_index, 0);
+
return next0;
}
@@ -803,7 +814,7 @@ icmp_in2out_slow_path (snat_main_t * sm,
/* Accounting */
nat44_session_update_counters (s0, now,
vlib_buffer_length_in_chain
- (sm->vlib_main, b0));
+ (sm->vlib_main, b0), thread_index);
/* Per-user LRU list maintenance */
nat44_session_update_lru (sm, s0, thread_index);
}
@@ -1091,8 +1102,8 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Accounting */
nat44_session_update_counters (s0, now,
- vlib_buffer_length_in_chain (vm,
- b0));
+ vlib_buffer_length_in_chain (vm, b0),
+ thread_index);
/* Per-user LRU list maintenance */
nat44_session_update_lru (sm, s0, thread_index);
trace00:
@@ -1280,8 +1291,8 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Accounting */
nat44_session_update_counters (s1, now,
- vlib_buffer_length_in_chain (vm,
- b1));
+ vlib_buffer_length_in_chain (vm, b1),
+ thread_index);
/* Per-user LRU list maintenance */
nat44_session_update_lru (sm, s1, thread_index);
trace01:
@@ -1504,8 +1515,8 @@ snat_in2out_node_fn_inline (vlib_main_t * vm,
/* Accounting */
nat44_session_update_counters (s0, now,
- vlib_buffer_length_in_chain (vm,
- b0));
+ vlib_buffer_length_in_chain (vm, b0),
+ thread_index);
/* Per-user LRU list maintenance */
nat44_session_update_lru (sm, s0, thread_index);
@@ -1887,8 +1898,8 @@ VLIB_NODE_FN (nat44_in2out_reass_node) (vlib_main_t * vm,
/* Accounting */
nat44_session_update_counters (s0, now,
- vlib_buffer_length_in_chain (vm,
- b0));
+ vlib_buffer_length_in_chain (vm, b0),
+ thread_index);
/* Per-user LRU list maintenance */
nat44_session_update_lru (sm, s0, thread_index);