Stefan Sperling has uploaded this change for review. ( 
https://gerrit.osmocom.org/9395


Change subject: log warnings when measurements arrive from the future
......................................................................

log warnings when measurements arrive from the future

We have observed problems which look like the monotonic clock
going backwards on Jenkins build workers, causing overflow in
a time delta calculation. When this happens, log an error and
don't process the measurement.

Change-Id: I7a3aaba8eba73fad09bebc1f32e832fc25f8eb28
Related: OS#3225
---
M src/gprs_rlcmac_meas.cpp
1 file changed, 25 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/95/9395/1

diff --git a/src/gprs_rlcmac_meas.cpp b/src/gprs_rlcmac_meas.cpp
index ac01f2a..056db20 100644
--- a/src/gprs_rlcmac_meas.cpp
+++ b/src/gprs_rlcmac_meas.cpp
@@ -24,6 +24,7 @@

 #include <string.h>
 #include <errno.h>
+#include <inttypes.h>

 /*
  * downlink measurement
@@ -78,6 +79,14 @@
        tbf->meas.rssi_num++;

        osmo_clock_gettime(CLOCK_MONOTONIC, &now_tv);
+       if (now_tv.tv_sec < rssi_tv->tv_sec ||
+           (now_tv.tv_sec == rssi_tv->tv_sec && now_tv.tv_nsec < 
rssi_tv->tv_nsec)) {
+               LOGP(DRLCMACMEAS, LOGL_ERROR, "Not processing RSSI measurement 
received from the future; "
+                    "did the monotonic clock jump backwards? (now=%" PRIu64 
".%" PRIu64 " < %" PRIu64 ".%" PRIu64 ")\n",
+                     (uint64_t)now_tv.tv_sec, (uint64_t)now_tv.tv_nsec,
+                     (uint64_t)rssi_tv->tv_sec, (uint64_t)rssi_tv->tv_nsec);
+               return 0;
+       }
        elapsed = ((now_tv.tv_sec - rssi_tv->tv_sec) << 7)
                + (((now_tv.tv_nsec - rssi_tv->tv_nsec)/1000) << 7) / 1000000;
        if (elapsed < 128)
@@ -130,6 +139,14 @@
        tbf->m_bw.dl_loss_lost += lost;

        osmo_clock_gettime(CLOCK_MONOTONIC, &now_tv);
+       if (now_tv.tv_sec < loss_tv->tv_sec ||
+           (now_tv.tv_sec == loss_tv->tv_sec && now_tv.tv_nsec < 
loss_tv->tv_nsec)) {
+               LOGP(DRLCMACMEAS, LOGL_ERROR, "Not processing lost frames 
measurement received from the future; "
+                    "did the monotonic clock jump backwards? (now=%" PRIu64 
".%" PRIu64 " < %" PRIu64 ".%" PRIu64 ")\n",
+                     (uint64_t)now_tv.tv_sec, (uint64_t)now_tv.tv_nsec,
+                     (uint64_t)loss_tv->tv_sec, (uint64_t)loss_tv->tv_nsec);
+               return 0;
+       }
        elapsed = ((now_tv.tv_sec - loss_tv->tv_sec) << 7)
                + (((now_tv.tv_nsec - loss_tv->tv_nsec)/1000) << 7) / 1000000;
        if (elapsed < 128)
@@ -174,6 +191,14 @@
        tbf->m_bw.dl_bw_octets += octets;

        osmo_clock_gettime(CLOCK_MONOTONIC, &now_tv);
+       if (now_tv.tv_sec < bw_tv->tv_sec ||
+           (now_tv.tv_sec == bw_tv->tv_sec && now_tv.tv_nsec < 
bw_tv->tv_nsec)) {
+               LOGP(DRLCMACMEAS, LOGL_ERROR, "Not processing bandwidth 
measurement received from the future; "
+                    "did the monotonic clock jump backwards? (now=%" PRIu64 
".%" PRIu64 " < %" PRIu64 ".%" PRIu64 ")\n",
+                     (uint64_t)now_tv.tv_sec, (uint64_t)now_tv.tv_nsec,
+                     (uint64_t)bw_tv->tv_sec, (uint64_t)bw_tv->tv_nsec);
+               return 0;
+       }
        elapsed = ((now_tv.tv_sec - bw_tv->tv_sec) << 7)
                + (((now_tv.tv_nsec - bw_tv->tv_nsec)/1000) << 7) / 1000000;
        if (elapsed < 128)

--
To view, visit https://gerrit.osmocom.org/9395
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I7a3aaba8eba73fad09bebc1f32e832fc25f8eb28
Gerrit-Change-Number: 9395
Gerrit-PatchSet: 1
Gerrit-Owner: Stefan Sperling <[email protected]>

Reply via email to