Change in osmo-bsc[master]: cosmetic: logging and ordering in handle_ass_compl()

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Thu May 17 22:29:27 UTC 2018


Neels Hofmeyr has uploaded this change for review. ( https://gerrit.osmocom.org/9230


Change subject: cosmetic: logging and ordering in handle_ass_compl()
......................................................................

cosmetic: logging and ordering in handle_ass_compl()

* Check the message length once at the start, before any other actions.
* Use only one local gsm48_hdr pointer.
* Read the cause value once near the top, re-use it.
* Log "ASSIGNMENT COMPLETE" always, not only during handover.
* Fully initialize local struct lchan_signal_data.

Change-Id: Idcfd932d3dfb0b621ed6d8c4f92c0231abcdcec8
---
M src/libbsc/bsc_api.c
1 file changed, 21 insertions(+), 19 deletions(-)



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

diff --git a/src/libbsc/bsc_api.c b/src/libbsc/bsc_api.c
index 71cc0f0..c6c1438 100644
--- a/src/libbsc/bsc_api.c
+++ b/src/libbsc/bsc_api.c
@@ -344,18 +344,27 @@
 static void handle_ass_compl(struct gsm_subscriber_connection *conn,
 			     struct msgb *msg)
 {
-	struct gsm48_hdr *gh;
+	struct gsm48_hdr *gh = msgb_l3(msg);
 	struct bsc_api *api = conn->network->bsc_api;
+	enum gsm48_rr_cause cause;
+
+	/* Expecting gsm48_hdr + cause value */
+	if (msgb_l3len(msg) != sizeof(*gh) + 1) {
+		LOGPLCHAN(msg->lchan, DRR, LOGL_ERROR,
+			  "RR Assignment Complete: length invalid: %zu, expected %zu\n",
+			  msgb_l3len(msg), sizeof(*gh) + 1);
+		return;
+	}
+
+	cause = gh->data[0];
+
+	LOGPLCHAN(msg->lchan, DRR, LOGL_DEBUG, "ASSIGNMENT COMPLETE cause = %s\n",
+		  rr_cause_name(cause));
 
 	if (conn->ho) {
-		struct lchan_signal_data sig;
-		struct gsm48_hdr *gh = msgb_l3(msg);
-
-		LOGPLCHAN(msg->lchan, DRR, LOGL_DEBUG, "ASSIGNMENT COMPLETE cause = %s\n",
-			  rr_cause_name(gh->data[0]));
-
-		sig.lchan = msg->lchan;
-		sig.mr = NULL;
+		struct lchan_signal_data sig = {
+			.lchan = msg->lchan,
+		};
 		osmo_signal_dispatch(SS_LCHAN, S_LCHAN_ASSIGNMENT_COMPL, &sig);
 		/* FIXME: release old channel */
 
@@ -366,15 +375,8 @@
 	}
 
 	if (conn->secondary_lchan != msg->lchan) {
-		LOGPLCHAN(msg->lchan, DMSC, LOGL_ERROR,
-			  "Assignment Compl should occur on second lchan.\n");
-		return;
-	}
-
-	gh = msgb_l3(msg);
-	if (msgb_l3len(msg) - sizeof(*gh) != 1) {
-		LOGPLCHAN(msg->lchan, DMSC, LOGL_ERROR, "Assignment Compl invalid: %zu\n",
-			  msgb_l3len(msg) - sizeof(*gh));
+		LOGPLCHAN(msg->lchan, DRR, LOGL_ERROR,
+			  "RR Assignment Complete does not match conn's secondary lchan.\n");
 		return;
 	}
 
@@ -391,7 +393,7 @@
 	if (is_ipaccess_bts(conn_get_bts(conn)) && conn->lchan->tch_mode != GSM48_CMODE_SIGN)
 		rsl_ipacc_crcx(conn->lchan);
 
-	api->assign_compl(conn, gh->data[0]);
+	api->assign_compl(conn, cause);
 }
 
 static void handle_ass_fail(struct gsm_subscriber_connection *conn,

-- 
To view, visit https://gerrit.osmocom.org/9230
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Idcfd932d3dfb0b621ed6d8c4f92c0231abcdcec8
Gerrit-Change-Number: 9230
Gerrit-PatchSet: 1
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20180517/043ea823/attachment.htm>


More information about the gerrit-log mailing list