Commit 6e13e4ec authored by Cedric Roux's avatar Cedric Roux

hotfix: better management of s-tmsi reconnect

The code was changing the rnti in the red-black tree without
removing/reinserting the context. This is wrong because the
rnti is a key of the red-black tree and you cannot change the
key in a stored item at will.

There are also modifications of the function mac_eNB_rrc_ul_failure
which has to remove the UE in any case.

And rrc_mac_remove_ue has been changed for the case where
the UE is not found.
parent 675455b0
...@@ -298,6 +298,12 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP) ...@@ -298,6 +298,12 @@ int rrc_mac_remove_ue(module_id_t mod_idP,rnti_t rntiP)
int UE_id = find_UE_id(mod_idP,rntiP); int UE_id = find_UE_id(mod_idP,rntiP);
int pCC_id = UE_PCCID(mod_idP,UE_id); int pCC_id = UE_PCCID(mod_idP,UE_id);
if (UE_id == -1) {
LOG_W(MAC,"rrc_mac_remove_ue: UE %x not found\n", rntiP);
mac_phy_remove_ue(mod_idP,rntiP);
return 0;
}
LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP); LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP);
dump_ue_list(UE_list,0); dump_ue_list(UE_list,0);
......
...@@ -723,8 +723,8 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, ...@@ -723,8 +723,8 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
const int CC_idP, const int CC_idP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t subframeP, const sub_frame_t subframeP,
const rnti_t rntiP) { const rnti_t rntiP)
{
struct rrc_eNB_ue_context_s* ue_context_p = NULL; struct rrc_eNB_ue_context_s* ue_context_p = NULL;
ue_context_p = rrc_eNB_get_ue_context( ue_context_p = rrc_eNB_get_ue_context(
&eNB_rrc_inst[Mod_instP], &eNB_rrc_inst[Mod_instP],
...@@ -735,10 +735,9 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP, ...@@ -735,10 +735,9 @@ void mac_eNB_rrc_ul_failure(const module_id_t Mod_instP,
ue_context_p->ue_context.ul_failure_timer=1; ue_context_p->ue_context.ul_failure_timer=1;
} }
else { else {
LOG_W(RRC,"Frame %d, Subframe %d: UE %x unknown \n",frameP,subframeP,rntiP); LOG_W(RRC,"Frame %d, Subframe %d: UL failure: UE %x unknown \n",frameP,subframeP,rntiP);
rrc_mac_remove_ue(Mod_instP,rntiP);
} }
rrc_mac_remove_ue(Mod_instP,rntiP);
} }
void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP, void mac_eNB_rrc_ul_in_sync(const module_id_t Mod_instP,
......
...@@ -3790,14 +3790,29 @@ rrc_eNB_decode_ccch( ...@@ -3790,14 +3790,29 @@ rrc_eNB_decode_ccch(
//#warning "TODO: stmsi_exist: remove UE from MAC/PHY (how?)" //#warning "TODO: stmsi_exist: remove UE from MAC/PHY (how?)"
LOG_I(RRC," S-TMSI exists, ue_context_p %p\n",ue_context_p); LOG_I(RRC," S-TMSI exists, ue_context_p %p\n",ue_context_p);
stmsi_received=1; stmsi_received=1;
/* replace rnti in the context */
/* for that, remove the context from the RB tree */
RB_REMOVE(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
/* and insert again, after changing rnti everywhere it has to be changed */
ue_context_p->ue_id_rnti = ctxt_pP->rnti;
ue_context_p->ue_context.rnti = ctxt_pP->rnti; ue_context_p->ue_context.rnti = ctxt_pP->rnti;
RB_INSERT(rrc_ue_tree_s, &eNB_rrc_inst[ctxt_pP->module_id].rrc_ue_head, ue_context_p);
/* reset timers */
ue_context_p->ue_context.ul_failure_timer = 0;
ue_context_p->ue_context.ue_release_timer = 0;
// AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)"); // AssertFatal(0 == 1, "TODO: remove UE from MAC/PHY (how?)");
// ue_context_p = NULL; // ue_context_p = NULL;
} else { } else {
ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY); ue_context_p = rrc_eNB_get_next_free_ue_context(ctxt_pP, NOT_A_RANDOM_UE_IDENTITY);
if (ue_context_p == NULL)
LOG_E(RRC, "%s:%d:%s: rrc_eNB_get_next_free_ue_context returned NULL\n", __FILE__, __LINE__, __FUNCTION__);
if (ue_context_p != NULL) {
ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE; ue_context_p->ue_context.Initialue_identity_s_TMSI.presence = TRUE;
ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code; ue_context_p->ue_context.Initialue_identity_s_TMSI.mme_code = mme_code;
ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi; ue_context_p->ue_context.Initialue_identity_s_TMSI.m_tmsi = m_tmsi;
} else {
break;
}
} }
MSC_LOG_RX_MESSAGE( MSC_LOG_RX_MESSAGE(
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment