Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(amf): Registration reject handling for mismatching plmn #12733

Merged
merged 1 commit into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
30 changes: 30 additions & 0 deletions lte/gateway/c/core/oai/tasks/amf/amf_recv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,36 @@ int amf_handle_registration_request(
* Extract the SUPI from SUCI directly as scheme is NULL */
if (msg->m5gs_mobile_identity.mobile_identity.imsi.type_of_identity ==
M5GSMobileIdentityMsg_SUCI_IMSI) {
bool is_plmn_present = false;
for (uint8_t i = 0; i < amf_config.guamfi.nb; i++) {
if ((msg->m5gs_mobile_identity.mobile_identity.imsi.mcc_digit2 ==
amf_config.guamfi.guamfi[i].plmn.mcc_digit2) &&
(msg->m5gs_mobile_identity.mobile_identity.imsi.mcc_digit1 ==
amf_config.guamfi.guamfi[i].plmn.mcc_digit1) &&
(msg->m5gs_mobile_identity.mobile_identity.imsi.mnc_digit3 ==
amf_config.guamfi.guamfi[i].plmn.mnc_digit3) &&
(msg->m5gs_mobile_identity.mobile_identity.imsi.mcc_digit3 ==
amf_config.guamfi.guamfi[i].plmn.mcc_digit3) &&
(msg->m5gs_mobile_identity.mobile_identity.imsi.mnc_digit2 ==
amf_config.guamfi.guamfi[i].plmn.mnc_digit2) &&
(msg->m5gs_mobile_identity.mobile_identity.imsi.mnc_digit1 ==
amf_config.guamfi.guamfi[i].plmn.mnc_digit1)) {
is_plmn_present = true;
}
}
if (!is_plmn_present) {
delete params;
amf_cause = AMF_CAUSE_INVALID_MANDATORY_INFO;
OAILOG_ERROR(LOG_NAS_AMF,
"UE PLMN mismatch"
"AMF rejecting the initial registration with "
"cause : %d for UE "
"ID: " AMF_UE_NGAP_ID_FMT,
amf_cause, ue_id);
rc = amf_proc_registration_reject(ue_id, amf_cause);
amf_free_ue_context(ue_context);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
}
// Only considering protection scheme as NULL else return error.
if (msg->m5gs_mobile_identity.mobile_identity.imsi.protect_schm_id ==
MOBILE_IDENTITY_PROTECTION_SCHEME_NULL) {
Expand Down
22 changes: 22 additions & 0 deletions lte/gateway/c/core/oai/test/amf/test_amf_procedures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,10 @@ class AMFAppProcedureTest : public ::testing::Test {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x2e,
0x08, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};

const uint8_t initial_ue_plmn_mismatch_message_hexbuf[23] = {
0x7e, 0x00, 0x41, 0x79, 0x00, 0x0d, 0x01, 0x00, 0x91, 0x10, 0xf0, 0xff,
0x00, 0x00, 0x79, 0x56, 0x54, 0x66, 0xf4, 0x2e, 0x02, 0xf0, 0xf0};

/* Guti based initial registration message */
const uint8_t guti_initial_ue_message_hexbuf[98] = {
0x7e, 0x01, 0x67, 0xb7, 0x6f, 0xc6, 0x03, 0x7e, 0x00, 0x41, 0x09,
Expand Down Expand Up @@ -393,6 +397,24 @@ TEST_F(AMFAppProcedureTest, TestRegistrationAuthSecurityCapabilityMismatch) {
EXPECT_TRUE(ue_context_p == nullptr);
}

TEST_F(AMFAppProcedureTest, TestRegistrationPlmnMismatch) {
amf_ue_ngap_id_t ue_id = 0;
std::vector<MessagesIds> expected_Ids{
AMF_APP_NGAP_AMF_UE_ID_NOTIFICATION, // new registration notification
// indication to ngap
NGAP_NAS_DL_DATA_REQ, // Registration Reject
NGAP_UE_CONTEXT_RELEASE_COMMAND // UEContextReleaseCommand
};
/* Send the initial UE message */
imsi64_t imsi64 = 0;
imsi64 = send_initial_ue_message_no_tmsi(
amf_app_desc_p, 36, 1, 1, 0, plmn,
initial_ue_plmn_mismatch_message_hexbuf,
sizeof(initial_ue_plmn_mismatch_message_hexbuf));
EXPECT_EQ(get_ue_id_from_imsi(amf_app_desc_p, imsi64, &ue_id), 0);
EXPECT_TRUE(expected_Ids == AMFClientServicer::getInstance().msgtype_stack);
}
Sathyaj27 marked this conversation as resolved.
Show resolved Hide resolved

TEST_F(AMFAppProcedureTest, TestRegistrationProcNoTMSI) {
amf_ue_ngap_id_t ue_id = 0;
std::vector<MessagesIds> expected_Ids{
Expand Down
7 changes: 7 additions & 0 deletions lte/gateway/c/core/oai/test/amf/test_amf_stateless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,13 @@ class AMFAppStatelessTest : public ::testing::Test {
amf_config.use_stateless = true;
amf_nas_state_init(&amf_config);
create_state_matrix();
amf_config.guamfi.nb = 1;
amf_config.guamfi.guamfi[0].plmn = {.mcc_digit2 = 2,
.mcc_digit1 = 2,
.mnc_digit3 = 6,
.mcc_digit3 = 2,
.mnc_digit2 = 5,
.mnc_digit1 = 4};

init_task_context(TASK_MAIN, nullptr, 0, NULL, &amf_app_task_zmq_ctx);

Expand Down