Change in osmo-gbproxy[master]: gb_proxy: simplify raid data storage

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
Tue Feb 9 15:44:45 UTC 2021


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

Change subject: gb_proxy: simplify raid data storage
......................................................................

gb_proxy: simplify raid data storage

Instead of storing the raw ra_id in its unparsed binary form, store it
as a parsed struct. Also store the cell-id on cell allocation for later
use.

Change-Id: Ib58b9188e3ce4bd3fdadb03f158d56b29778387c
Related: OS#4894
---
M include/osmocom/sgsn/gb_proxy.h
M src/gb_proxy.c
M src/gb_proxy_ctrl.c
M src/gb_proxy_vty.c
4 files changed, 26 insertions(+), 20 deletions(-)

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



diff --git a/include/osmocom/sgsn/gb_proxy.h b/include/osmocom/sgsn/gb_proxy.h
index d988cae..269b851 100644
--- a/include/osmocom/sgsn/gb_proxy.h
+++ b/include/osmocom/sgsn/gb_proxy.h
@@ -8,6 +8,7 @@
 #include <osmocom/core/hashtable.h>
 #include <osmocom/gsm/gsm23003.h>
 #include <osmocom/gsm/gsm23236.h>
+#include <osmocom/gsm/gsm48.h>
 #include <osmocom/gsm/protocol/gsm_23_003.h>
 
 #include <osmocom/gprs/gprs_ns2.h>
@@ -110,8 +111,13 @@
 	/*  BVCI of PTP BVCs associated to this cell */
 	uint16_t bvci;
 
-	/* Routing Area that this BVC is part of (raw 04.08 encoding) */
-	uint8_t ra[6];
+	struct {
+		/* Routing Area that this cell is part of */
+		struct gprs_ra_id raid;
+
+		/* Cell ID of this cell */
+		uint16_t cid;
+	} id;
 
 	/* pointer to the BSS-side BVC */
 	struct gbproxy_bvc *bss_bvc;
@@ -131,8 +137,8 @@
 	/* PTP BVCI of this BVC */
 	uint16_t bvci;
 
-	/* Routing Area that this BVC is part of (raw 04.08 encoding) */
-	uint8_t ra[6];
+	/* Routing Area that this BVC is part of */
+	struct gprs_ra_id raid;
 
 	/* Counter */
 	struct rate_ctr_group *ctrg;
diff --git a/src/gb_proxy.c b/src/gb_proxy.c
index e8a78f2..12e685d 100644
--- a/src/gb_proxy.c
+++ b/src/gb_proxy.c
@@ -671,7 +671,8 @@
 
 		bvc->cell = gbproxy_cell_alloc(cfg, bvci);
 		OSMO_ASSERT(bvc->cell);
-		memcpy(bvc->cell->ra, bvc->ra, sizeof(bvc->cell->ra));
+		memcpy(&bvc->cell->id.raid, &bvc->raid, sizeof(bvc->cell->id.raid));
+		bvc->cell->id.cid = cell_id;
 
 		/* link us to the cell and vice-versa */
 		bvc->cell->bss_bvc = bvc;
@@ -688,7 +689,7 @@
 			OSMO_ASSERT(sgsn_bvc);
 
 			sgsn_bvc->cell = bvc->cell;
-			memcpy(sgsn_bvc->ra, bvc->cell->ra, sizeof(sgsn_bvc->ra));
+			memcpy(&sgsn_bvc->raid, &bvc->cell->id.raid, sizeof(sgsn_bvc->raid));
 			sgsn_bvc->fi = bssgp_bvc_fsm_alloc_ptp_bss(sgsn_bvc, cfg->nsi, sgsn_nse->nsei,
 								   bvci, ra_id, cell_id);
 			OSMO_ASSERT(sgsn_bvc->fi);
@@ -878,8 +879,8 @@
 			 * PDU, this means we can extend our local
 			 * state information about this particular cell
 			 * */
-			memcpy(from_bvc->ra, TLVP_VAL(tp, BSSGP_IE_CELL_ID), sizeof(from_bvc->ra));
-			gsm48_parse_ra(&raid, from_bvc->ra);
+			gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_CELL_ID));
+			memcpy(&from_bvc->raid, &raid, sizeof(from_bvc->raid));
 			LOGPBVC(from_bvc, LOGL_INFO, "Cell ID %s\n", osmo_rai_name(&raid));
 		}
 	}
@@ -1053,11 +1054,13 @@
 		LOGPBVC(sgsn_bvc, LOGL_INFO, "Rx %s: routing by BVCI\n", pdut_name);
 		return gbprox_relay2peer(msg, sgsn_bvc->cell->bss_bvc, ns_bvci);
 	} else if (TLVP_PRES_LEN(tp, BSSGP_IE_ROUTEING_AREA, 6)) {
+		struct gprs_ra_id raid;
 		errctr = GBPROX_GLOB_CTR_INV_RAI;
+		gsm48_parse_ra(&raid, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA));
 		/* iterate over all bvcs and dispatch the paging to each matching one */
 		hash_for_each(cfg->bss_nses, i, nse, list) {
 			hash_for_each(nse->bvcs, j, bss_bvc, list) {
-				if (!memcmp(bss_bvc->ra, TLVP_VAL(tp, BSSGP_IE_ROUTEING_AREA), 6)) {
+				if (gsm48_ra_equal(&bss_bvc->raid, &raid)) {
 					LOGPNSE(nse, LOGL_INFO, "Rx %s: routing to NSE (RAI match)\n",
 						pdut_name);
 					gbprox_relay2peer(msg, bss_bvc, ns_bvci);
@@ -1068,11 +1071,13 @@
 			}
 		}
 	} else if (TLVP_PRES_LEN(tp, BSSGP_IE_LOCATION_AREA, 5)) {
+		struct gsm48_ra_id lac;
 		errctr = GBPROX_GLOB_CTR_INV_LAI;
 		/* iterate over all bvcs and dispatch the paging to each matching one */
 		hash_for_each(cfg->bss_nses, i, nse, list) {
 			hash_for_each(nse->bvcs, j, bss_bvc, list) {
-				if (!memcmp(bss_bvc->ra, TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA), 5)) {
+				gsm48_encode_ra(&lac, &bss_bvc->raid);
+				if (!memcmp(&lac, TLVP_VAL(tp, BSSGP_IE_LOCATION_AREA), 5)) {
 					LOGPNSE(nse, LOGL_INFO, "Rx %s: routing to NSE (LAI match)\n",
 						pdut_name);
 					gbprox_relay2peer(msg, bss_bvc, ns_bvci);
diff --git a/src/gb_proxy_ctrl.c b/src/gb_proxy_ctrl.c
index 10d3727..b6f01af 100644
--- a/src/gb_proxy_ctrl.c
+++ b/src/gb_proxy_ctrl.c
@@ -91,13 +91,12 @@
 	hash_for_each(cfg->bss_nses, i, nse_peer, list) {
 		struct gbproxy_bvc *bvc;
 		hash_for_each(nse_peer->bvcs, j, bvc, list) {
-			struct gprs_ra_id raid;
-			gsm48_parse_ra(&raid, bvc->ra);
+			struct gprs_ra_id *raid = &bvc->cell->id.raid;
 
 			cmd->reply = talloc_asprintf_append(cmd->reply, "%u,%u,%u-%u-%u-%u,%s\n",
 					nse_peer->nsei, bvc->bvci,
-					raid.mcc, raid.mnc,
-					raid.lac, raid.rac,
+					raid->mcc, raid->mnc,
+					raid->lac, raid->rac,
 					osmo_fsm_inst_state_name(bvc->fi));
 		}
 	}
diff --git a/src/gb_proxy_vty.c b/src/gb_proxy_vty.c
index fd4692d..9dbde58 100644
--- a/src/gb_proxy_vty.c
+++ b/src/gb_proxy_vty.c
@@ -78,10 +78,8 @@
 		vty_out(vty, "NSEI %5u, SIG-BVCI %5u [%s]%s", bvc->nse->nsei, bvc->bvci,
 			osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE);
 	} else {
-		struct gprs_ra_id raid;
-		gsm48_parse_ra(&raid, bvc->ra);
 		vty_out(vty, "NSEI %5u, PTP-BVCI %5u, RAI %s [%s]%s", bvc->nse->nsei, bvc->bvci,
-			osmo_rai_name(&raid), osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE);
+			osmo_rai_name(&bvc->cell->id.raid), osmo_fsm_inst_state_name(bvc->fi), VTY_NEWLINE);
 	}
 }
 
@@ -100,12 +98,10 @@
 
 static void gbproxy_vty_print_cell(struct vty *vty, struct gbproxy_cell *cell, bool show_stats)
 {
-	struct gprs_ra_id raid;
-	gsm48_parse_ra(&raid, cell->ra);
 	unsigned int num_sgsn_bvc = 0;
 	unsigned int i;
 
-	vty_out(vty, "BVCI %5u RAI %s: ", cell->bvci, osmo_rai_name(&raid));
+	vty_out(vty, "BVCI %5u RAI %s CID %05u: ", cell->bvci, osmo_rai_name(&cell->id.raid), cell->id.cid);
 	if (cell->bss_bvc)
 		vty_out(vty, "BSS NSEI %5u, SGSN NSEI ", cell->bss_bvc->nse->nsei);
 	else

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

Gerrit-Project: osmo-gbproxy
Gerrit-Branch: master
Gerrit-Change-Id: Ib58b9188e3ce4bd3fdadb03f158d56b29778387c
Gerrit-Change-Number: 22653
Gerrit-PatchSet: 9
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
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/20210209/15cc299b/attachment.htm>


More information about the gerrit-log mailing list