Skip to content

Commit

Permalink
[mme] turn various asserts into checks with error-handling (#69)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencersevilla committed Jan 24, 2024
1 parent 7c00997 commit 1252568
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,6 @@ When a UPS re-associates itself with the CPS after a period of disconnectivity,

## Fine-Grained Timers
Stock open5gs has one configurable parameter (`message.duration`) which sets the timeout value for *all* messages sent or received by the program in question. We keep this parameter as the default, but have also added several different ones pertaining to each message protocol to allow us to have finer-grained control over these timers, which is highly recommended by the 3GPP. Specifically, `message.duration` has been supplemented by `message.sbi_duration`, `message.gtp_duration`, `message.pfcp_duration` and `message.diameter_timeout`.

## Stability Fixes
We have caught and fixed a large number of small bugs that threaten stability, generally asserts() that are not always true. Our team is firmly committed to contributing all such fixes to the main open5gs project, and these commits are either already upstreamed or will be soon.
46 changes: 32 additions & 14 deletions src/mme/mme-s11-handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,6 @@ void mme_s11_handle_create_session_response(
ogs_error("MME-UE Context has already been removed");
return;
}
source_ue = sgw_ue_cycle(mme_ue->sgw_ue);
ogs_assert(source_ue);

if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) {
target_ue = sgw_ue_cycle(source_ue->target_ue);
ogs_assert(target_ue);
} else {
target_ue = source_ue;
ogs_assert(target_ue);
}

/************************
* Getting Cause Value
Expand All @@ -155,6 +145,23 @@ void mme_s11_handle_create_session_response(
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}

source_ue = sgw_ue_cycle(mme_ue->sgw_ue);
if (!source_ue) {
ogs_error("Cannot find source_ue context");
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}

if (create_action == OGS_GTP_CREATE_IN_PATH_SWITCH_REQUEST) {
// if source_ue == null we'll catch below
if (source_ue) {
target_ue = sgw_ue_cycle(source_ue->target_ue);
ogs_assert(target_ue);
}
} else {
target_ue = source_ue;
// if source_ue == null we'll catch below
}

if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
if (create_action == OGS_GTP_CREATE_IN_ATTACH_REQUEST) {
ogs_error("[%s] Attach reject [Cause:%d]",
Expand Down Expand Up @@ -498,8 +505,6 @@ void mme_s11_handle_modify_bearer_response(
ogs_error("MME-UE Context has already been removed");
return;
}
sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
ogs_assert(sgw_ue);

/************************
* Getting Cause Value
Expand All @@ -521,6 +526,12 @@ void mme_s11_handle_modify_bearer_response(
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}

sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
if (!sgw_ue) {
ogs_error("Cannot find sgw_ue context");
cause_value = OGS_GTP2_CAUSE_CONTEXT_NOT_FOUND;
}

if (cause_value != OGS_GTP2_CAUSE_REQUEST_ACCEPTED) {
mme_send_delete_session_or_mme_ue_context_release(mme_ue);
return;
Expand Down Expand Up @@ -1264,14 +1275,21 @@ void mme_s11_handle_release_access_bearers_response(
ogs_error("MME-UE Context has already been removed");
return;
}
sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
ogs_assert(sgw_ue);

/***********************
* Check MME-UE Context
***********************/
if (!mme_ue_from_teid) {
ogs_error("No Context in TEID [ACTION:%d]", action);
mme_send_delete_session_or_mme_ue_context_release(mme_ue);
return;
}

sgw_ue = sgw_ue_cycle(mme_ue->sgw_ue);
if (!sgw_ue) {
ogs_error("Cannot find sgw_ue");
mme_send_delete_session_or_mme_ue_context_release(mme_ue);
return;
}

/********************
Expand Down
7 changes: 7 additions & 0 deletions src/mme/nas-path.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ int nas_eps_send_attach_reject(mme_ue_t *mme_ue,
ogs_nas_emm_cause_t emm_cause, ogs_nas_esm_cause_t esm_cause)
{
int rv;
enb_ue_t *enb_ue = NULL;
mme_sess_t *sess = NULL;
ogs_pkbuf_t *esmbuf = NULL, *emmbuf = NULL;

Expand All @@ -200,6 +201,12 @@ int nas_eps_send_attach_reject(mme_ue_t *mme_ue,
ogs_debug("[%s] Attach reject", mme_ue->imsi_bcd);
ogs_debug(" Cause[%d]", emm_cause);

enb_ue = enb_ue_cycle(mme_ue->enb_ue);
if (!enb_ue) {
ogs_error("S1 context has already been removed");
return OGS_OK;
}

sess = mme_sess_first(mme_ue);
if (sess) {
esmbuf = esm_build_pdn_connectivity_reject(
Expand Down

0 comments on commit 1252568

Please sign in to comment.