From 9a11690f818106b015e663204ecd11db0740269b Mon Sep 17 00:00:00 2001 From: Guido Casati Date: Wed, 7 Jan 2026 20:10:45 +0100 Subject: [PATCH] RRC: Improve UE context lookup for re-establishment on different DU Add intermediate fallback to rrc_gNB_get_ue_context_by_rnti_any_du() in re-establishment request handling to better handle cases where UE re-establishes on a different DU. RNTI is NOT globally unique - different DUs can assign the same RNTI to different UEs. The assoc_id check in rrc_gNB_get_ue_context_by_rnti() disambiguates RNTI across DUs and prevents returning the wrong UE. However, during re-establishment on a different DU, du_assoc_id hasn't been updated yet (message comes from new DU, but ue_data.du_assoc_id still points to old DU), causing the primary lookup to fail even though the UE exists. The lookup now uses a three-tier fallback: 1. Primary: rrc_gNB_get_ue_context_by_rnti() with assoc_id check (normal case: same DU) 2. Fallback 1: rrc_gNB_get_ue_context_by_rnti_any_du() by RNTI only (re-establishment on different DU) 3. Fallback 2: rrc_gNB_get_ue_context_source_cell() using physCellId (handover scenarios) --- openair2/RRC/NR/rrc_gNB.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index a727418160..32ddaadecf 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -1510,12 +1510,18 @@ static void rrc_handle_RRCReestablishmentRequest(gNB_RRC_INST *rrc, goto fallback_rrc_setup; } + // Try to find UE context by RNTI and assoc_id (normal case: same DU) ue_context_p = rrc_gNB_get_ue_context_by_rnti(rrc, assoc_id, old_rnti); if (ue_context_p == NULL) { - ue_context_p = rrc_gNB_get_ue_context_source_cell(rrc, physCellId, old_rnti); + // Fallback 1: Try to find UE by RNTI only (re-establishment on different DU scenario) + ue_context_p = rrc_gNB_get_ue_context_by_rnti_any_du(rrc, old_rnti); if (ue_context_p == NULL) { - LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without UE context, fallback to RRC setup\n"); - goto fallback_rrc_setup; + // Fallback 2: Try to find UE by source cell (handover scenario) + ue_context_p = rrc_gNB_get_ue_context_source_cell(rrc, physCellId, old_rnti); + if (ue_context_p == NULL) { + LOG_E(NR_RRC, "NR_RRCReestablishmentRequest without UE context, fallback to RRC setup\n"); + goto fallback_rrc_setup; + } } } gNB_RRC_UE_t *UE = &ue_context_p->ue_context;