From 7f9afa02134e96317684e0b59a3c12cd4b72bb8d Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sun, 8 Jan 2023 20:02:18 +0900 Subject: [PATCH] [AMF] More Follow-up on #1987 --- lib/core/ogs-timer.c | 6 +++++ lib/core/ogs-timer.h | 2 ++ src/amf/amf-sm.c | 12 ++++++++++ src/amf/context.c | 12 ---------- src/amf/gmm-sm.c | 52 +++++++++++++++++++++++++++--------------- src/amf/namf-handler.c | 38 ++++++++++++++++++------------ src/amf/ngap-handler.c | 12 ++++++++++ src/amf/ngap-path.c | 25 ++------------------ 8 files changed, 91 insertions(+), 68 deletions(-) diff --git a/lib/core/ogs-timer.c b/lib/core/ogs-timer.c index 43a921ff8..56e63b06f 100644 --- a/lib/core/ogs-timer.c +++ b/lib/core/ogs-timer.c @@ -157,6 +157,12 @@ void ogs_timer_stop_debug(ogs_timer_t *timer, const char *file_line) ogs_rbtree_delete(&manager->tree, timer); } +bool ogs_timer_running(ogs_timer_t *timer) +{ + ogs_assert(timer); + return timer->running; +} + ogs_time_t ogs_timer_mgr_next(ogs_timer_mgr_t *manager) { ogs_time_t current; diff --git a/lib/core/ogs-timer.h b/lib/core/ogs-timer.h index f38b208a3..ca017700d 100644 --- a/lib/core/ogs-timer.h +++ b/lib/core/ogs-timer.h @@ -58,6 +58,8 @@ void ogs_timer_start_debug( ogs_timer_stop_debug(timer, OGS_FILE_LINE) void ogs_timer_stop_debug(ogs_timer_t *timer, const char *file_line); +bool ogs_timer_running(ogs_timer_t *timer); + ogs_time_t ogs_timer_mgr_next(ogs_timer_mgr_t *manager); void ogs_timer_mgr_expire(ogs_timer_mgr_t *manager); diff --git a/src/amf/amf-sm.c b/src/amf/amf-sm.c index 6bb70ff1c..6a68da658 100644 --- a/src/amf/amf-sm.c +++ b/src/amf/amf-sm.c @@ -877,6 +877,18 @@ void amf_state_operational(ogs_fsm_t *s, amf_event_t *e) NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); } amf_ue_associate_ran_ue(amf_ue, ran_ue); + + /* + * TS 24.501 + * 5.3.7 Handling of the periodic registration update timer + * + * The mobile reachable timer shall be stopped + * when a NAS signalling connection is established for the UE. + * The implicit de-registration timer shall be stopped + * when a NAS signalling connection is established for the UE. + */ + CLEAR_AMF_UE_TIMER(amf_ue->mobile_reachable); + CLEAR_AMF_UE_TIMER(amf_ue->implicit_deregistration); } ogs_assert(amf_ue); diff --git a/src/amf/context.c b/src/amf/context.c index 3876ab1ce..7b6d5abd3 100644 --- a/src/amf/context.c +++ b/src/amf/context.c @@ -1843,18 +1843,6 @@ void amf_ue_associate_ran_ue(amf_ue_t *amf_ue, ran_ue_t *ran_ue) amf_ue->ran_ue = ran_ue; ran_ue->amf_ue = amf_ue; - - /* Clear mobile_reachable and implicit_deregistration Timers - * TS 24.501 - * 5.3.7 Handling of the periodic registration update timer and - * mobile reachable timer - * The mobile reachable timer shall be stopped when a NAS signalling - * connection is established for the UE. - * The implicit de-registration timer shall be stopped when a NAS - * signalling connection is established for the UE. - */ - CLEAR_AMF_UE_TIMER(amf_ue->mobile_reachable); - CLEAR_AMF_UE_TIMER(amf_ue->implicit_deregistration); } void ran_ue_deassociate(ran_ue_t *ran_ue) diff --git a/src/amf/gmm-sm.c b/src/amf/gmm-sm.c index 2ce777a94..893a9bab6 100644 --- a/src/amf/gmm-sm.c +++ b/src/amf/gmm-sm.c @@ -382,17 +382,10 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) } } - /* Clear Paging Info */ AMF_UE_CLEAR_PAGING_INFO(amf_ue); - - /* Clear N2 Transfer */ AMF_UE_CLEAR_N2_TRANSFER( amf_ue, pdu_session_resource_setup_request); - - /* Clear 5GSM Message */ AMF_UE_CLEAR_5GSM_MESSAGE(amf_ue); - - /* Clear t3513 Timers */ CLEAR_AMF_UE_TIMER(amf_ue->t3513); } else { @@ -437,37 +430,58 @@ void gmm_state_registered(ogs_fsm_t *s, amf_event_t *e) break; case AMF_TIMER_MOBILE_REACHABLE: - ogs_info("[%s] Mobile Reachable Timer Expired", amf_ue->supi); - /* Clear mobile_reachable Timers */ - CLEAR_AMF_UE_TIMER(amf_ue->mobile_reachable); - /* Start AMF_TIMER_IMPLICIT_DEREGISTRATION + + /* * TS 24.501 * 5.3.7 Handling of the periodic registration update timer and - * mobile reachable timer + * * Upon expiry of the mobile reachable timer the network shall * start the implicit de-registration timer over 3GPP access. * The default value of the implicit de-registration timer over * 3GPP access is 4 minutes greater than the value of timer T3512. */ + + ogs_warn("[%s] Mobile Reachable Timer Expired", amf_ue->supi); + + ogs_list_for_each(&amf_ue->sess_list, sess) { + if (sess->paging.ongoing == true && + sess->paging.n1n2_failure_txf_notif_uri != NULL) { + ogs_assert(true == + amf_sbi_send_n1_n2_failure_notify( + sess, + OpenAPI_n1_n2_message_transfer_cause_UE_NOT_REACHABLE_FOR_SESSION)); + } + } + + /* Stop Paging */ + AMF_UE_CLEAR_PAGING_INFO(amf_ue); + AMF_UE_CLEAR_N2_TRANSFER( + amf_ue, pdu_session_resource_setup_request); + AMF_UE_CLEAR_5GSM_MESSAGE(amf_ue); + CLEAR_AMF_UE_TIMER(amf_ue->t3513); + ogs_timer_start(amf_ue->implicit_deregistration.timer, ogs_time_from_sec(amf_self()->time.t3512.value + 240)); break; case AMF_TIMER_IMPLICIT_DEREGISTRATION: - ogs_info("[%s] Do Network-Initiated De-Register UE", amf_ue->supi); - /* Clear implicit_deregistration Timers */ - CLEAR_AMF_UE_TIMER(amf_ue->implicit_deregistration); - /* Implicitly de-register UE + + /* * TS 24.501 * 5.3.7 Handling of the periodic registration update timer and - * mobile reachable timer + * * If the implicit de-registration timer expires before the UE * contacts the network, the network shall implicitly de-register * the UE. + * * TS 23.502 * 4.2.2.3.3 Network-initiated Deregistration - * The AMF does not send the Deregistration Request message to the UE - * for Implicit Deregistration. + * + * The AMF does not send the Deregistration Request message + * to the UE for Implicit Deregistration. */ + + ogs_info("[%s] Do Network-initiated De-register UE", amf_ue->supi); + ogs_assert(true == amf_ue_sbi_discover_and_send( OGS_SBI_SERVICE_TYPE_NUDM_SDM, NULL, amf_nudm_sdm_build_subscription_delete, diff --git a/src/amf/namf-handler.c b/src/amf/namf-handler.c index 3821b66b8..3bfe368f9 100644 --- a/src/amf/namf-handler.c +++ b/src/amf/namf-handler.c @@ -272,16 +272,21 @@ int amf_namf_comm_handle_n1_n2_message_transfer( sendmsg.http.location = ogs_sbi_server_uri(server, &header); - /* Store Paging Info */ - AMF_SESS_STORE_PAGING_INFO( + if (ogs_timer_running( + amf_ue->implicit_deregistration.timer) == true) { + ogs_warn("[%s] Paging failed. Stop", amf_ue->supi); + } else { + /* Store Paging Info */ + AMF_SESS_STORE_PAGING_INFO( sess, sendmsg.http.location, N1N2MessageTransferReqData->n1n2_failure_txf_notif_uri); - /* Store N2 Transfer message */ - AMF_SESS_STORE_N2_TRANSFER( - sess, pdu_session_resource_setup_request, n2buf); + /* Store N2 Transfer message */ + AMF_SESS_STORE_N2_TRANSFER( + sess, pdu_session_resource_setup_request, n2buf); - ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + } } else if (CM_CONNECTED(amf_ue)) { ogs_assert(OGS_OK == @@ -331,16 +336,21 @@ int amf_namf_comm_handle_n1_n2_message_transfer( sendmsg.http.location = ogs_sbi_server_uri(server, &header); - /* Store Paging Info */ - AMF_SESS_STORE_PAGING_INFO( - sess, sendmsg.http.location, NULL); + if (ogs_timer_running( + amf_ue->implicit_deregistration.timer) == true) { + ogs_warn("[%s] Paging failed. Stop", amf_ue->supi); + } else { + /* Store Paging Info */ + AMF_SESS_STORE_PAGING_INFO( + sess, sendmsg.http.location, NULL); - /* Store 5GSM Message */ - AMF_SESS_STORE_5GSM_MESSAGE(sess, - OGS_NAS_5GS_PDU_SESSION_MODIFICATION_COMMAND, - n1buf, n2buf); + /* Store 5GSM Message */ + AMF_SESS_STORE_5GSM_MESSAGE(sess, + OGS_NAS_5GS_PDU_SESSION_MODIFICATION_COMMAND, + n1buf, n2buf); - ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + ogs_assert(OGS_OK == ngap_send_paging(amf_ue)); + } } else if (CM_CONNECTED(amf_ue)) { ogs_expect(OGS_OK == diff --git a/src/amf/ngap-handler.c b/src/amf/ngap-handler.c index e0275ee4b..69247ae3a 100644 --- a/src/amf/ngap-handler.c +++ b/src/amf/ngap-handler.c @@ -462,6 +462,18 @@ void ngap_handle_initial_ue_message(amf_gnb_t *gnb, ogs_ngap_message_t *message) NGAP_UE_CTX_REL_NG_CONTEXT_REMOVE, 0)); } amf_ue_associate_ran_ue(amf_ue, ran_ue); + + /* + * TS 24.501 + * 5.3.7 Handling of the periodic registration update timer + * + * The mobile reachable timer shall be stopped + * when a NAS signalling connection is established for the UE. + * The implicit de-registration timer shall be stopped + * when a NAS signalling connection is established for the UE. + */ + CLEAR_AMF_UE_TIMER(amf_ue->mobile_reachable); + CLEAR_AMF_UE_TIMER(amf_ue->implicit_deregistration); } } } diff --git a/src/amf/ngap-path.c b/src/amf/ngap-path.c index 36df0176f..44fee8ec0 100644 --- a/src/amf/ngap-path.c +++ b/src/amf/ngap-path.c @@ -369,29 +369,8 @@ int ngap_send_paging(amf_ue_t *amf_ue) int i, j; int rv; - if (amf_ue->implicit_deregistration.timer->running) { - /* Mobile Reachable timer has expired if implicit de-registration - * timer is running - * TS 24.501 - * 5.3.7 Handling of the periodic registration update timer and - * mobile reachable timer - * The network behaviour upon expiry of the mobile reachable timer - * is network dependent, but typically the network stops sending - * paging messages to the UE on the first expiry - */ - ogs_info("[%s] Paging ignored due to Mobile Reachable timer expiration", - amf_ue->supi); - /* Clear Paging Info */ - AMF_UE_CLEAR_PAGING_INFO(amf_ue); - - /* Clear N2 Transfer */ - AMF_UE_CLEAR_N2_TRANSFER( - amf_ue, pdu_session_resource_setup_request); - - /* Clear 5GSM Message */ - AMF_UE_CLEAR_5GSM_MESSAGE(amf_ue); - return OGS_OK; - } + ogs_assert(ogs_timer_running( + amf_ue->implicit_deregistration.timer) == false); ogs_list_for_each(&amf_self()->gnb_list, gnb) { for (i = 0; i < gnb->num_of_supported_ta_list; i++) {