pespin has submitted this change. ( 
https://gerrit.osmocom.org/c/osmo-pcu/+/29925 )

Change subject: update_ms(): Set TLLI of new MS object before merge with old MS
......................................................................

update_ms(): Set TLLI of new MS object before merge with old MS

This way it becomes clearer in logs that we are merging MS which
contains the same TLLI.

Change-Id: Ifd232daa4219e1726c30449d647312a3a226a61d
---
M src/tbf.cpp
M tests/tbf/TbfTest.err
2 files changed, 9 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, approved
  fixeria: Looks good to me, but someone else must approve
  laforge: Looks good to me, but someone else must approve



diff --git a/src/tbf.cpp b/src/tbf.cpp
index 58695d2..dfed320 100644
--- a/src/tbf.cpp
+++ b/src/tbf.cpp
@@ -215,6 +215,8 @@

 void gprs_rlcmac_tbf::update_ms(uint32_t tlli, enum gprs_rlcmac_tbf_direction 
dir)
 {
+       GprsMs *old_ms = NULL;
+
        if (tlli == GSM_RESERVED_TMSI)
                return;

@@ -222,18 +224,17 @@
         * MS object that belongs to that TLLI and if yes make sure one of them
         * gets deleted. This is the same problem that can arise with
         * IMSI in dl_tbf_handle() so there should be a unified solution */
-       if (!ms_check_tlli(ms(), tlli)) {
-               GprsMs *old_ms;
-
+       if (!ms_check_tlli(ms(), tlli))
                old_ms = bts_ms_store(bts)->get_ms(tlli, GSM_RESERVED_TMSI, 
NULL);
-               if (old_ms)
-                       ms_merge_and_clear_ms(ms(), old_ms);
-       }

        if (dir == GPRS_RLCMAC_UL_TBF)
                ms_set_tlli(ms(), tlli);
        else
                ms_confirm_tlli(ms(), tlli);
+
+       if (old_ms)
+               ms_merge_and_clear_ms(ms(), old_ms);
+       /* old_ms may no longer be available here */
 }

 static void tbf_unlink_pdch(struct gprs_rlcmac_tbf *tbf)
diff --git a/tests/tbf/TbfTest.err b/tests/tbf/TbfTest.err
index bde7940..fe7b628 100644
--- a/tests/tbf/TbfTest.err
+++ b/tests/tbf/TbfTest.err
@@ -2655,6 +2655,7 @@
 TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) BSN 0 storing in window (0..63)
 TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) data_length=20, data=f1 22 33 44 
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
 TBF(TFI=0 TLLI=0xffffffff DIR=UL STATE=FLOW) Decoded premier TLLI=0xf1223344 
of UL DATA TFI=0.
+Modifying MS object, UL TLLI: 0xffffffff -> 0xf1223344, not yet confirmed
 TBF(TFI=0 TLLI=0xf1223344 DIR=DL STATE=ASSIGN) free
 PDCH(bts=0,trx=0,ts=7) Detaching TBF(TFI=0 TLLI=0xf1223344 DIR=DL 
STATE=ASSIGN), 1 TBFs, USFs = 01, TFIs = 00000001.
 MS(TLLI=0xf1223344, IMSI=0011223344, TA=7, 1/0,) Detaching TBF: TBF(TFI=0 
TLLI=0xf1223344 DIR=DL STATE=ASSIGN)
@@ -2662,10 +2663,9 @@
 TBF(DL-TFI_0){ASSIGN}: Deallocated
 UL_ASS_TBF(DL-TFI_0){NONE}: Deallocated
 DL_ASS_TBF(DL-TFI_0){NONE}: Deallocated
-Modifying MS object, TLLI = 0xffffffff, MS class 0 -> 1
+Modifying MS object, TLLI = 0xf1223344, MS class 0 -> 1
 MS(TLLI=0xf1223344, IMSI=0011223344, TA=7, 1/0,) Clearing MS object
 MS(TLLI=0xffffffff, IMSI=, TA=7, 1/0,) Destroying MS object
-Modifying MS object, UL TLLI: 0xffffffff -> 0xf1223344, not yet confirmed
 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Assembling frames: (len=20)
 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) Frame 1 starts at offset 4, 
length=16, is_complete=1
 TBF(TFI=0 TLLI=0xf1223344 DIR=UL STATE=FLOW) complete UL frame len=16

--
To view, visit https://gerrit.osmocom.org/c/osmo-pcu/+/29925
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: Ifd232daa4219e1726c30449d647312a3a226a61d
Gerrit-Change-Number: 29925
Gerrit-PatchSet: 3
Gerrit-Owner: pespin <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>
Gerrit-Reviewer: pespin <[email protected]>
Gerrit-MessageType: merged

Reply via email to