Change in osmo-bsc[master]: Fix neigh resolution service on local neighbours

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

pespin gerrit-no-reply at lists.osmocom.org
Wed Feb 10 15:23:59 UTC 2021


pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/22814 )


Change subject: Fix neigh resolution service on local neighbours
......................................................................

Fix neigh resolution service on local neighbours

Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Related: SYS#4909
---
M include/osmocom/bsc/bts.h
M src/osmo-bsc/bts.c
M src/osmo-bsc/neighbor_ident.c
M tests/ctrl/osmo-bsc-neigh-test.cfg
M tests/ctrl_test_runner.py
5 files changed, 110 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-bsc refs/changes/14/22814/1

diff --git a/include/osmocom/bsc/bts.h b/include/osmocom/bsc/bts.h
index e1dd403..7d71991 100644
--- a/include/osmocom/bsc/bts.h
+++ b/include/osmocom/bsc/bts.h
@@ -660,3 +660,4 @@
 const char *btsvariant2str(enum gsm_bts_type_variant v);
 
 struct neighbor_ident_key *bts_ident_key(const struct gsm_bts *bts);
+int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct osmo_cell_global_id_ps *cgi_ps);
diff --git a/src/osmo-bsc/bts.c b/src/osmo-bsc/bts.c
index 76da136..af22561 100644
--- a/src/osmo-bsc/bts.c
+++ b/src/osmo-bsc/bts.c
@@ -769,6 +769,19 @@
 	return &key;
 }
 
+int gsm_bts_get_cgi_ps(const struct gsm_bts *bts, struct osmo_cell_global_id_ps *cgi_ps)
+{
+	if (bts->gprs.mode == BTS_GPRS_NONE)
+		return -ENOTSUP;
+
+	cgi_ps->rai.lac.plmn = bts->network->plmn;
+	cgi_ps->rai.lac.lac = bts->location_area_code;
+	cgi_ps->rai.rac = bts->gprs.rac;
+	cgi_ps->cell_identity = bts->cell_identity;
+
+	return 0;
+}
+
 const struct rate_ctr_desc bts_ctr_description[] = {
 	[BTS_CTR_CHREQ_TOTAL] = \
 		{ "chreq:total",
diff --git a/src/osmo-bsc/neighbor_ident.c b/src/osmo-bsc/neighbor_ident.c
index 185cd0b..6f96033 100644
--- a/src/osmo-bsc/neighbor_ident.c
+++ b/src/osmo-bsc/neighbor_ident.c
@@ -273,7 +273,9 @@
 	char *tmp = NULL, *tok, *saveptr;
 	struct neighbor_ident_key ni;
 	unsigned lac, cell_id;
-	const struct osmo_cell_global_id_ps *cgi_ps;
+	struct osmo_cell_global_id_ps local_cgi_ps;
+	const struct osmo_cell_global_id_ps *cgi_ps = NULL;
+	struct gsm_bts_ref *neigh;
 
 	if (!cmd->variable)
 		goto fmt_err;
@@ -324,10 +326,26 @@
 	if (!neighbor_ident_key_valid(&ni))
 		goto fmt_err;
 
-	tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, &ni);
-	if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
-		goto notfound_err;
-	cgi_ps = &tgt_cell_li->id_list[0].global_ps;
+	/* Is there a local BTS that matches the key? */
+	llist_for_each_entry(neigh, &bts_found->local_neighbors, entry) {
+		struct gsm_bts *neigh_bts = neigh->bts;
+		struct neighbor_ident_key *neigh_bts_key = bts_ident_key(neigh_bts);
+		neigh_bts_key->from_bts = ni.from_bts;
+		if (!neighbor_ident_key_match(neigh_bts_key, &ni, true))
+			continue;
+		if (gsm_bts_get_cgi_ps(neigh->bts, &local_cgi_ps) < 0)
+			continue; /* Not supporting GPRS */
+		cgi_ps = &local_cgi_ps;
+		break;
+	}
+
+	/* No local neighbor found, looking for remote neighbors */
+	if (!cgi_ps) {
+		tgt_cell_li = neighbor_ident_get(net->neighbor_bss_cells, &ni);
+		if (!tgt_cell_li || tgt_cell_li->id_discr != CELL_IDENT_WHOLE_GLOBAL_PS || tgt_cell_li->id_list_len < 1)
+			goto notfound_err;
+		cgi_ps = &tgt_cell_li->id_list[0].global_ps;
+	}
 
 	ctrl_cmd_reply_printf(cmd, "%s", osmo_cgi_ps_name(cgi_ps));
 	talloc_free(tmp);
diff --git a/tests/ctrl/osmo-bsc-neigh-test.cfg b/tests/ctrl/osmo-bsc-neigh-test.cfg
index f1e71b6..2fbc8f8 100644
--- a/tests/ctrl/osmo-bsc-neigh-test.cfg
+++ b/tests/ctrl/osmo-bsc-neigh-test.cfg
@@ -46,6 +46,8 @@
   oml ipa stream-id 255 line 0
   codec-support fr
   gprs mode gprs
+  gprs routing area 5
+  ! remote neigh:
   neighbor cgi-ps 23 42 423 2 5 arfcn 23 bsic 32
   trx 0
    rf_locked 0
@@ -78,6 +80,63 @@
    timeslot 7
     phys_chan_config TCH/F
     hopping enabled 0
+ bts 1
+  type sysmobts
+  band DCS1800
+  cell_identity 123
+  location_area_code 1
+  base_station_id_code 55
+  ms max power 15
+  cell reselection hysteresis 4
+  rxlev access min 0
+  radio-link-timeout 32
+  channel allocator ascending
+  rach tx integer 9
+  rach max transmission 7
+  channel-description attach 1
+  channel-description bs-pa-mfrms 5
+  channel-description bs-ag-blks-res 1
+  early-classmark-sending forbidden
+  ipa unit-id 55 0
+  oml ipa stream-id 255 line 0
+  codec-support fr
+  gprs mode gprs
+  gprs routing area 6
+  neighbor bts 0
+  trx 0
+   rf_locked 0
+   arfcn 880
+   nominal power 23
+   ! to use full TRX power, set max_power_red 0
+   max_power_red 20
+   rsl e1 tei 0
+   timeslot 0
+    phys_chan_config CCCH+SDCCH4
+    hopping enabled 0
+   timeslot 1
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 2
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 3
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 4
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 5
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 6
+    phys_chan_config TCH/F
+    hopping enabled 0
+   timeslot 7
+    phys_chan_config TCH/F
+    hopping enabled 0
+ bts 0
+  ! local neigh, refers to bts 1:
+  neighbor cgi-ps 1 1 1 6 123
 msc 0
  type normal
  allow-emergency allow
diff --git a/tests/ctrl_test_runner.py b/tests/ctrl_test_runner.py
index fb983c9..501b917 100755
--- a/tests/ctrl_test_runner.py
+++ b/tests/ctrl_test_runner.py
@@ -501,11 +501,24 @@
     def ctrl_app(self):
         return (4248, "./src/osmo-bsc/osmo-bsc", "OsmoBSC", "bsc")
 
-    def testCtrlNeighborResolution(self):
+    def testCtrlNeighborResolutionLocalBtsNr(self):
+        r = self.do_get('neighbor_resolve_cgi_ps_from_lac_ci.1.123.871.63')
+        self.assertEqual(r['mtype'], 'GET_REPLY')
+        self.assertEqual(r['var'], 'neighbor_resolve_cgi_ps_from_lac_ci.1.123.871.63')
+        self.assertEqual(r['value'], '001-01-1-5-6969')
+
+    def testCtrlNeighborResolutionLocalWithoutArfcnBsic(self):
+        r = self.do_get('neighbor_resolve_cgi_ps_from_lac_ci.1.6969.880.55')
+        self.assertEqual(r['mtype'], 'GET_REPLY')
+        self.assertEqual(r['var'], 'neighbor_resolve_cgi_ps_from_lac_ci.1.6969.880.55')
+        self.assertEqual(r['value'], '001-01-1-6-123')
+
+    def testCtrlNeighborResolutionWrongSyntax(self):
         r = self.do_get('neighbor_resolve_cgi_ps_from_lac_ci')
         self.assertEqual(r['mtype'], 'ERROR')
         self.assertEqual(r['error'], 'The format is <src_lac>,<src_cell_id>,<dst_arfcn>,<dst_bsic>')
 
+    def testCtrlNeighborResolutionRemote(self):
         r = self.do_get('neighbor_resolve_cgi_ps_from_lac_ci.1.6969.23.32')
         self.assertEqual(r['mtype'], 'GET_REPLY')
         self.assertEqual(r['var'], 'neighbor_resolve_cgi_ps_from_lac_ci.1.6969.23.32')

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I217e3550aa6d7f3c3cab4e545641d790ae12b23f
Gerrit-Change-Number: 22814
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210210/e96b0395/attachment.htm>


More information about the gerrit-log mailing list