Change in osmo-bsc[master]: LCLS: move mode check into separate function

Max gerrit-no-reply at lists.osmocom.org
Sun Nov 18 21:01:34 UTC 2018


Max has submitted this change and it was merged. ( https://gerrit.osmocom.org/11551 )

Change subject: LCLS: move mode check into separate function
......................................................................

LCLS: move mode check into separate function

Before closing or breaking the loop in LCLS we do preliminary
checks. To facilitate adding new LCLS modes it's restructured as
follows:

* move check into dedicated static function
* explicitly check for MGW mode in endpoint check
* check for mode mismatch

Change-Id: I32ba232ad802625d97a0ad9d0511edc6ac7f251c
Related: OS#3659
---
M src/osmo-bsc/osmo_bsc_lcls.c
1 file changed, 25 insertions(+), 8 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/src/osmo-bsc/osmo_bsc_lcls.c b/src/osmo-bsc/osmo_bsc_lcls.c
index a25faa4..81daaf0 100644
--- a/src/osmo-bsc/osmo_bsc_lcls.c
+++ b/src/osmo-bsc/osmo_bsc_lcls.c
@@ -227,6 +227,26 @@
 	osmo_fsm_inst_dispatch(conn->lcls.fi, LCLS_EV_APPLY_CFG_CSC, NULL);
 }
 
+static inline bool lcls_check_toggle_allowed(const struct gsm_subscriber_connection *conn, bool enable)
+{
+	if (conn->lcls.other &&
+	    conn->sccp.msc->lcls_mode != conn->lcls.other->sccp.msc->lcls_mode) {
+		LOGPFSM(conn->lcls.fi, "FIXME: LCLS connection mode mismatch: %s != %s\n",
+			get_value_string(bsc_lcls_mode_names, conn->sccp.msc->lcls_mode),
+			get_value_string(bsc_lcls_mode_names, conn->lcls.other->sccp.msc->lcls_mode));
+		return false;
+	}
+
+	if (conn->sccp.msc->lcls_mode == BSC_LCLS_MODE_MGW_LOOP && !conn->user_plane.mgw_endpoint_ci_msc) {
+		/* the MGCP FSM has died, e.g. due to some MGCP/SDP parsing error */
+		LOGPFSML(conn->lcls.fi, LOGL_NOTICE, "Cannot %s LCLS without MSC-side MGCP FSM\n",
+			 enable ? "enable" : "disable");
+		return false;
+	}
+
+	return true;
+}
+
 /* Close the loop for LCLS using MGCP */
 static inline void lcls_mdcx(const struct gsm_subscriber_connection *conn, struct mgcp_conn_peer *mdcx_info)
 {
@@ -242,11 +262,8 @@
 	LOGPFSM(conn->lcls.fi, "=== HERE IS WHERE WE DISABLE LCLS(%s)\n",
 		bsc_lcls_mode_name(conn->sccp.msc->lcls_mode));
 
-	if (!conn->user_plane.mgw_endpoint_ci_msc) {
-		/* the MGCP FSM has died, e.g. due to some MGCP/SDP parsing error */
-		LOGPFSML(conn->lcls.fi, LOGL_NOTICE, "Cannot disable LCLS without MSC-side MGCP FSM\n");
+	if (!lcls_check_toggle_allowed(conn, false))
 		return;
-	}
 
 	if (conn->sccp.msc->lcls_mode == BSC_LCLS_MODE_MGW_LOOP) {
 		struct mgcp_conn_peer mdcx_info = (struct mgcp_conn_peer){
@@ -583,12 +600,12 @@
 
 	OSMO_ASSERT(conn_other);
 
+	if (!lcls_check_toggle_allowed(conn, true))
+		return;
+
 	LOGPFSM(fi, "=== HERE IS WHERE WE ENABLE LCLS(%s)\n",
 		bsc_lcls_mode_name(conn->sccp.msc->lcls_mode));
-	if (!conn->user_plane.mgw_endpoint_ci_msc) {
-		LOGPFSML(fi, LOGL_ERROR, "Cannot enable LCLS without MSC-side MGCP FSM. FIXME\n");
-		return;
-	}
+
 	if (!conn_other->user_plane.mgw_endpoint_ci_msc) {
 		LOGPFSML(fi, LOGL_ERROR, "Cannot enable LCLS without MSC-side MGCP FSM. FIXME\n");
 		return;

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

Gerrit-Project: osmo-bsc
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I32ba232ad802625d97a0ad9d0511edc6ac7f251c
Gerrit-Change-Number: 11551
Gerrit-PatchSet: 8
Gerrit-Owner: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Max <msuraev at sysmocom.de>
Gerrit-Reviewer: Neels Hofmeyr <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181118/0da12197/attachment.html>


More information about the gerrit-log mailing list