From e303b1be6bdf06659a4f3070d8ec935c5680a031 Mon Sep 17 00:00:00 2001
From: David Kim <david.kim@episci.com>
Date: Fri, 29 Oct 2021 17:48:30 -0700
Subject: [PATCH] Fixing ra procedures sync problem by checking rnti value.

---
 openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +-
 openair2/RRC/NR_UE/rrc_UE.c                  | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
index 1273a76da8..93ea43d07b 100644
--- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
+++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c
@@ -550,7 +550,7 @@ int nr_ue_process_dci_indication_pdu(module_id_t module_id,int cc_id, int gNB_in
   NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
   dci_pdu_rel15_t *def_dci_pdu_rel15 = &mac->def_dci_pdu_rel15[dci->dci_format];
 
-  if ((dci->rnti != mac->crnti) && (dci->rnti != mac->ra.ra_rnti)) {
+  if ((dci->rnti != mac->crnti) && (dci->rnti != mac->ra.ra_rnti) && (dci->rnti != 0xFFFF)) {
       LOG_D(MAC,"We skip for the received dci indication rnti %4x != mac->crnti %4x  frame slot %4d.%2d  RA state %d\n",
                     dci->rnti, mac->crnti, frame, slot, mac->ra.ra_state);
       return 0;
diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c
index f0a2789b17..cc0b34aaf1 100644
--- a/openair2/RRC/NR_UE/rrc_UE.c
+++ b/openair2/RRC/NR_UE/rrc_UE.c
@@ -408,6 +408,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
           SEQUENCE_free( &asn_DEF_NR_RadioBearerConfig, RadioBearerConfig, 1 );
           return;
         }
+#if 0
         protocol_ctxt_t ctxt;
         NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
         PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_id, ENB_FLAG_YES, mac->crnti, 0, 0, 0);
@@ -418,6 +419,7 @@ void process_nsa_message(NR_UE_RRC_INST_t *rrc, nsa_message_t nsa_message_type,
                         RadioBearerConfig->securityConfig->securityAlgorithmConfig->cipheringAlgorithm,
                         *RadioBearerConfig->securityConfig->keyToUse);
         nr_rrc_ue_process_RadioBearerConfig(&ctxt, 0, RadioBearerConfig);
+#endif
 
       }
       break;
-- 
2.26.2