Change in osmo-gbproxy[master]: gbproxy: Forward MS_REGISTR_ENQ/_RESP correctly

daniel gerrit-no-reply at lists.osmocom.org
Fri Jul 9 18:12:41 UTC 2021


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

Change subject: gbproxy: Forward MS_REGISTR_ENQ/_RESP correctly
......................................................................

gbproxy: Forward MS_REGISTR_ENQ/_RESP correctly

We need to save the BSS NSE <-> IMSI mapping to correctly route the
answer.

Related: OS#4472
Change-Id: I1908bbe8db11271dbd3f45b0d9f1bc0bfe48f239
---
M include/osmocom/gbproxy/gb_proxy.h
M src/gb_proxy.c
2 files changed, 40 insertions(+), 0 deletions(-)

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



diff --git a/include/osmocom/gbproxy/gb_proxy.h b/include/osmocom/gbproxy/gb_proxy.h
index c1cc35f..76a7d31 100644
--- a/include/osmocom/gbproxy/gb_proxy.h
+++ b/include/osmocom/gbproxy/gb_proxy.h
@@ -194,6 +194,7 @@
 
 enum cache_usage_type {
 	CACHE_USAGE_PAGING,
+	CACHE_USAGE_MS_REG_ENQ,
 };
 
 /* TLLI cache */
diff --git a/src/gb_proxy.c b/src/gb_proxy.c
index e017abe..94ac4a3 100644
--- a/src/gb_proxy.c
+++ b/src/gb_proxy.c
@@ -1114,6 +1114,26 @@
 		rc = gbprox_relay2nse(msg, nse, 0);
 		break;
 	}
+	case BSSGP_PDUT_MS_REGISTR_ENQ:
+	{
+		struct gbproxy_sgsn *sgsn;
+		struct osmo_mobile_identity mi;
+		const uint8_t *mi_data = TLVP_VAL(&tp[0], BSSGP_IE_IMSI);
+		uint8_t mi_len = TLVP_LEN(&tp[0], BSSGP_IE_IMSI);
+		osmo_mobile_identity_decode(&mi, mi_data, mi_len, false);
+
+		sgsn = gbproxy_select_sgsn(nse->cfg, NULL);
+		if (!sgsn) {
+			LOGP(DGPRS, LOGL_ERROR, "Could not find any SGSN, dropping message!\n");
+			rc = -EINVAL;
+			break;
+		}
+
+		gbproxy_imsi_cache_update(nse, mi.imsi, CACHE_USAGE_MS_REG_ENQ);
+
+		rc = gbprox_relay2nse(msg, sgsn->nse, 0);
+		break;
+	}
 	default:
 		LOGPNSE(nse, LOGL_ERROR, "Rx %s: Implementation missing\n", pdut_name);
 		break;
@@ -1444,6 +1464,25 @@
 	case BSSGP_PDUT_RAN_INFO_APP_ERROR:
 		rc = gbprox_rx_rim_from_sgsn(tp, nse, msg, log_pfx, pdut_name);
 		break;
+	case BSSGP_PDUT_MS_REGISTR_ENQ_RESP:
+	{
+		struct gbproxy_nse *nse_peer;
+		struct osmo_mobile_identity mi;
+		const uint8_t *mi_data = TLVP_VAL(&tp[0], BSSGP_IE_IMSI);
+		uint8_t mi_len = TLVP_LEN(&tp[0], BSSGP_IE_IMSI);
+		osmo_mobile_identity_decode(&mi, mi_data, mi_len, false);
+		nse_peer = gbproxy_nse_by_imsi(cfg, mi.imsi, CACHE_USAGE_MS_REG_ENQ);
+		if (!nse_peer) {
+			LOGPNSE(nse, LOGL_ERROR, "Rx %s: Cannot find NSE\n", pdut_name);
+			return tx_status(nse, ns_bvci, BSSGP_CAUSE_INV_MAND_INF, NULL, msg);
+		} else if (nse_peer->sgsn_facing) {
+			LOGPNSE(nse, LOGL_ERROR, "Forwarding %s failed: IMSI cache contains SGSN NSE", pdut_name);
+			return tx_status(nse, ns_bvci, BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+		}
+		gbproxy_imsi_cache_remove(cfg, mi.imsi, CACHE_USAGE_MS_REG_ENQ);
+		gbprox_relay2nse(msg, nse_peer, ns_bvci);
+		break;
+	}
 	default:
 		LOGPNSE(nse, LOGL_NOTICE, "Rx %s: Not supported\n", pdut_name);
 		rate_ctr_inc(rate_ctr_group_get_ctr(cfg->ctrg, GBPROX_GLOB_CTR_PROTO_ERR_SGSN));

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

Gerrit-Project: osmo-gbproxy
Gerrit-Branch: master
Gerrit-Change-Id: I1908bbe8db11271dbd3f45b0d9f1bc0bfe48f239
Gerrit-Change-Number: 24859
Gerrit-PatchSet: 3
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann at sysmocom.de>
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: lynxis lazus <lynxis at fe80.eu>
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/20210709/72dc4e60/attachment.htm>


More information about the gerrit-log mailing list