diff options
author | Alexander Chernavin <achernavin@netgate.com> | 2019-05-16 10:51:22 -0400 |
---|---|---|
committer | Ole Trøan <otroan@employees.org> | 2019-05-30 09:41:23 +0000 |
commit | 2ecf18a55081165beb807e4e65c485762d2c9f5e (patch) | |
tree | 91b553ddf3b413829b639c4e7eccd3e553e39b91 | |
parent | 2466f5068f044ddfcb1f300f1f20122030b52221 (diff) |
NAT: create bypass in correct thread if workers>1
Change-Id: I70817579a09a7026f5fa7c8e71babded891ea285
Signed-off-by: Alexander Chernavin <achernavin@netgate.com>
-rw-r--r-- | src/plugins/nat/out2in_ed.c | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/src/plugins/nat/out2in_ed.c b/src/plugins/nat/out2in_ed.c index 06e72f31a1b..7e984807107 100644 --- a/src/plugins/nat/out2in_ed.c +++ b/src/plugins/nat/out2in_ed.c @@ -508,6 +508,18 @@ create_bypass_for_fwd (snat_main_t * sm, ip4_header_t * ip, u32 rx_fib_index, nat44_session_update_lru (sm, s, thread_index); } +static inline void +create_bypass_for_fwd_worker (snat_main_t * sm, ip4_header_t * ip, + u32 rx_fib_index) +{ + ip4_header_t ip_wkr = { + .src_address = ip->dst_address, + }; + u32 thread_index = sm->worker_in2out_cb (&ip_wkr, rx_fib_index); + + create_bypass_for_fwd (sm, ip, rx_fib_index, thread_index); +} + #ifndef CLIB_MARCH_VARIANT u32 icmp_match_out2in_ed (snat_main_t * sm, vlib_node_runtime_t * node, @@ -570,7 +582,10 @@ icmp_match_out2in_ed (snat_main_t * sm, vlib_node_runtime_t * node, next = NAT44_ED_OUT2IN_NEXT_IN2OUT; goto out; } - create_bypass_for_fwd (sm, ip, rx_fib_index, thread_index); + if (sm->num_workers > 1) + create_bypass_for_fwd_worker (sm, ip, rx_fib_index); + else + create_bypass_for_fwd (sm, ip, rx_fib_index, thread_index); goto out; } } @@ -923,8 +938,12 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm, next0 = NAT44_ED_OUT2IN_NEXT_IN2OUT; goto trace00; } - create_bypass_for_fwd (sm, ip0, rx_fib_index0, - thread_index); + if (sm->num_workers > 1) + create_bypass_for_fwd_worker (sm, ip0, + rx_fib_index0); + else + create_bypass_for_fwd (sm, ip0, rx_fib_index0, + thread_index); } goto trace00; } @@ -1157,8 +1176,12 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm, next1 = NAT44_ED_OUT2IN_NEXT_IN2OUT; goto trace01; } - create_bypass_for_fwd (sm, ip1, rx_fib_index1, - thread_index); + if (sm->num_workers > 1) + create_bypass_for_fwd_worker (sm, ip1, + rx_fib_index1); + else + create_bypass_for_fwd (sm, ip1, rx_fib_index1, + thread_index); } goto trace01; } @@ -1425,8 +1448,12 @@ nat44_ed_out2in_node_fn_inline (vlib_main_t * vm, next0 = NAT44_ED_OUT2IN_NEXT_IN2OUT; goto trace0; } - create_bypass_for_fwd (sm, ip0, rx_fib_index0, - thread_index); + if (sm->num_workers > 1) + create_bypass_for_fwd_worker (sm, ip0, + rx_fib_index0); + else + create_bypass_for_fwd (sm, ip0, rx_fib_index0, + thread_index); } goto trace0; } @@ -1778,8 +1805,12 @@ VLIB_NODE_FN (nat44_ed_out2in_reass_node) (vlib_main_t * vm, next0 = NAT44_ED_OUT2IN_NEXT_IN2OUT; goto trace0; } - create_bypass_for_fwd (sm, ip0, rx_fib_index0, - thread_index); + if (sm->num_workers > 1) + create_bypass_for_fwd_worker (sm, ip0, + rx_fib_index0); + else + create_bypass_for_fwd (sm, ip0, rx_fib_index0, + thread_index); reass0->flags |= NAT_REASS_FLAG_ED_DONT_TRANSLATE; nat_ip4_reass_get_frags (reass0, &fragments_to_loopback); |