From e4deacc4220511c5ee93eca6b059d2a64ab1d36c Mon Sep 17 00:00:00 2001 From: Klement Sekera Date: Mon, 27 Apr 2020 08:19:12 +0000 Subject: nat: fix coverity warning Type: fix Signed-off-by: Klement Sekera Change-Id: I609fef6f96c6a3fc85a4dc07e75244b0e1ba9239 --- src/plugins/nat/in2out_ed.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) (limited to 'src/plugins/nat/in2out_ed.c') diff --git a/src/plugins/nat/in2out_ed.c b/src/plugins/nat/in2out_ed.c index f0bbe0b656e..21ef75c820c 100644 --- a/src/plugins/nat/in2out_ed.c +++ b/src/plugins/nat/in2out_ed.c @@ -296,7 +296,6 @@ slow_path_ed (snat_main_t * sm, nat_outside_fib_t *outside_fib; fib_node_index_t fei = FIB_NODE_INDEX_INVALID; clib_bihash_kv_16_8_t out2in_ed_kv; - bool out2in_ed_inserted = false; ip4_address_t allocated_addr; u16 allocated_port; u8 identity_nat; @@ -346,7 +345,7 @@ slow_path_ed (snat_main_t * sm, { nat_elog_warn ("create NAT session failed"); b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_USER_SESS_EXCEEDED]; - goto drop; + return NAT_NEXT_DROP; } switch (vec_len (sm->outside_fibs)) { @@ -384,10 +383,10 @@ slow_path_ed (snat_main_t * sm, { nat_elog_notice ("addresses exhausted"); b->error = node->errors[NAT_IN2OUT_ED_ERROR_OUT_OF_PORTS]; - goto drop; + nat_free_session_data (sm, s, thread_index, 0); + nat44_ed_delete_session (sm, s, thread_index, 1); + return NAT_NEXT_DROP; } - - out2in_ed_inserted = true; key1.addr = allocated_addr; key1.port = allocated_port; } @@ -403,7 +402,7 @@ slow_path_ed (snat_main_t * sm, { nat_elog_warn ("create NAT session failed"); b->error = node->errors[NAT_IN2OUT_ED_ERROR_MAX_USER_SESS_EXCEEDED]; - goto drop; + return NAT_NEXT_DROP; } switch (vec_len (sm->outside_fibs)) { @@ -441,7 +440,6 @@ slow_path_ed (snat_main_t * sm, (&tsm->out2in_ed, &out2in_ed_kv, nat44_o2i_ed_is_idle_session_cb, &ctx)) nat_elog_notice ("out2in-ed key add failed"); - out2in_ed_inserted = true; } if (lb) @@ -487,18 +485,6 @@ slow_path_ed (snat_main_t * sm, thread_index, 0); return next; -drop: - if (out2in_ed_inserted) - { - if (clib_bihash_add_del_16_8 (&tsm->out2in_ed, &out2in_ed_kv, 0)) - nat_elog_notice ("out2in-ed key del failed"); - } - if (s) - { - nat_free_session_data (sm, s, thread_index, 0); - nat44_ed_delete_session (sm, s, thread_index, 1); - } - return NAT_NEXT_DROP; } static_always_inline int -- cgit 1.2.3-korg