Change in ...osmo-msc[master]: libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation

fixeria gerrit-no-reply at lists.osmocom.org
Sat Jun 15 09:58:28 UTC 2019


fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-msc/+/14463


Change subject: libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation
......................................................................

libmsc/gsm_09_11.c: do not abuse LOG_TRANS() and early trans allocation

In case of network-originated SS/USSD session establishment, we
need to verify the received GSUP PROC_SS_REQ message and make
sure that all mandatory IEs are present.

There is no sensible need to allocate a new transaction before
doing all the checks. This complicates the code.

Change-Id: I4e027b19e8065a39324a1647957cef4066b82ce7
---
M src/libmsc/gsm_09_11.c
M tests/msc_vlr/msc_vlr_test_ss.err
2 files changed, 22 insertions(+), 31 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-msc refs/changes/63/14463/1

diff --git a/src/libmsc/gsm_09_11.c b/src/libmsc/gsm_09_11.c
index 4a7c348..9acff0c 100644
--- a/src/libmsc/gsm_09_11.c
+++ b/src/libmsc/gsm_09_11.c
@@ -317,53 +317,44 @@
 	struct gsm_trans *trans, *transt;
 	int tid;
 
-	/* Allocate transaction first, for log context */
-	trans = trans_alloc(net, vsub, TRANS_USSD,
-		TRANS_ID_UNASSIGNED, gsup_msg->session_id);
-
-	if (!trans) {
-		LOG_TRANS(trans, LOGL_ERROR, " -> No memory for trans\n");
-		return NULL;
-	}
-
 	if (gsup_msg->session_state != OSMO_GSUP_SESSION_STATE_BEGIN) {
-		LOG_TRANS(trans, LOGL_ERROR, "Received non-BEGIN message "
-			"for non-existing transaction\n");
-		trans_free(trans);
+		LOGP(DSS, LOGL_ERROR, "Received non-BEGIN message for non-existing transaction\n");
 		return NULL;
 	}
 
+	LOGP(DSS, LOGL_DEBUG, "Establishing a network-originated session (id=0x%x) "
+			      "with subscriber %s\n", gsup_msg->session_id,
+			      vlr_subscr_name(vsub));
+
 	if (!gsup_msg->ss_info || gsup_msg->ss_info_len < 2) {
-		LOG_TRANS(trans, LOGL_ERROR, "Missing mandatory Facility IE\n");
-		trans_free(trans);
+		LOGP(DSS, LOGL_ERROR, "Missing mandatory Facility IE\n");
 		return NULL;
 	}
 
 	/* If subscriber is not "attached" */
 	if (!vsub->cgi.lai.lac) {
-		LOG_TRANS(trans, LOGL_ERROR, "Network-originated session "
+		LOGP(DSS, LOGL_ERROR, "Network-originated session "
 			"rejected - subscriber is not attached\n");
-		trans_free(trans);
 		return NULL;
 	}
 
-	LOG_TRANS(trans, LOGL_DEBUG, "Establishing network-originated session\n");
+	/* Obtain an unused transaction ID */
+	tid = trans_assign_trans_id(net, vsub, TRANS_USSD);
+	if (tid < 0) {
+		LOGP(DSS, LOGL_ERROR, "No free transaction ID\n");
+		return NULL;
+	}
+
+	/* Allocate a new NCSS transaction */
+	trans = trans_alloc(net, vsub, TRANS_USSD, tid, gsup_msg->session_id);
+	if (!trans) {
+		LOGP(DSS, LOGL_ERROR, " -> No memory for trans\n");
+		return NULL;
+	}
 
 	/* Count active NC SS/USSD sessions */
 	osmo_counter_inc(net->active_nc_ss);
 
-	/* Assign transaction ID */
-	tid = trans_assign_trans_id(trans->net, trans->vsub, TRANS_USSD);
-	if (tid < 0) {
-		LOG_TRANS(trans, LOGL_ERROR, "No free transaction ID\n");
-		/* TODO: inform HLR about this */
-		/* TODO: release connection with subscriber */
-		trans->callref = 0;
-		trans_free(trans);
-		return NULL;
-	}
-	trans->transaction_id = tid;
-
 	/* Init inactivity timer */
 	osmo_timer_setup(&trans->ss.timer_guard,
 		ncss_session_timeout_handler, trans);
diff --git a/tests/msc_vlr/msc_vlr_test_ss.err b/tests/msc_vlr/msc_vlr_test_ss.err
index 1199cf1..e058e37 100644
--- a/tests/msc_vlr/msc_vlr_test_ss.err
+++ b/tests/msc_vlr/msc_vlr_test_ss.err
@@ -367,9 +367,9 @@
   llist_count(&vsub->cs.requests) == 0
 <-- GSUP rx OSMO_GSUP_MSGT_PROC_SS_REQUEST: 20010809710000004026f03004200001013101013515a11302010102013b300b04010f0406aa510c061b010a0103
 DREF VLR subscr IMSI-901700000004620:MSISDN-46071 + gsm0911_gsup_rx: now used by 3 (attached,_test_ss_ussd_no,gsm0911_gsup_rx)
+DSS Establishing a network-originated session (id=0x20000101) with subscriber IMSI-901700000004620:MSISDN-46071
 DREF VLR subscr IMSI-901700000004620:MSISDN-46071 + NCSS: now used by 4 (attached,_test_ss_ussd_no,gsm0911_gsup_rx,NCSS)
-DSS trans(NCSS IMSI-901700000004620:MSISDN-46071 callref-0x20000101 tid-255) New transaction
-DSS trans(NCSS IMSI-901700000004620:MSISDN-46071 callref-0x20000101 tid-255) Establishing network-originated session
+DSS trans(NCSS IMSI-901700000004620:MSISDN-46071 callref-0x20000101 tid-0) New transaction
 DSS trans(NCSS IMSI-901700000004620:MSISDN-46071 callref-0x20000101 tid-0) Triggering Paging Request
 DPAG Paging: IMSI-901700000004620:MSISDN-46071 for GSM 09.11 SS/USSD: Starting paging
   paging request (SIGNALLING_HIGH_PRIO) to IMSI-901700000004620:MSISDN-46071 on GERAN-A

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

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-Change-Id: I4e027b19e8065a39324a1647957cef4066b82ce7
Gerrit-Change-Number: 14463
Gerrit-PatchSet: 1
Gerrit-Owner: fixeria <axilirator at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190615/46d9f9f0/attachment.html>


More information about the gerrit-log mailing list