Change in osmo-bsc[master]: Add bts counters to count BTS events where we don't have a bts

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/.

laforge gerrit-no-reply at lists.osmocom.org
Mon Aug 24 07:41:46 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-bsc/+/19735 )

Change subject: Add bts counters to count BTS events where we don't have a bts
......................................................................

Add bts counters to count BTS events where we don't have a bts

In some (error-) cases we might be unable to determine which BTS to use
when counting handover events. We don't want to loose these events
because then ctr(bsc) == sum(ctr(bsc->bts)) would not be true anymore.

Those events are now counted by a counter in struct gsm_network which
uses an index that is out of range for regular BTS (65536).

Change-Id: Ic0f3edd5dc014c4eac5e8423133633a3e5d4c13e
Related: SYS#4877
---
M include/osmocom/bsc/gsm_data.h
M src/osmo-bsc/bsc_init.c
M src/osmo-bsc/bsc_subscr_conn_fsm.c
M src/osmo-bsc/handover_fsm.c
4 files changed, 37 insertions(+), 11 deletions(-)

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



diff --git a/include/osmocom/bsc/gsm_data.h b/include/osmocom/bsc/gsm_data.h
index 1dac670..1a4a1c4 100644
--- a/include/osmocom/bsc/gsm_data.h
+++ b/include/osmocom/bsc/gsm_data.h
@@ -1089,6 +1089,11 @@
 	BSC_STAT_NUM_BTS_TOTAL,
 };
 
+/* BTS counter index if a BTS could not be found
+ * Currently we are limited to bts 0 - 255 in the VTY, but that might change in
+ * the future so use 2**16 */
+#define BTS_STAT_IDX_UNKNOWN (UINT16_MAX + 1)
+
 struct gsm_tz {
 	int override; /* if 0, use system's time zone instead. */
 	int hr; /* hour */
@@ -1123,6 +1128,11 @@
 	struct llist_head bts_list;
 	struct llist_head bts_rejected;
 
+        /* BTS-based counters when we can't find the actual BTS
+         * e.g. when conn->lchan is NULL */
+        struct rate_ctr_group *bts_unknown_ctrs;
+        struct osmo_stat_item_group *bts_unknown_statg;
+
 	/* see gsm_network_T_defs */
 	struct osmo_tdef *T_defs;
 
diff --git a/src/osmo-bsc/bsc_init.c b/src/osmo-bsc/bsc_init.c
index e45b5e8..22eba50 100644
--- a/src/osmo-bsc/bsc_init.c
+++ b/src/osmo-bsc/bsc_init.c
@@ -90,8 +90,7 @@
 
 	net->cbc = talloc_zero(net, struct bsc_cbc_link);
 	if (!net->cbc) {
-		talloc_free(net);
-		return NULL;
+		goto err_out;
 	}
 
 	/* Init back pointer */
@@ -104,16 +103,19 @@
 
 	/* init statistics */
 	net->bsc_ctrs = rate_ctr_group_alloc(net, &bsc_ctrg_desc, 0);
-	if (!net->bsc_ctrs) {
-		talloc_free(net);
-		return NULL;
-	}
+	if (!net->bsc_ctrs)
+		goto err_out;
 	net->bsc_statg = osmo_stat_item_group_alloc(net, &bsc_statg_desc, 0);
-	if (!net->bsc_statg) {
-		rate_ctr_group_free(net->bsc_ctrs);
-		talloc_free(net);
-		return NULL;
-	}
+	if (!net->bsc_statg)
+		goto err_free_bsc_ctr;
+
+	/* init statistics */
+	net->bts_unknown_ctrs = rate_ctr_group_alloc(net, &bts_ctrg_desc, BTS_STAT_IDX_UNKNOWN);
+	if (!net->bts_unknown_ctrs)
+		goto err_free_bsc_ctr_stat;
+	net->bts_unknown_statg = osmo_stat_item_group_alloc(net, &bts_statg_desc, BTS_STAT_IDX_UNKNOWN);
+	if (!net->bts_unknown_statg)
+		goto err_free_all;
 
 	INIT_LLIST_HEAD(&net->bts_rejected);
 	gsm_net_update_ctype(net);
@@ -134,6 +136,16 @@
 	net->cbc->config.listen_hostname = talloc_strdup(net->cbc, "127.0.0.1");
 
 	return net;
+
+err_free_all:
+	rate_ctr_group_free(net->bts_unknown_ctrs);
+err_free_bsc_ctr_stat:
+	osmo_stat_item_group_free(net->bsc_statg);
+err_free_bsc_ctr:
+	rate_ctr_group_free(net->bsc_ctrs);
+err_out:
+	talloc_free(net);
+	return NULL;
 }
 
 int bsc_network_alloc(void)
diff --git a/src/osmo-bsc/bsc_subscr_conn_fsm.c b/src/osmo-bsc/bsc_subscr_conn_fsm.c
index 04718da..22aa70a 100644
--- a/src/osmo-bsc/bsc_subscr_conn_fsm.c
+++ b/src/osmo-bsc/bsc_subscr_conn_fsm.c
@@ -386,6 +386,8 @@
 		rate_ctr_inc(&conn->network->bsc_ctrs->ctr[BSC_CTR_HANDOVER_ATTEMPTED]);
 		if (bts)
 			rate_ctr_inc(&bts->bts_ctrs->ctr[BTS_CTR_HANDOVER_ATTEMPTED]);
+		else
+			rate_ctr_inc(&conn->network->bts_unknown_ctrs->ctr[BTS_CTR_HANDOVER_ATTEMPTED]);
 
 		/* Rely on handover_fsm timeout */
 		if (osmo_fsm_inst_state_chg(fi, ST_HANDOVER, 0, 0))
diff --git a/src/osmo-bsc/handover_fsm.c b/src/osmo-bsc/handover_fsm.c
index e238d83..78dbd33 100644
--- a/src/osmo-bsc/handover_fsm.c
+++ b/src/osmo-bsc/handover_fsm.c
@@ -96,6 +96,8 @@
 		       bts_ctr_description[counter].description); \
 		if (bts) \
 			rate_ctr_inc(&bts->bts_ctrs->ctr[counter]); \
+		else \
+			rate_ctr_inc(&conn->network->bts_unknown_ctrs->ctr[counter]); \
 	} while(0)
 
 #define ho_count(bts, counter) do { \

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ic0f3edd5dc014c4eac5e8423133633a3e5d4c13e
Gerrit-Change-Number: 19735
Gerrit-PatchSet: 4
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200824/64fda480/attachment.htm>


More information about the gerrit-log mailing list