Cleanup: Pass UE context into handle_rrcSetupComplete()
Pass UE context, without protocol_ctxt_t, for cleanup. Remove the return from within the switch, as this would lead to memory leaks; nothing is executed after the switch statement (except for freeing memory).
This commit is contained in:
+16
-26
@@ -471,15 +471,14 @@ static void rrc_gNB_generate_RRCReject(module_id_t module_id, rrc_gNB_ue_context
|
||||
/*
|
||||
* Process the rrc setup complete message from UE (SRB1 Active)
|
||||
*/
|
||||
static void rrc_gNB_process_RRCSetupComplete(const protocol_ctxt_t *const ctxt_pP, rrc_gNB_ue_context_t *ue_context_pP, NR_RRCSetupComplete_IEs_t *rrcSetupComplete)
|
||||
static void rrc_gNB_process_RRCSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
LOG_A(NR_RRC, "UE %d Processing NR_RRCSetupComplete from UE\n", ue_context_pP->ue_context.rrc_ue_id);
|
||||
ue_context_pP->ue_context.Srb[1].Active = 1;
|
||||
ue_context_pP->ue_context.Srb[2].Active = 0;
|
||||
AssertFatal(ctxt_pP->rntiMaybeUEid == ue_context_pP->ue_context.rrc_ue_id, "logic bug: inconsistent IDs, must use CU UE ID!\n");
|
||||
LOG_A(NR_RRC, "UE %d Processing NR_RRCSetupComplete from UE\n", UE->rrc_ue_id);
|
||||
UE->Srb[1].Active = 1;
|
||||
UE->Srb[2].Active = 0;
|
||||
|
||||
rrc_gNB_send_NGAP_NAS_FIRST_REQ(ctxt_pP, ue_context_pP, rrcSetupComplete);
|
||||
rrc_gNB_send_NGAP_NAS_FIRST_REQ(rrc, UE, rrcSetupComplete);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -1514,21 +1513,14 @@ static int handle_ueCapabilityInformation(const protocol_ctxt_t *const ctxt_pP,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
rrc_gNB_ue_context_t *ue_context_p,
|
||||
const NR_RRCSetupComplete_t *setup_complete)
|
||||
static void handle_rrcSetupComplete(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, const NR_RRCSetupComplete_t *setup_complete)
|
||||
{
|
||||
if (!ue_context_p) {
|
||||
LOG_I(NR_RRC, "Processing NR_RRCSetupComplete UE %lx, ue_context_p is NULL\n", ctxt_pP->rntiMaybeUEid);
|
||||
return -1;
|
||||
}
|
||||
gNB_RRC_UE_t *UE = &ue_context_p->ue_context;
|
||||
uint8_t xid = setup_complete->rrc_TransactionIdentifier;
|
||||
UE->xids[xid] = RRC_ACTION_NONE;
|
||||
|
||||
if (setup_complete->criticalExtensions.present != NR_RRCSetupComplete__criticalExtensions_PR_rrcSetupComplete) {
|
||||
LOG_E(NR_RRC, "malformed RRCSetupComplete received from UE %lx\n", ctxt_pP->rntiMaybeUEid);
|
||||
return -1;
|
||||
LOG_E(NR_RRC, "malformed RRCSetupComplete received from UE %d\n", UE->rrc_ue_id);
|
||||
return;
|
||||
}
|
||||
|
||||
NR_RRCSetupComplete_IEs_t *setup_complete_ies = setup_complete->criticalExtensions.choice.rrcSetupComplete;
|
||||
@@ -1539,7 +1531,7 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
const BIT_STRING_t *part2 = &setup_complete_ies->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI_Part2;
|
||||
if (part2->size != 2) {
|
||||
LOG_E(NR_RRC, "wrong ng_5G_S_TMSI_Part2 size, expected 2, provided %lu", part2->size);
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (UE->Initialue_identity_5g_s_TMSI.presence) {
|
||||
@@ -1555,7 +1547,7 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
const NR_NG_5G_S_TMSI_t *bs_stmsi = &setup_complete_ies->ng_5G_S_TMSI_Value->choice.ng_5G_S_TMSI;
|
||||
if (bs_stmsi->size != 6) {
|
||||
LOG_E(NR_RRC, "wrong ng_5G_S_TMSI size, expected 6, provided %lu", bs_stmsi->size);
|
||||
return -1;
|
||||
return;
|
||||
}
|
||||
|
||||
fiveg_s_TMSI = BIT_STRING_to_uint64(bs_stmsi);
|
||||
@@ -1583,9 +1575,8 @@ static int handle_rrcSetupComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
}
|
||||
}
|
||||
|
||||
rrc_gNB_process_RRCSetupComplete(ctxt_pP, ue_context_p, setup_complete->criticalExtensions.choice.rrcSetupComplete);
|
||||
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_UE_FMT " UE State = NR_RRC_CONNECTED \n", PROTOCOL_NR_RRC_CTXT_UE_ARGS(ctxt_pP));
|
||||
return 0;
|
||||
rrc_gNB_process_RRCSetupComplete(rrc, UE, setup_complete->criticalExtensions.choice.rrcSetupComplete);
|
||||
return;
|
||||
}
|
||||
|
||||
static void handle_rrcReconfigurationComplete(const protocol_ctxt_t *const ctxt_pP,
|
||||
@@ -1644,10 +1635,10 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP,
|
||||
const sdu_size_t sdu_sizeP)
|
||||
//-----------------------------------------------------------------------------
|
||||
{
|
||||
gNB_RRC_INST *gnb_rrc_inst = RC.nrrrc[ctxt_pP->module_id];
|
||||
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
|
||||
|
||||
/* we look up by CU UE ID! Do NOT change back to RNTI! */
|
||||
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(gnb_rrc_inst, ctxt_pP->rntiMaybeUEid);
|
||||
rrc_gNB_ue_context_t *ue_context_p = rrc_gNB_get_ue_context(rrc, ctxt_pP->rntiMaybeUEid);
|
||||
if (!ue_context_p) {
|
||||
LOG_E(RRC, "could not find UE context for CU UE ID %lu, aborting transaction\n", ctxt_pP->rntiMaybeUEid);
|
||||
return -1;
|
||||
@@ -1683,8 +1674,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP,
|
||||
break;
|
||||
|
||||
case NR_UL_DCCH_MessageType__c1_PR_rrcSetupComplete:
|
||||
if (handle_rrcSetupComplete(ctxt_pP, ue_context_p, ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete) == -1)
|
||||
return -1;
|
||||
handle_rrcSetupComplete(rrc, UE, ul_dcch_msg->message.choice.c1->choice.rrcSetupComplete);
|
||||
break;
|
||||
|
||||
case NR_UL_DCCH_MessageType__c1_PR_measurementReport:
|
||||
@@ -1741,7 +1731,7 @@ int rrc_gNB_decode_dcch(const protocol_ctxt_t *const ctxt_pP,
|
||||
* to set up security, so trigger PDU sessions now. The UE NAS
|
||||
* message will be forwarded in the corresponding reconfiguration,
|
||||
* the Initial context setup response after reconfiguration complete. */
|
||||
trigger_bearer_setup(gnb_rrc_inst, UE, UE->n_initial_pdu, UE->initial_pdus, 0);
|
||||
trigger_bearer_setup(rrc, UE, UE->n_initial_pdu, UE->initial_pdus, 0);
|
||||
} else {
|
||||
/* we already have capabilities, and no PDU sessions to setup, ack
|
||||
* this UE */
|
||||
|
||||
@@ -147,26 +147,20 @@ void nr_rrc_pdcp_config_security(gNB_RRC_UE_t *UE, bool enable_ciphering)
|
||||
/*
|
||||
* Initial UE NAS message on S1AP.
|
||||
*/
|
||||
void
|
||||
rrc_gNB_send_NGAP_NAS_FIRST_REQ(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
rrc_gNB_ue_context_t *ue_context_pP,
|
||||
NR_RRCSetupComplete_IEs_t *rrcSetupComplete
|
||||
)
|
||||
void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete)
|
||||
//------------------------------------------------------------------------------
|
||||
{
|
||||
// gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
|
||||
MessageDef *message_p = NULL;
|
||||
gNB_RRC_UE_t *UE = &ue_context_pP->ue_context;
|
||||
|
||||
message_p = itti_alloc_new_message(TASK_RRC_GNB, 0, NGAP_NAS_FIRST_REQ);
|
||||
MessageDef *message_p = itti_alloc_new_message(TASK_RRC_GNB, rrc->module_id, NGAP_NAS_FIRST_REQ);
|
||||
ngap_nas_first_req_t *req = &NGAP_NAS_FIRST_REQ(message_p);
|
||||
memset(req, 0, sizeof(*req));
|
||||
|
||||
req->gNB_ue_ngap_id = UE->rrc_ue_id;
|
||||
|
||||
/* Assume that cause is coded in the same way in RRC and NGap, just check that the value is in NGap range */
|
||||
AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST, "Establishment cause invalid (%jd/%d) for gNB %d!", UE->establishment_cause, NGAP_RRC_CAUSE_LAST, ctxt_pP->module_id);
|
||||
AssertFatal(UE->establishment_cause < NGAP_RRC_CAUSE_LAST,
|
||||
"Establishment cause invalid (%jd/%d)!",
|
||||
UE->establishment_cause,
|
||||
NGAP_RRC_CAUSE_LAST);
|
||||
req->establishment_cause = UE->establishment_cause;
|
||||
|
||||
/* Forward NAS message */
|
||||
@@ -207,8 +201,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ(
|
||||
UE->ue_guami.amf_pointer = req->ue_identity.guami.amf_pointer;
|
||||
|
||||
LOG_I(NGAP,
|
||||
"[gNB %d] Build NGAP_NAS_FIRST_REQ adding in s_TMSI: GUAMI amf_set_id %u amf_region_id %u ue %x\n",
|
||||
ctxt_pP->module_id,
|
||||
"Build NGAP_NAS_FIRST_REQ adding in s_TMSI: GUAMI amf_set_id %u amf_region_id %u ue %x\n",
|
||||
req->ue_identity.guami.amf_set_id,
|
||||
req->ue_identity.guami.amf_region_id,
|
||||
UE->rnti);
|
||||
@@ -216,7 +209,7 @@ rrc_gNB_send_NGAP_NAS_FIRST_REQ(
|
||||
req->ue_identity.presenceMask = NGAP_UE_IDENTITIES_NONE;
|
||||
}
|
||||
|
||||
itti_send_msg_to_task (TASK_NGAP, ctxt_pP->instance, message_p);
|
||||
itti_send_msg_to_task(TASK_NGAP, rrc->module_id, message_p);
|
||||
}
|
||||
|
||||
static void fill_qos(NGAP_QosFlowSetupRequestList_t *qos, pdusession_t *session)
|
||||
|
||||
@@ -40,12 +40,7 @@
|
||||
#include "NR_UL-DCCH-Message.h"
|
||||
#include "NGAP_CauseRadioNetwork.h"
|
||||
|
||||
void
|
||||
rrc_gNB_send_NGAP_NAS_FIRST_REQ(
|
||||
const protocol_ctxt_t *const ctxt_pP,
|
||||
rrc_gNB_ue_context_t *ue_context_pP,
|
||||
NR_RRCSetupComplete_IEs_t *rrcSetupComplete
|
||||
);
|
||||
void rrc_gNB_send_NGAP_NAS_FIRST_REQ(gNB_RRC_INST *rrc, gNB_RRC_UE_t *UE, NR_RRCSetupComplete_IEs_t *rrcSetupComplete);
|
||||
|
||||
int rrc_gNB_process_NGAP_INITIAL_CONTEXT_SETUP_REQ(MessageDef *msg_p, instance_t instance);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user