[MERGED] osmo-bsc[master]: Fix: meas_rep.c will only use valid DL measurement reports

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Harald Welte gerrit-no-reply at lists.osmocom.org
Mon Jan 22 01:57:45 UTC 2018


Harald Welte has submitted this change and it was merged.

Change subject: Fix: meas_rep.c will only use valid DL measurement reports
......................................................................


Fix: meas_rep.c will only use valid DL measurement reports

When averaging measurements, only the valid reports are used. If there is
no valid report in the averaging window at all, an error is returned.

Change-Id: I33056225ead788340755e98113d72e1cbf3ebce6
---
M src/libbsc/meas_rep.c
1 file changed, 19 insertions(+), 4 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/libbsc/meas_rep.c b/src/libbsc/meas_rep.c
index fbd1515..73d9a1f 100644
--- a/src/libbsc/meas_rep.c
+++ b/src/libbsc/meas_rep.c
@@ -29,12 +29,20 @@
 {
 	switch (field) {
 	case MEAS_REP_DL_RXLEV_FULL:
+		if (!(rep->flags & MEAS_REP_F_DL_VALID))
+			return -EINVAL;
 		return rep->dl.full.rx_lev;
 	case MEAS_REP_DL_RXLEV_SUB:
+		if (!(rep->flags & MEAS_REP_F_DL_VALID))
+			return -EINVAL;
 		return rep->dl.sub.rx_lev;
 	case MEAS_REP_DL_RXQUAL_FULL:
+		if (!(rep->flags & MEAS_REP_F_DL_VALID))
+			return -EINVAL;
 		return rep->dl.full.rx_qual;
 	case MEAS_REP_DL_RXQUAL_SUB:
+		if (!(rep->flags & MEAS_REP_F_DL_VALID))
+			return -EINVAL;
 		return rep->dl.sub.rx_qual;
 	case MEAS_REP_UL_RXLEV_FULL:
 		return rep->ul.full.rx_lev;
@@ -73,7 +81,7 @@
 		     enum meas_rep_field field, unsigned int num)
 {
 	unsigned int i, idx;
-	int avg = 0;
+	int avg = 0, valid_num = 0;
 
 	if (num < 1)
 		return -EINVAL;
@@ -86,11 +94,18 @@
 
 	for (i = 0; i < num; i++) {
 		int j = (idx+i) % ARRAY_SIZE(lchan->meas_rep);
+		int val = get_field(&lchan->meas_rep[j], field);
 
-		avg += get_field(&lchan->meas_rep[j], field);
+		if (val >= 0) {
+			avg += val;
+			valid_num++;
+		}
 	}
 
-	return avg / num;
+	if (valid_num == 0)
+		return -EINVAL;
+
+	return avg / valid_num;
 }
 
 /* Check if N out of M last values for FIELD are >= bd */
@@ -108,7 +123,7 @@
 		int j = (idx + i) % ARRAY_SIZE(lchan->meas_rep);
 		int val = get_field(&lchan->meas_rep[j], field);
 
-		if (val >= be)
+		if (val >= be) /* implies that val < 0 will not count */
 			count++;
 
 		if (count >= n)

-- 
To view, visit https://gerrit.osmocom.org/5923
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I33056225ead788340755e98113d72e1cbf3ebce6
Gerrit-PatchSet: 8
Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder



More information about the gerrit-log mailing list