From 51669d73a06eb565f2e8e0c11faa836dad8a12fb Mon Sep 17 00:00:00 2001 From: Bostjan Meglic <103102696+bmeglicit@users.noreply.github.com> Date: Tue, 6 Sep 2022 12:47:42 +0200 Subject: [PATCH] [AMF] Accept Deregistration Notification from UDM only for registered UE (#1737) Add additional check when receiving Deregistration Notification from UDM. UE should already be in registered state before accepting the request and deregistering the UE. Also add additional check that PCF association policy exists before sending a delete request to PCF. --- src/amf/namf-handler.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/amf/namf-handler.c b/src/amf/namf-handler.c index 552baaf4c..0aebec6c6 100644 --- a/src/amf/namf-handler.c +++ b/src/amf/namf-handler.c @@ -565,7 +565,8 @@ int amf_namf_callback_handle_dereg_notify( */ - if (CM_CONNECTED(amf_ue)) + if ((CM_CONNECTED(amf_ue)) && + (OGS_FSM_CHECK(&amf_ue->sm, gmm_state_registered))) { amf_ue->network_initiated_de_reg = true; @@ -575,11 +576,14 @@ int amf_namf_callback_handle_dereg_notify( amf_sbi_send_release_all_sessions( amf_ue, AMF_RELEASE_SM_CONTEXT_NO_STATE); - if (ogs_list_count(&amf_ue->sess_list) == 0) + if ((ogs_list_count(&amf_ue->sess_list) == 0) && + (PCF_AM_POLICY_ASSOCIATED(amf_ue))) + { ogs_assert(true == amf_ue_sbi_discover_and_send( OGS_SBI_SERVICE_TYPE_NPCF_AM_POLICY_CONTROL, NULL, amf_npcf_am_policy_control_build_delete, amf_ue, NULL)); + } OGS_FSM_TRAN(&amf_ue->sm, &gmm_state_de_registered); } @@ -587,6 +591,11 @@ int amf_namf_callback_handle_dereg_notify( /* TODO: need to page UE */ /*ngap_send_paging(amf_ue);*/ } + else { + status = OGS_SBI_HTTP_STATUS_BAD_REQUEST; + ogs_error("[%s] Deregistration notification for UE in wrong state", amf_ue->supi); + goto cleanup; + } cleanup: memset(&sendmsg, 0, sizeof(sendmsg));