From 7eb3237936d87bb428a9189a7efa7e745cf5130f Mon Sep 17 00:00:00 2001 From: Spencer Sevilla Date: Tue, 16 Jan 2024 16:51:40 -0800 Subject: [PATCH] [mme] handle second s1ap setup as reset (#87) --- lib/gtp/xact.h | 1 + src/mme/mme-gtp-path.c | 6 ++++-- src/mme/mme-s11-handler.c | 3 ++- src/mme/s1ap-handler.c | 10 ++++++++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/lib/gtp/xact.h b/lib/gtp/xact.h index 5bb25242b2..1df7e0fbc7 100644 --- a/lib/gtp/xact.h +++ b/lib/gtp/xact.h @@ -112,6 +112,7 @@ typedef struct ogs_gtp_xact_s { #define OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED 2 #define OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_ALL 3 #define OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_PARTIAL 4 +#define OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_S1_SETUPREQ 5 int release_action; #define OGS_GTP_DELETE_INDIRECT_HANDOVER_COMPLETE 1 diff --git a/src/mme/mme-gtp-path.c b/src/mme/mme-gtp-path.c index c1f4014f52..fa2f7c5c2b 100644 --- a/src/mme/mme-gtp-path.c +++ b/src/mme/mme-gtp-path.c @@ -554,7 +554,8 @@ void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action) mme_ue = enb_ue->mme_ue; if (mme_ue) { - if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED) { + if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED || + action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_S1_SETUPREQ) { /* * https://github.com/open5gs/open5gs/pull/1497 * @@ -585,7 +586,8 @@ void mme_gtp_send_release_all_ue_in_enb(mme_enb_t *enb, int action) enb_ue->enb_ue_s1ap_id, enb_ue->mme_ue_s1ap_id, action); if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED || - action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_ALL) { + action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_RESET_ALL || + action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_S1_SETUPREQ) { enb_ue_remove(enb_ue); } else { /* At this point, it does not support other action */ diff --git a/src/mme/mme-s11-handler.c b/src/mme/mme-s11-handler.c index 1f5eea95fd..bc0b428311 100644 --- a/src/mme/mme-s11-handler.c +++ b/src/mme/mme-s11-handler.c @@ -1330,7 +1330,8 @@ void mme_s11_handle_release_access_bearers_response( } else { ogs_error("ENB-S1 Context has already been removed"); } - } else if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED) { + } else if (action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_LO_CONNREFUSED || + action == OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_S1_SETUPREQ) { /* enb_ue_unlink() and enb_ue_remove() has already been executed. * So, there is no `enb_ue` context */ diff --git a/src/mme/s1ap-handler.c b/src/mme/s1ap-handler.c index 1258e13f7e..aa14ce9601 100644 --- a/src/mme/s1ap-handler.c +++ b/src/mme/s1ap-handler.c @@ -244,7 +244,17 @@ void s1ap_handle_s1_setup_request(mme_enb_t *enb, ogs_s1ap_message_t *message) stats_update_mme_enbs(); + if (enb->state.s1_setup_success == true) { + // we have already associated with this eNB in the past, so + // something happened. Per 36.413.8.7.3.1 we need to clear + // all associated UE contexts similar to a Reset procedure. + ogs_warn("eNB was previously associated. Clearing all associated UE contexts."); + + mme_gtp_send_release_all_ue_in_enb( + enb, OGS_GTP_RELEASE_S1_CONTEXT_REMOVE_BY_S1_SETUPREQ); + } enb->state.s1_setup_success = true; + r = s1ap_send_s1_setup_response(enb); ogs_expect(r == OGS_OK); ogs_assert(r != OGS_ERROR);