Change in osmo-bsc[master]: MSC pooling: implement NAS node selection by NRI from TMSI

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
Thu Jun 18 11:27:45 UTC 2020


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

Change subject: MSC pooling: implement NAS node selection by NRI from TMSI
......................................................................

MSC pooling: implement NAS node selection by NRI from TMSI

If applicable, choose MSC from NRI, extracted from TMSI MI.

Change-Id: Ifbdea197b26e88751a391c8a80c41f04e7d5e047
---
M src/osmo-bsc/gsm_08_08.c
1 file changed, 43 insertions(+), 4 deletions(-)

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



diff --git a/src/osmo-bsc/gsm_08_08.c b/src/osmo-bsc/gsm_08_08.c
index a5f7493..0707c65 100644
--- a/src/osmo-bsc/gsm_08_08.c
+++ b/src/osmo-bsc/gsm_08_08.c
@@ -33,6 +33,7 @@
 #include <osmocom/gsm/gsm0808.h>
 #include <osmocom/gsm/mncc.h>
 #include <osmocom/gsm/gsm48.h>
+#include <osmocom/gsm/gsm23236.h>
 
 #include <osmocom/bsc/osmo_bsc_sigtran.h>
 
@@ -152,6 +153,8 @@
 	uint8_t round_robin_next_nr;
 	struct bsc_subscr *subscr;
 	bool is_emerg = false;
+	int16_t nri_v = -1;
+	bool is_null_nri = false;
 
 	if (msgb_l3len(msg) < sizeof(*gh)) {
 		LOGP(DRSL, LOGL_ERROR, "There is no GSM48 header here.\n");
@@ -186,16 +189,45 @@
 		}
 	}
 
-	/* TODO: extract NRI from MI */
+#define LOG_NRI(LOGLEVEL, FORMAT, ARGS...) \
+	LOGP(DMSC, LOGLEVEL, "%s NRI(%d)=0x%x=%d: " FORMAT, osmo_mobile_identity_to_str_c(OTC_SELECT, &mi), \
+	     net->nri_bitlen, nri_v, nri_v, ##ARGS)
+
+	/* Extract NRI bits from TMSI, possibly indicating which MSC is responsible */
+	if (mi.type == GSM_MI_TYPE_TMSI) {
+		if (osmo_tmsi_nri_v_get(&nri_v, mi.tmsi, net->nri_bitlen)) {
+			LOGP(DMSC, LOGL_ERROR, "Unable to retrieve NRI from TMSI, nri_bitlen == %u\n", net->nri_bitlen);
+			nri_v = -1;
+		} else {
+			is_null_nri = osmo_nri_v_matches_ranges(nri_v, net->null_nri_ranges);
+			if (is_null_nri)
+				LOG_NRI(LOGL_DEBUG, "this is a NULL-NRI\n");
+		}
+	}
 
 	/* Iterate MSCs to find one that matches the extracted NRI, and the next round-robin target for the case no NRI
 	 * match is found. */
 	round_robin_next_nr = (is_emerg ? net->mscs_round_robin_next_emerg_nr : net->mscs_round_robin_next_nr);
 	llist_for_each_entry(msc, &net->mscs, entry) {
-		if (!is_msc_usable(msc, is_emerg))
-			continue;
+		bool nri_matches_msc = (nri_v >= 0 && osmo_nri_v_matches_ranges(nri_v, msc->nri_ranges));
 
-		/* TODO: return msc when extracted NRI matches this MSC */
+		if (!is_msc_usable(msc, is_emerg)) {
+			if (nri_matches_msc)
+				LOG_NRI(LOGL_DEBUG, "matches msc %d, but this MSC is currently not connected\n",
+					msc->nr);
+			continue;
+		}
+
+		/* Return MSC if it matches this NRI, with some debug logging. */
+		if (nri_matches_msc) {
+			if (is_null_nri) {
+				LOG_NRI(LOGL_DEBUG, "matches msc %d, but this NRI is also configured as NULL-NRI\n",
+					msc->nr);
+			} else {
+				LOG_NRI(LOGL_DEBUG, "matches msc %d\n", msc->nr);
+				return msc;
+			}
+		}
 
 		/* Figure out the next round-robin MSC. The MSCs may appear unsorted in net->mscs. Make sure to linearly
 		 * round robin the MSCs by number: pick the lowest msc->nr >= round_robin_next_nr, and also remember the
@@ -207,6 +239,9 @@
 			msc_round_robin_next = msc;
 	}
 
+	if (nri_v >= 0 && !is_null_nri)
+		LOG_NRI(LOGL_DEBUG, "No MSC found for this NRI, doing round-robin\n");
+
 	/* No dedicated MSC found. Choose by round-robin.
 	 * If msc_round_robin_next is NULL, there are either no more MSCs at/after mscs_round_robin_next_nr, or none of
 	 * them are usable -- wrap to the start. */
@@ -217,12 +252,16 @@
 		return NULL;
 	}
 
+	LOGP(DMSC, LOGL_DEBUG, "New subscriber %s: MSC round-robin selects msc %d\n",
+	     osmo_mobile_identity_to_str_c(OTC_SELECT, &mi), msc_target->nr);
+
 	/* An MSC was picked by round-robin, so update the next round-robin nr to pick */
 	if (is_emerg)
 		net->mscs_round_robin_next_emerg_nr = msc_target->nr + 1;
 	else
 		net->mscs_round_robin_next_nr = msc_target->nr + 1;
 	return msc_target;
+#undef LOG_NRI
 }
 
 static int handle_page_resp(struct gsm_subscriber_connection *conn, struct msgb *msg)

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: Ifbdea197b26e88751a391c8a80c41f04e7d5e047
Gerrit-Change-Number: 18766
Gerrit-PatchSet: 6
Gerrit-Owner: neels <nhofmeyr 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/20200618/efd5337e/attachment.htm>


More information about the gerrit-log mailing list