From 13c08184c3fb77a54e8d7e46cb45f091cc71fcc3 Mon Sep 17 00:00:00 2001 From: Matus Fabian Date: Wed, 11 Apr 2018 00:36:57 -0700 Subject: NAT44: fix setting of flag SNAT_SESSION_FLAG_LOAD_BALANCING (VPP-1235) Change-Id: Ieeafb41d10959700bfd434cd455800af31944150 Signed-off-by: Matus Fabian --- src/plugins/nat/nat.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src/plugins/nat/nat.c') diff --git a/src/plugins/nat/nat.c b/src/plugins/nat/nat.c index 48535d9be0a..96a69282077 100755 --- a/src/plugins/nat/nat.c +++ b/src/plugins/nat/nat.c @@ -1063,9 +1063,9 @@ int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, (clib_net_to_host_u16 (s->out2in.port) != e_port)) continue; } - - if (s->flags & SNAT_SESSION_FLAG_LOAD_BALANCING) - continue; + + if (is_lb_session (s)) + continue; nat_free_session_data (sm, s, tsm - sm->per_thread_data); clib_dlist_remove (tsm->list_pool, s->per_user_index); @@ -1391,6 +1391,9 @@ int nat44_add_del_lb_static_mapping (ip4_address_t e_addr, u16 e_port, elt = pool_elt_at_index (tsm->list_pool, elt->next); ses_index = elt->value; + if (!(is_lb_session (s))) + continue; + if ((s->in2out.addr.as_u32 != local->addr.as_u32) && (clib_net_to_host_u16 (s->in2out.port) != local->port)) continue; @@ -1966,6 +1969,7 @@ void snat_free_outside_address_and_port (snat_address_t * addresses, * address. * @param is_addr_only If matched mapping is address only * @param twice_nat If matched mapping is twice NAT. + * @param lb If matched mapping is load-balanced. * * @returns 0 if match found otherwise 1. */ @@ -1974,7 +1978,8 @@ int snat_static_mapping_match (snat_main_t * sm, snat_session_key_t * mapping, u8 by_external, u8 *is_addr_only, - u8 *twice_nat) + u8 *twice_nat, + u8 *lb) { clib_bihash_kv_8_8_t kv, value; snat_static_mapping_t *m; @@ -2045,6 +2050,9 @@ int snat_static_mapping_match (snat_main_t * sm, if (PREDICT_FALSE(twice_nat != 0)) *twice_nat = m->twice_nat; + if (PREDICT_FALSE(lb != 0)) + *lb = vec_len (m->locals) > 0; + return 0; } -- cgit 1.2.3-korg