fixeria has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/osmo-bts/+/24594 )


Change subject: l1sap: fix TDMA frame number wrap in l1sap_info_time_ind()
......................................................................

l1sap: fix TDMA frame number wrap in l1sap_info_time_ind()

Using the normal arithmetic for TDMA frame numbers may result
in getting wrong values.  Consider the following situation:

  'info_time_ind->fn' is 0 (beginning of period)
   'bts->gsm_time.fn' is 2715647 (end of period)

With these input values the following expression:

  info_time_ind->fn - bts->gsm_time.fn

will be equal to:

  0 - 2715647 or -2715647

In this case osmo-bts does not log an error, because:

  if (-2715647 > 0) // is false

As a consequence, we do not increment number of RACH slots that
have passed by since the last time indication:

  for (i = 0; i < -2715647; i++) // is false

This is why we introduced GSM_TDMA_FN_{SUB,SUM,DIFF,INC} API.

Change-Id: I6168dd75daea50bbe2e19338e637185ac9ac87ef
---
M src/common/l1sap.c
1 file changed, 4 insertions(+), 4 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bts refs/changes/94/24594/1

diff --git a/src/common/l1sap.c b/src/common/l1sap.c
index b17bf01..cd2af57 100644
--- a/src/common/l1sap.c
+++ b/src/common/l1sap.c
@@ -592,17 +592,17 @@
                               struct osmo_phsap_prim *l1sap,
                               struct info_time_ind_param *info_time_ind)
 {
-       int frames_expired;
-       int i;
+       unsigned int frames_expired;
+       unsigned int i;

        DEBUGPFN(DL1P, info_time_ind->fn, "Rx MPH_INFO time ind\n");

        /* Calculate and check frame difference */
-       frames_expired = info_time_ind->fn - bts->gsm_time.fn;
+       frames_expired = GSM_TDMA_FN_SUB(info_time_ind->fn, bts->gsm_time.fn);
        if (frames_expired > 1) {
                if (bts->gsm_time.fn)
                        LOGPFN(DL1P, LOGL_ERROR, info_time_ind->fn,
-                            "Invalid condition detected: Frame difference is 
%"PRIu32"-%"PRIu32"=%d > 1!\n",
+                            "Invalid condition detected: Frame difference is 
%"PRIu32"-%"PRIu32"=%u > 1!\n",
                             info_time_ind->fn, bts->gsm_time.fn, 
frames_expired);
        }


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

Gerrit-Project: osmo-bts
Gerrit-Branch: master
Gerrit-Change-Id: I6168dd75daea50bbe2e19338e637185ac9ac87ef
Gerrit-Change-Number: 24594
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <vyanits...@sysmocom.de>
Gerrit-MessageType: newchange

Reply via email to