From 74bc3497052e9f39a94ce8e5e0245c65b5dda8c3 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 91c840f2ce..4457d82297 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 21f788b6b8..dec42e66b6 100644 --- a/src/mme/mme-gtp-path.c +++ b/src/mme/mme-gtp-path.c @@ -543,7 +543,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 * @@ -574,7 +575,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 8db6f02087..4982d80c17 100644 --- a/src/mme/mme-s11-handler.c +++ b/src/mme/mme-s11-handler.c @@ -1350,7 +1350,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 7827c2072a..949580f800 100644 --- a/src/mme/s1ap-handler.c +++ b/src/mme/s1ap-handler.c @@ -195,7 +195,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);