Merge remote-tracking branch 'origin/bugfix-ngap-amf-selection' into integration_2025_w24 (!3474)

Fix AMF selection fallback by PLMN ID when no UE identity is present or matching

If a mask is present (i.e., not zero), AMF selection by PLMN ID may
still fail, causing the AMF selection process to skip the fallback
option, i.e. selection by PLMN ID, when no UE identity is available or
when no match is found.

This MR adds also warnings in case there's a match for the AMF is not
found.
This commit is contained in:
Robert Schmidt
2025-06-11 07:55:11 +02:00
2 changed files with 31 additions and 14 deletions
+16 -14
View File
@@ -112,24 +112,26 @@ static ngap_gNB_amf_data_t *select_amf(ngap_gNB_instance_t *instance_p, const ng
}
// No UE identity (5G-S-TMSI or GUAMI) is present
if (msg->ue_identity.presenceMask == 0) {
// Select the AMF based on the selected PLMN identity received through RRCSetupComplete
amf = ngap_gNB_nnsf_select_amf_by_plmn_id(instance_p, msg->establishment_cause, msg->plmn);
// Select the AMF based on the selected PLMN identity received through RRCSetupComplete
amf = ngap_gNB_nnsf_select_amf_by_plmn_id(instance_p, msg->establishment_cause, msg->plmn);
if (amf) {
NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through selected PLMN MCC=%03d MNC=%0*d\n",
msg->gNB_ue_ngap_id,
amf->amf_name,
amf->assoc_id,
msg->plmn.mcc,
msg->plmn.mnc_digit_length,
msg->plmn.mnc);
return amf;
} else {
// Select the AMF with the highest capacity
amf = ngap_gNB_nnsf_select_amf(instance_p, msg->establishment_cause);
if (amf) {
NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through selected PLMN MCC %d MNC %d\n",
NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through highest relative capacity\n",
msg->gNB_ue_ngap_id,
amf->amf_name,
amf->assoc_id,
msg->plmn.mcc,
msg->plmn.mnc);
amf->assoc_id);
return amf;
} else {
// Select the AMF with the highest capacity
amf = ngap_gNB_nnsf_select_amf(instance_p, msg->establishment_cause);
if (amf) {
NGAP_INFO("UE %d: Chose AMF '%s' (assoc_id %d) through highest relative capacity\n", msg->gNB_ue_ngap_id, amf->amf_name, amf->assoc_id);
return amf;
}
}
}
+15
View File
@@ -30,6 +30,7 @@
#include "ngap_gNB_nnsf.h"
#include <stdio.h>
#include "ngap_gNB_defs.h"
#include "ngap_common.h"
#include "queue.h"
#include "tree.h"
@@ -222,6 +223,12 @@ ngap_gNB_amf_data_t *ngap_gNB_nnsf_select_amf_by_amf_setid(ngap_gNB_instance_t *
}
}
NGAP_WARN("No matching AMF found for PLMN (MCC=%03d MNC=%0*d) and AMF SetID=%u\n",
selected_plmn_identity.mcc,
selected_plmn_identity.mnc_digit_length,
selected_plmn_identity.mnc,
amf_setid);
/* At this point no AMF matches the selected PLMN and AMF code. In this case,
* return NULL. That way the RRC layer should know about it and reject RRC
* connectivity. */
@@ -314,6 +321,14 @@ ngap_gNB_amf_data_t *ngap_gNB_nnsf_select_amf_by_guami(ngap_gNB_instance_t *inst
}
}
NGAP_WARN("No matching AMF found for GUAMI (MCC=%03d MNC=%0*d RegionID=%d SetID=%d Pointer=%d)\n",
guami.mcc,
guami.mnc_len,
guami.mnc,
guami.amf_region_id,
guami.amf_set_id,
guami.amf_pointer);
/* At this point no AMF matches the provided GUAMI. In this case, return
* NULL. That way the RRC layer should know about it and reject RRC
* connectivity. */