Skip to content

Commit

Permalink
Addressed review comment (R2)
Browse files Browse the repository at this point in the history
Signed-off-by: RahulKalsangra <rahul.kalsangra@wavelabs.ai>
  • Loading branch information
RahulKalsangra committed Mar 16, 2022
1 parent 1342c76 commit 1b098d0
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 49 deletions.
31 changes: 22 additions & 9 deletions lte/gateway/c/core/oai/tasks/amf/amf_authentication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ static int start_authentication_information_procedure(

rc = amf_authentication_request_sent(ue_id);
if (rc != RETURNok) {
OAILOG_WARNING(LOG_NAS_AMF,
"AMF-PROC - Failed authentication request for ue_id "
"= " AMF_UE_NGAP_ID_FMT "\n",
ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
}

OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNok);
}

int amf_authentication_request_sent(amf_ue_ngap_id_t ue_id) {
status_code_e amf_authentication_request_sent(amf_ue_ngap_id_t ue_id) {
ue_m5gmm_context_s* ue_mm_context = nullptr;
amf_context_t* amf_context = nullptr;
char imsi_str[IMSI_BCD_DIGITS_MAX + 1];
Expand All @@ -137,28 +141,37 @@ int amf_authentication_request_sent(amf_ue_ngap_id_t ue_id) {
uint8_t snni[40] = {0};
if (!ue_mm_context) {
OAILOG_WARNING(LOG_NAS_AMF,
"AMF-PROC - Failed authentication request the UE due to NULL"
"ue_context\n");
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
"AMF-PROC - Failed authentication request for UE ID "
"= " AMF_UE_NGAP_ID_FMT
"due to NULL"
"ue_context\n",
ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
amf_context = &ue_mm_context->amf_context;
if (!amf_context) {
OAILOG_WARNING(LOG_NAS_AMF,
"AMF-PROC - Failed authentication request for UE ID "
"= " AMF_UE_NGAP_ID_FMT
"due to NULL"
"amf_context\n",
ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
nas5g_amf_auth_proc_t* auth_proc =
get_nas5g_common_procedure_authentication(amf_context);

if (!auth_proc) {
OAILOG_WARNING(LOG_NAS_AMF, "authentication procedure not present\n");
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
IMSI64_TO_STRING(amf_context->imsi64, imsi_str, IMSI_LENGTH);

rc = calculate_amf_serving_network_name(amf_context, snni);
if (rc != RETURNok) {
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}

nas5g_auth_info_proc_t* auth_info_proc =
get_nas5g_cn_procedure_auth_info(amf_context);
auth_info_proc->request_sent = true;
if (!(auth_proc->auts.data)) {
OAILOG_INFO(LOG_AMF_APP,
"Sending msg(grpc) to :[subscriberdb] for ue: [%s] auth-info\n",
Expand Down
2 changes: 1 addition & 1 deletion lte/gateway/c/core/oai/tasks/amf/amf_authentication.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ int amf_send_authentication_request(amf_context_t* amf_context,

// To be called when authentication is successful from subscriberdb
int amf_authentication_proc_success(amf_context_t* amf_context);
int amf_authentication_request_sent(amf_ue_ngap_id_t ue_id);
status_code_e amf_authentication_request_sent(amf_ue_ngap_id_t ue_id);
int amf_nas_proc_authentication_info_answer(itti_amf_subs_auth_info_ans_t* aia);
nas5g_amf_auth_proc_t* get_nas5g_common_procedure_authentication(
const amf_context_t* const ctxt);
Expand Down
44 changes: 35 additions & 9 deletions lte/gateway/c/core/oai/tasks/amf/nas_proc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,20 +422,41 @@ static int subs_auth_retry(zloop_t* loop, int timer_id, void* arg) {
int rc = RETURNerror;
ue_m5gmm_context_s* ue_mm_context = nullptr;
if (!amf_pop_timer_arg(timer_id, &ue_id)) {
OAILOG_WARNING(
LOG_AMF_APP,
"auth_retry_timer: Invalid Timer Id expiration, Timer Id: %d \n",
timer_id);
OAILOG_WARNING(LOG_AMF_APP,
"auth_retry_timer: Invalid Timer Id expiration, Timer Id: "
"%d and UE id: " AMF_UE_NGAP_ID_FMT "\n",
timer_id, ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNok);
}
ue_mm_context = amf_ue_context_exists_amf_ue_ngap_id(ue_id);
if (!ue_mm_context) {
OAILOG_WARNING(
LOG_NAS_AMF,
"AMF-PROC - Failed authentication request for UE id " AMF_UE_NGAP_ID_FMT
"due to NULL"
"ue_context\n",
ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
amf_ctxt_p = &ue_mm_context->amf_context;
if (!amf_ctxt_p) {
OAILOG_WARNING(LOG_NAS_AMF,
"AMF-PROC - Failed authentication request for UE "
"id= " AMF_UE_NGAP_ID_FMT
"due to NULL"
"amf_ctxt_p\n",
ue_id);
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
if (amf_ctxt_p->auth_retry_count < amf_config.auth_retry_max_count) {
amf_ctxt_p->auth_retry_count++;
OAILOG_INFO(LOG_AMF_APP,
"auth_retry_timer: Incrementing auth_retry_count to %u\n",
amf_ctxt_p->auth_retry_count);
rc = amf_authentication_request_sent(ue_id);
if (rc != RETURNok) {
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
amf_ctxt_p->auth_retry_timer.id =
amf_app_start_timer(amf_config.auth_retry_interval, TIMER_REPEAT_ONCE,
subs_auth_retry, ue_id);
Expand All @@ -444,18 +465,21 @@ static int subs_auth_retry(zloop_t* loop, int timer_id, void* arg) {
OAILOG_ERROR(
LOG_NAS_AMF,
"auth_retry_timer is expired . Authentication reject with cause "
"AMF_UE_ILLEGAL\n");
"AMF_UE_ILLEGAL for ue_id " AMF_UE_NGAP_ID_FMT "\n",
ue_id);
amf_cause = AMF_UE_ILLEGAL;

rc = amf_proc_registration_reject(ue_id, amf_cause);
if (rc != RETURNok) {
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNerror);
}
if (auth_info_proc) {
nas5g_delete_cn_procedure(amf_ctxt_p, &auth_info_proc->cn_proc);
}

amf_free_ue_context(ue_mm_context);
}

return rc;
OAILOG_FUNC_RETURN(LOG_NAS_AMF, RETURNok);
}

int amf_nas_proc_authentication_info_answer(
Expand Down Expand Up @@ -494,7 +518,9 @@ int amf_nas_proc_authentication_info_answer(
if (aia->auth_info.nb_of_vectors) {
nas5g_amf_auth_proc_t* auth_proc =
get_nas5g_common_procedure_authentication(amf_ctxt_p);
free_wrapper(reinterpret_cast<void**>(&auth_proc->auts.data));
if (auth_proc) {
free_wrapper(reinterpret_cast<void**>(&auth_proc->auts.data));
}
if ((NAS5G_TIMER_INACTIVE_ID != amf_ctxt_p->auth_retry_timer.id) &&
(0 != amf_ctxt_p->auth_retry_timer.id)) {
OAILOG_DEBUG(LOG_NAS_AMF, "Stopping: Timer auth_retry_timer.\n");
Expand Down Expand Up @@ -539,7 +565,7 @@ int amf_nas_proc_authentication_info_answer(
nas5g_delete_cn_procedure(amf_ctxt_p, &auth_info_proc->cn_proc);
}
amf_free_ue_context(ue_5gmm_context_p);
return rc;
OAILOG_FUNC_RETURN(LOG_NAS_AMF, rc);
} else {
amf_ctxt_p->auth_retry_timer.id =
amf_app_start_timer(amf_config.auth_retry_interval, TIMER_REPEAT_ONCE,
Expand Down
3 changes: 3 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 @@ -1720,8 +1720,11 @@ TEST_F(AMFAppProcedureTest, TestAuthFailureFromSubscribeDbLock) {
rc = amf_nas_proc_authentication_info_answer(&aia_itti_msg);
EXPECT_TRUE(rc == RETURNok);
ue_context_p = amf_ue_context_exists_amf_ue_ngap_id(ue_id);
EXPECT_NE(ue_context_p, nullptr);
amf_ctxt_p = &ue_context_p->amf_context;
EXPECT_NE(amf_ctxt_p, nullptr);
auth_info_proc = get_nas5g_cn_procedure_auth_info(amf_ctxt_p);
EXPECT_NE(auth_info_proc, nullptr);
nas5g_delete_cn_procedure(amf_ctxt_p, &auth_info_proc->cn_proc);
amf_free_ue_context(ue_context_p);
}
Expand Down
46 changes: 16 additions & 30 deletions lte/gateway/python/scripts/generate_oai_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,47 +333,33 @@ def _get_amf_name_config(service_mconfig: object) -> str:
return service_mconfig.amf_name or DEFAULT_NGAP_AMF_NAME


def _get_default_auth_retry_count(service_mconfig: object) -> str:
def _get_default_auth_retry_count() -> str:
"""
Retrieve default_auth_retry_count config value. If it does not
exist, it defaults to DEFAULT_AUTH_RETRY_COUNT.
Args:
service_mconfig: This is a configuration placeholder for mme.
Retrieve default_auth_retry_count config
value. If it does not exist, it defaults
to DEFAULT_AUTH_RETRY_COUNT.
Returns:
default default auth retry count.
default auth retry count.
"""
enable_default_auth_retry_count_config = get_service_config_value(
'mme', 'auth_retry_max_count', None,
return get_service_config_value(
'mme', 'auth_retry_max_count', DEFAULT_AUTH_RETRY_COUNT,
)

if enable_default_auth_retry_count_config is not None:
return enable_default_auth_retry_count_config

return DEFAULT_AUTH_RETRY_COUNT


def _get_default_auth_timer_expire_msec(service_mconfig: object) -> str:
def _get_default_auth_timer_expire_msec() -> str:
"""
Retrieve default_auth_retry_timer_expire_msec config value. If it
does not exist, it defaults to DEFAULT_AUTH_TIMER_EXPIRE_MSEC.
Args:
service_mconfig: This is a configuration placeholder for mme.
Retrieve default_auth_retry_timer_expire_msec
config value. If it does not exist, it defaults
to DEFAULT_AUTH_TIMER_EXPIRE_MSEC.
Returns:
default default auth timer expire msec.
default auth timer expire msec.
"""
enable_default_auth_timer_expire_config = get_service_config_value(
'mme', 'auth_retry_interval', None,
return get_service_config_value(
'mme', 'auth_retry_interval', DEFAULT_AUTH_TIMER_EXPIRE_MSEC,
)

if enable_default_auth_timer_expire_config is not None:
return enable_default_auth_timer_expire_config

return DEFAULT_AUTH_TIMER_EXPIRE_MSEC


def _get_default_dnn_config(service_mconfig: object) -> str:
"""Retrieve default_dnn config value. If it does not exist, it defaults to DEFAULT_DEFAULT_DNN.
Expand Down Expand Up @@ -513,8 +499,8 @@ def _get_context():
"amf_set_id": _get_amf_set_id(mme_service_config),
"amf_pointer": _get_amf_pointer(mme_service_config),
"default_dnn": _get_default_dnn_config(mme_service_config),
"auth_retry_max_count": _get_default_auth_retry_count(mme_service_config),
"auth_retry_interval": _get_default_auth_timer_expire_msec(mme_service_config),
"auth_retry_max_count": _get_default_auth_retry_count(),
"auth_retry_interval": _get_default_auth_timer_expire_msec(),
}

context["s1u_ip"] = mme_service_config.ipv4_sgw_s1u_addr or _get_iface_ip(
Expand Down

0 comments on commit 1b098d0

Please sign in to comment.