Skip to content

[lte] Handling Implicit detach timer while mme restart #4

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

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
afa7d7a
Fixed memory leaks for attach-detach procedure
rsarwad Apr 20, 2020
63071ef
Merge remote-tracking branch 'upstream/master'
rsarwad Apr 22, 2020
c37c59d
Merge remote-tracking branch 'upstream/master'
rsarwad Apr 29, 2020
cee491c
Merge remote-tracking branch 'upstream/master'
rsarwad May 8, 2020
f38e4a7
Merge remote-tracking branch 'upstream/master'
rsarwad May 8, 2020
16a168f
Merge remote-tracking branch 'upstream/master'
rsarwad May 11, 2020
6917b2b
Merge remote-tracking branch 'upstream/master'
rsarwad May 12, 2020
bc269f4
Merge remote-tracking branch 'upstream/master'
rsarwad May 15, 2020
1e137b8
Merge remote-tracking branch 'upstream/master'
rsarwad May 21, 2020
c5e9218
Merge remote-tracking branch 'upstream/master'
rsarwad May 24, 2020
8482f79
Merge remote-tracking branch 'upstream/master'
rsarwad May 25, 2020
5b7034e
Merge remote-tracking branch 'upstream/master'
rsarwad May 28, 2020
f6658a0
1. Provided fix for mme crash during execution of TC, test_different_…
rsarwad May 28, 2020
3c01e8f
Merge remote-tracking branch 'upstream/master'
rsarwad May 29, 2020
0da6f58
Revert "1. Provided fix for mme crash during execution of TC, test_di…
rsarwad May 29, 2020
7511dbc
Merge remote-tracking branch 'upstream/master'
rsarwad Jun 4, 2020
cf43cb7
Merge remote-tracking branch 'upstream/master'
rsarwad Jun 5, 2020
653ce47
Merge remote-tracking branch 'upstream/master'
rsarwad Jun 25, 2020
8a3e6a8
Merge remote-tracking branch 'upstream/master'
rsarwad Jun 30, 2020
bc40e88
Merge remote-tracking branch 'upstream/master'
rsarwad Jul 1, 2020
43c0b86
Merge remote-tracking branch 'upstream/master'
rsarwad Jul 3, 2020
9ebebdc
Merge remote-tracking branch 'upstream/master'
rsarwad Jul 9, 2020
fe681ea
Merge remote-tracking branch 'upstream/master' into rsarwad_stateless…
rsarwad Jul 10, 2020
4c731e0
Merge remote-tracking branch 'upstream/master' into rsarwad_stateless…
rsarwad Jul 15, 2020
030e922
Merge remote-tracking branch 'upstream/master' into rsarwad_stateless…
rsarwad Jul 17, 2020
1e5e81f
Added Implcit detach timer handling while mme restarts
rsarwad Jul 17, 2020
f17c9bd
Resolved merge conflicts
rsarwad Jul 27, 2020
d7edcf1
Merge remote-tracking branch 'upstream/master' into rsarwad_stateless…
rsarwad Jul 30, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lte/gateway/c/oai/include/mme_app_ue_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ typedef struct ue_mm_context_s {
* Stop when UE moves to connected state
*/
struct mme_app_timer_t implicit_detach_timer;
time_t time_implicit_detach_timer_started;
/* Initial Context Setup Procedure Guard timer */
struct mme_app_timer_t initial_context_setup_rsp_timer;
/* UE Context Modification Procedure Guard timer */
Expand Down
2 changes: 2 additions & 0 deletions lte/gateway/c/oai/tasks/mme_app/mme_app_bearer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1590,6 +1590,7 @@ void mme_app_handle_mobile_reachability_timer_expiry(void* args) {
ue_context_p->mme_ue_s1ap_id);
ue_context_p->implicit_detach_timer.id = MME_APP_TIMER_INACTIVE_ID;
} else {
ue_context_p->time_implicit_detach_timer_started = time(NULL);
OAILOG_DEBUG_UE(
LOG_MME_APP, ue_context_p->emm_context._imsi64,
"Started Implicit Detach timer for UE id: " MME_UE_S1AP_ID_FMT "\n",
Expand All @@ -1616,6 +1617,7 @@ void mme_app_handle_implicit_detach_timer_expiry(void* args) {
OAILOG_FUNC_OUT(LOG_MME_APP);
}
ue_context_p->implicit_detach_timer.id = MME_APP_TIMER_INACTIVE_ID;
ue_context_p->time_implicit_detach_timer_started = 0;
// Initiate Implicit Detach for the UE
nas_proc_implicit_detach_ue_ind(mme_ue_s1ap_id);
OAILOG_FUNC_OUT(LOG_MME_APP);
Expand Down
85 changes: 74 additions & 11 deletions lte/gateway/c/oai/tasks/mme_app/mme_app_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ static bool mme_app_recover_timers_for_ue(
static void mme_app_resume_mobile_reachability_timer(
struct ue_mm_context_s* const ue_mm_context_pP);

static void mme_app_resume_implicit_detach_timer(
struct ue_mm_context_s* const ue_mm_context_pP);

static void _directoryd_report_location(uint64_t imsi, uint8_t imsi_len) {
char imsi_str[IMSI_BCD_DIGITS_MAX + 1];
IMSI64_TO_STRING(imsi, imsi_str, imsi_len);
Expand Down Expand Up @@ -1529,6 +1532,7 @@ void mme_ue_context_update_ue_sig_connection_state(
free_wrapper((void**) &timer_argP);
}
ue_context_p->implicit_detach_timer.id = MME_APP_TIMER_INACTIVE_ID;
ue_context_p->time_implicit_detach_timer_started = 0;
}
// Update Stats
update_mme_app_stats_connected_ue_add();
Expand Down Expand Up @@ -2289,27 +2293,37 @@ static bool mme_app_recover_timers_for_ue(
ue_mm_context_pP->time_mobile_reachability_timer_started) {
mme_app_resume_mobile_reachability_timer(ue_mm_context_pP);
}
if (ue_mm_context_pP &&
ue_mm_context_pP->time_implicit_detach_timer_started) {
mme_app_resume_implicit_detach_timer(ue_mm_context_pP);
}
OAILOG_FUNC_RETURN(LOG_MME_APP, false);
}

// Resumes mobile reachability timer on MME restart
static void mme_app_resume_mobile_reachability_timer(
struct ue_mm_context_s* const ue_mm_context_pP) {
OAILOG_FUNC_IN(LOG_MME_APP);
time_t current_time = time(NULL);
time_t lapsed_time =
current_time - ue_mm_context_pP->time_mobile_reachability_timer_started;
ue_mm_context_pP->mobile_reachability_timer.sec =
(((mme_config.nas_config.t3412_min) +
MME_APP_DELTA_T3412_REACHABILITY_TIMER) *
60) -
lapsed_time;

/* Below condition validates whether timer has expired before MME recovers
* from restart, so MME shall handle as timer expiry
*/
if (ue_mm_context_pP->mobile_reachability_timer.sec <= lapsed_time) {
mme_app_handle_mobile_reachability_timer_expiry(
(void*) &(ue_mm_context_pP->mme_ue_s1ap_id));
OAILOG_FUNC_OUT(LOG_MME_APP);
}
uint32_t remaining_time_in_seconds =
ue_mm_context_pP->mobile_reachability_timer.sec - lapsed_time;
OAILOG_DEBUG(
LOG_MME_APP,
"Current_time :%ld time mobile reachability timer "
"started:%ld lapsed time:%ld remaining time:%ld\n",
"Current_time :%ld mobile reachability timer start time :%ld "
"lapsed time:%ld remaining time:%d \n",
current_time, ue_mm_context_pP->time_mobile_reachability_timer_started,
lapsed_time, ue_mm_context_pP->mobile_reachability_timer.sec);
lapsed_time, remaining_time_in_seconds);

// Start Mobile reachability timer only for remaining duration
nas_itti_timer_arg_t timer_callback_arg = {0};
Expand All @@ -2318,9 +2332,8 @@ static void mme_app_resume_mobile_reachability_timer(
timer_callback_arg.nas_timer_callback_arg =
(void*) &(ue_mm_context_pP->mme_ue_s1ap_id);
if (timer_setup(
ue_mm_context_pP->mobile_reachability_timer.sec, 0, TASK_MME_APP,
INSTANCE_DEFAULT, TIMER_ONE_SHOT, &timer_callback_arg,
sizeof(timer_callback_arg),
remaining_time_in_seconds, 0, TASK_MME_APP, INSTANCE_DEFAULT,
TIMER_ONE_SHOT, &timer_callback_arg, sizeof(timer_callback_arg),
&(ue_mm_context_pP->mobile_reachability_timer.id)) < 0) {
OAILOG_ERROR_UE(
LOG_MME_APP, ue_mm_context_pP->emm_context._imsi64,
Expand All @@ -2336,3 +2349,53 @@ static void mme_app_resume_mobile_reachability_timer(
}
OAILOG_FUNC_OUT(LOG_MME_APP);
}

// Resumes implicit detach timer on MME restart
static void mme_app_resume_implicit_detach_timer(
struct ue_mm_context_s* const ue_mm_context_pP) {
OAILOG_FUNC_IN(LOG_MME_APP);
time_t current_time = time(NULL);
time_t lapsed_time =
current_time - ue_mm_context_pP->time_implicit_detach_timer_started;

/* Below condition validates whether timer has expired before MME recovers
* from restart, so MME shall handle as timer expiry
*/
if (ue_mm_context_pP->implicit_detach_timer.sec <= lapsed_time) {
mme_app_handle_implicit_detach_timer_expiry(
(void*) &(ue_mm_context_pP->mme_ue_s1ap_id));
OAILOG_FUNC_OUT(LOG_MME_APP);
}
uint32_t remaining_time_in_seconds =
ue_mm_context_pP->implicit_detach_timer.sec - lapsed_time;
OAILOG_DEBUG(
LOG_MME_APP,
"Current_time :%ld imiplcit detach timer start time:%ld "
"lapsed time:%ld remaining time:%d \n",
current_time, ue_mm_context_pP->time_implicit_detach_timer_started,
lapsed_time, remaining_time_in_seconds);

// Start Implicit detach timer only for remaining duration
nas_itti_timer_arg_t timer_callback_arg = {0};
timer_callback_arg.nas_timer_callback =
mme_app_handle_implicit_detach_timer_expiry;
timer_callback_arg.nas_timer_callback_arg =
(void*) &(ue_mm_context_pP->mme_ue_s1ap_id);
if (timer_setup(
remaining_time_in_seconds, 0, TASK_MME_APP, INSTANCE_DEFAULT,
TIMER_ONE_SHOT, &timer_callback_arg, sizeof(timer_callback_arg),
&(ue_mm_context_pP->implicit_detach_timer.id)) < 0) {
OAILOG_ERROR_UE(
LOG_MME_APP, ue_mm_context_pP->emm_context._imsi64,
"Failed to start Implicit Detach timer for UE id "
" " MME_UE_S1AP_ID_FMT "\n",
ue_mm_context_pP->mme_ue_s1ap_id);
ue_mm_context_pP->implicit_detach_timer.id = MME_APP_TIMER_INACTIVE_ID;
} else {
OAILOG_DEBUG_UE(
LOG_MME_APP, ue_mm_context_pP->emm_context._imsi64,
"Started Implicit Detach timer for UE id " MME_UE_S1AP_ID_FMT "\n",
ue_mm_context_pP->mme_ue_s1ap_id);
}
OAILOG_FUNC_OUT(LOG_MME_APP);
}
8 changes: 8 additions & 0 deletions lte/gateway/c/oai/tasks/mme_app/mme_app_state_converter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ void MmeNasStateConverter::proto_to_pdn_context_list(

void MmeNasStateConverter::ue_context_to_proto(
const ue_mm_context_t* state_ue_context, oai::UeContext* ue_context_proto) {
OAILOG_FUNC_IN(LOG_MME_APP);
ue_context_proto->Clear();

char* msisdn_buffer = bstr2cstr(state_ue_context->msisdn, (char) '?');
Expand Down Expand Up @@ -602,11 +603,15 @@ void MmeNasStateConverter::ue_context_to_proto(
ue_context_proto->mutable_ulr_response_timer());
ue_context_proto->mutable_time_mobile_reachability_timer_started()
->set_seconds(state_ue_context->time_mobile_reachability_timer_started);
ue_context_proto->mutable_time_implicit_detach_timer_started()->set_seconds(
state_ue_context->time_implicit_detach_timer_started);
OAILOG_FUNC_OUT(LOG_MME_APP);
}

void MmeNasStateConverter::proto_to_ue_mm_context(
const oai::UeContext& ue_context_proto,
ue_mm_context_t* state_ue_mm_context) {
OAILOG_FUNC_IN(LOG_MME_APP);
state_ue_mm_context->msisdn = bfromcstr(ue_context_proto.msisdn().c_str());
state_ue_mm_context->ue_context_rel_cause =
static_cast<enum s1cause>(ue_context_proto.rel_cause());
Expand Down Expand Up @@ -690,6 +695,9 @@ void MmeNasStateConverter::proto_to_ue_mm_context(
&state_ue_mm_context->paging_response_timer);
state_ue_mm_context->time_mobile_reachability_timer_started =
ue_context_proto.time_mobile_reachability_timer_started().seconds();
state_ue_mm_context->time_implicit_detach_timer_started =
ue_context_proto.time_implicit_detach_timer_started().seconds();
OAILOG_FUNC_OUT(LOG_MME_APP);
}

/*********************************************************
Expand Down
3 changes: 3 additions & 0 deletions lte/gateway/c/oai/tasks/mme_app/mme_app_state_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ void MmeNasStateManager::mme_nas_state_init_local_state() {
mme_statistic_timer_);
state_cache_p->statistic_timer_id = 0;
}
if (is_initialized) {
mme_app_recover_timers_for_all_ues();
}
}

// Create the hashtables for MME NAS state
Expand Down
1 change: 1 addition & 0 deletions lte/protos/oai/mme_nas_state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ message UeContext {
uint32 rau_tau_timer = 205;
Timer ulr_response_timer = 206;
google.protobuf.Timestamp time_mobile_reachability_timer_started = 207;
google.protobuf.Timestamp time_implicit_detach_timer_started = 208;
}

// mme_ue_context_t
Expand Down