Change in osmo-bsc[master]: compl l3: allocate conn in gsm_08_08.c, not gsm_04_08_rr.c

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 gerrit-no-reply at lists.osmocom.org
Thu Oct 1 04:11:07 UTC 2020


neels has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-bsc/+/20343 )


Change subject: compl l3: allocate conn in gsm_08_08.c, not gsm_04_08_rr.c
......................................................................

compl l3: allocate conn in gsm_08_08.c, not gsm_04_08_rr.c

Move conn allocation to bsc_compl_l3(), from gsm0408_rcvmsg().

Drop dispatch of GSCON_EV_A_DISC_IND, because a) we did not receive such
DISC.IND, and b) the lchan release will discard the conn in the regular
fashion.

In upcoming LCS patch, bsc_compl_l3() will decide whether to allocate a new
conn or whether a conn from a Perform Location Request already exists for the
subscriber.

In this patch, it becomes clear that the conn->bsub is always NULL in
bsc_compl_l3(), and that the 'log_set_context(LOG_CTX_BSC_SUBSCR, conn->bsub);'
never has the intended effect. An upcoming patch will change that.

Change-Id: I92af0f0d54c4282d782f2b29d524a64006c3b674
---
M include/osmocom/bsc/gsm_08_08.h
M src/osmo-bsc/gsm_04_08_rr.c
M src/osmo-bsc/gsm_08_08.c
M tests/bsc/bsc_test.c
M tests/gsm0408/gsm0408_test.c
M tests/handover/handover_test.c
6 files changed, 23 insertions(+), 21 deletions(-)



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

diff --git a/include/osmocom/bsc/gsm_08_08.h b/include/osmocom/bsc/gsm_08_08.h
index 80da297..da5e2f1 100644
--- a/include/osmocom/bsc/gsm_08_08.h
+++ b/include/osmocom/bsc/gsm_08_08.h
@@ -8,7 +8,7 @@
 
 void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, uint8_t dlci, enum gsm0808_cause cause);
 void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t chosen_encr);
-int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel);
+int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_channel);
 void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg);
 void bsc_cm_update(struct gsm_subscriber_connection *conn,
 		   const uint8_t *cm2, uint8_t cm2_len,
diff --git a/src/osmo-bsc/gsm_04_08_rr.c b/src/osmo-bsc/gsm_04_08_rr.c
index a7bba0d..49ec848 100644
--- a/src/osmo-bsc/gsm_04_08_rr.c
+++ b/src/osmo-bsc/gsm_04_08_rr.c
@@ -1015,7 +1015,6 @@
 int gsm0408_rcvmsg(struct msgb *msg, uint8_t link_id)
 {
 	struct gsm_lchan *lchan;
-	int rc;
 
 	lchan = msg->lchan;
 	if (!lchan_may_receive_data(lchan)) {
@@ -1028,21 +1027,8 @@
 		 * MSC */
 		dispatch_dtap(lchan->conn, link_id, msg);
 	} else {
-		/* allocate a new connection */
-		lchan->conn = bsc_subscr_con_allocate(msg->lchan->ts->trx->bts->network);
-		if (!lchan->conn) {
-			lchan_release(lchan, false, true, RSL_ERR_EQUIPMENT_FAIL);
-			return -1;
-		}
-		lchan->conn->lchan = lchan;
-
 		/* fwd via bsc_api to send COMPLETE L3 INFO to MSC */
-		rc = bsc_compl_l3(lchan->conn, msg, 0);
-		if (rc < 0) {
-			osmo_fsm_inst_dispatch(lchan->conn->fi, GSCON_EV_A_DISC_IND, NULL);
-			return rc;
-		}
-		/* conn shall release lchan on teardown, also if this Layer 3 Complete is rejected. */
+		return bsc_compl_l3(lchan, msg, 0);
 	}
 
 	return 0;
diff --git a/src/osmo-bsc/gsm_08_08.c b/src/osmo-bsc/gsm_08_08.c
index 7741939..5a25aad 100644
--- a/src/osmo-bsc/gsm_08_08.c
+++ b/src/osmo-bsc/gsm_08_08.c
@@ -25,6 +25,7 @@
 #include <osmocom/bsc/paging.h>
 #include <osmocom/bsc/gsm_08_08.h>
 #include <osmocom/bsc/codec_pref.h>
+#include <osmocom/bsc/lchan_fsm.h>
 
 #include <osmocom/bsc/gsm_04_08_rr.h>
 #include <osmocom/bsc/a_reset.h>
@@ -428,8 +429,9 @@
 }
 
 /*! MS->MSC: New MM context with L3 payload. */
-int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel)
+int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_channel)
 {
+	struct gsm_subscriber_connection *conn;
 	struct bsc_msc_data *msc;
 	struct msgb *create_l3;
 	struct gsm0808_speech_codec_list scl;
@@ -440,6 +442,7 @@
 	struct osmo_mobile_identity mi;
 	struct gsm48_hdr *gh;
 	uint8_t pdisc, mtype;
+	bool release_lchan = true;
 
 	if (msgb_l3len(msg) < sizeof(*gh)) {
 		LOGP(DRSL, LOGL_ERROR, "There is no GSM48 header here.\n");
@@ -461,6 +464,15 @@
 		 */
 	}
 
+	/* allocate a new connection */
+	conn = bsc_subscr_con_allocate(bsc_gsmnet);
+	if (!conn) {
+		LOG_COMPL_L3(pdisc, mtype, LOGL_ERROR, "Failed to allocate conn\n");
+		goto early_fail;
+	}
+	gscon_change_primary_lchan(conn, lchan);
+	gscon_update_id(conn);
+
 	log_set_context(LOG_CTX_BSC_SUBSCR, conn->bsub);
 
 	/* find the MSC link we want to use */
@@ -511,8 +523,12 @@
 		goto early_fail;
 	}
 	rc = osmo_fsm_inst_dispatch(conn->fi, GSCON_EV_A_CONN_REQ, create_l3);
+	if (!rc)
+		release_lchan = false;
 
 early_fail:
+	if (release_lchan)
+		lchan_release(lchan, false, true, RSL_ERR_EQUIPMENT_FAIL);
 	log_set_context(LOG_CTX_BSC_SUBSCR, NULL);
 	return rc;
 }
diff --git a/tests/bsc/bsc_test.c b/tests/bsc/bsc_test.c
index d999608..6a6ff8b 100644
--- a/tests/bsc/bsc_test.c
+++ b/tests/bsc/bsc_test.c
@@ -225,7 +225,7 @@
 
 void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, uint8_t dlci, enum gsm0808_cause cause) {}
 void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t chosen_encr) {}
-int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel)
+int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_channel)
 { return 0; }
 void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg) {}
 void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_cause) {}
diff --git a/tests/gsm0408/gsm0408_test.c b/tests/gsm0408/gsm0408_test.c
index 35531f8..8ee29f7 100644
--- a/tests/gsm0408/gsm0408_test.c
+++ b/tests/gsm0408/gsm0408_test.c
@@ -952,8 +952,8 @@
 
 bool lchan_may_receive_data(struct gsm_lchan *lchan) { return  true; }
 
-int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg,
-		 uint16_t chosen_channel) { return 0; }
+int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_channel)
+{ return 0; }
 
 void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id,
 	      struct msgb *msg) {}
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index 78e8daf..ba0ec21 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -1796,7 +1796,7 @@
 int osmo_bsc_sigtran_open_conn(struct gsm_subscriber_connection *conn, struct msgb *msg) { return 0; }
 void bsc_sapi_n_reject(struct gsm_subscriber_connection *conn, uint8_t dlci, enum gsm0808_cause cause) {}
 void bsc_cipher_mode_compl(struct gsm_subscriber_connection *conn, struct msgb *msg, uint8_t chosen_encr) {}
-int bsc_compl_l3(struct gsm_subscriber_connection *conn, struct msgb *msg, uint16_t chosen_channel)
+int bsc_compl_l3(struct gsm_lchan *lchan, struct msgb *msg, uint16_t chosen_channel)
 { return 0; }
 void bsc_dtap(struct gsm_subscriber_connection *conn, uint8_t link_id, struct msgb *msg) {}
 void bsc_assign_compl(struct gsm_subscriber_connection *conn, uint8_t rr_cause) {}

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-Change-Id: I92af0f0d54c4282d782f2b29d524a64006c3b674
Gerrit-Change-Number: 20343
Gerrit-PatchSet: 1
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201001/c462407e/attachment.htm>


More information about the gerrit-log mailing list