From: Benoît Ganne Date: Thu, 22 Dec 2022 14:01:21 +0000 (+0100) Subject: nat: do not use nat session object after deletion X-Git-Tag: v23.06-rc0~34 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=f06a518f8b768c49301414cbeefb19020071fd1d;p=vpp.git nat: do not use nat session object after deletion Type: fix Change-Id: Ifc709b6e7217a893d13aee6d3019e699637366ef Signed-off-by: Benoît Ganne --- diff --git a/src/plugins/nat/nat44-ed/nat44_ed_in2out.c b/src/plugins/nat/nat44-ed/nat44_ed_in2out.c index 61ce70f357f..f41fcac5153 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_in2out.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_in2out.c @@ -1194,6 +1194,7 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t *vm, // session is closed, go slow path nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = def_slow; goto trace0; } @@ -1206,6 +1207,7 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t *vm, { nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; // session is closed, go slow path next[0] = def_slow; goto trace0; @@ -1227,6 +1229,7 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t *vm, translation_error = NAT_ED_TRNSL_ERR_FLOW_MISMATCH; nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED]; goto trace0; @@ -1238,6 +1241,7 @@ nat44_ed_in2out_fast_path_node_fn_inline (vlib_main_t *vm, { nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED]; goto trace0; @@ -1395,6 +1399,7 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, { nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED]; goto trace0; @@ -1418,6 +1423,7 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, { nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED]; goto trace0; @@ -1496,6 +1502,7 @@ nat44_ed_in2out_slow_path_node_fn_inline (vlib_main_t *vm, { nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_IN2OUT_ED_ERROR_TRNSL_FAILED]; goto trace0; diff --git a/src/plugins/nat/nat44-ed/nat44_ed_out2in.c b/src/plugins/nat/nat44-ed/nat44_ed_out2in.c index dfe4a15752b..fe4a41c5e08 100644 --- a/src/plugins/nat/nat44-ed/nat44_ed_out2in.c +++ b/src/plugins/nat/nat44-ed/nat44_ed_out2in.c @@ -881,6 +881,7 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, // session is closed, go slow path nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; slow_path_reason = NAT_ED_SP_REASON_VRF_EXPIRED; next[0] = NAT_NEXT_OUT2IN_ED_SLOW_PATH; goto trace0; @@ -895,6 +896,7 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, // session is closed, go slow path nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; slow_path_reason = NAT_ED_SP_SESS_EXPIRED; next[0] = NAT_NEXT_OUT2IN_ED_SLOW_PATH; goto trace0; @@ -943,6 +945,7 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm, translation_error = NAT_ED_TRNSL_ERR_FLOW_MISMATCH; nat44_ed_free_session_data (sm, s0, thread_index, 0); nat_ed_session_delete (sm, s0, thread_index, 1); + s0 = 0; next[0] = NAT_NEXT_DROP; b0->error = node->errors[NAT_OUT2IN_ED_ERROR_TRNSL_FAILED]; goto trace0;