Change in osmo-msc[master]: sgs_iface: detect and react to VLR/HLR failure

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

dexter gerrit-no-reply at lists.osmocom.org
Tue Apr 9 15:43:45 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/13559


Change subject: sgs_iface: detect and react to VLR/HLR failure
......................................................................

sgs_iface: detect and react to VLR/HLR failure

The HLR (which is connected via the GSUP interface) may fail and
disconnect. On the next location update the VLR will try to talk to the
HLR and fail. This failure event is not communicated towards the SGs
related code and the SGs-association will remain in the LA-PRESENT state
forever. Lets add code to report the problem to the SGs code and trigger
a RESET an the SGs interface.

- Add a flag to report an HLR problem back to the SGs code
- Fix the FSM that controls the reset
- Make sure the all SGs associations are reset when the failure occurs.

Change-Id: Icc7df92879728bc98c85fc1d5d8b4c6246501b12
Related: OS#3859
---
M include/osmocom/msc/vlr_sgs.h
M src/libmsc/sgs_iface.c
M src/libvlr/vlr.c
M src/libvlr/vlr_sgs_fsm.c
4 files changed, 50 insertions(+), 20 deletions(-)



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

diff --git a/include/osmocom/msc/vlr_sgs.h b/include/osmocom/msc/vlr_sgs.h
index cc07807..615b56c 100644
--- a/include/osmocom/msc/vlr_sgs.h
+++ b/include/osmocom/msc/vlr_sgs.h
@@ -72,6 +72,7 @@
 /* This callback function is called when an SGs location update is complete */
 struct sgs_lu_response {
 	bool accepted;
+	bool error;
 	struct vlr_subscr *vsub;
 };
 typedef void (*vlr_sgs_lu_response_cb_t) (struct sgs_lu_response *response);
diff --git a/src/libmsc/sgs_iface.c b/src/libmsc/sgs_iface.c
index 450d552..6ee2075 100644
--- a/src/libmsc/sgs_iface.c
+++ b/src/libmsc/sgs_iface.c
@@ -369,15 +369,26 @@
 	unsigned int new_id_len = 0;
 	uint8_t resp_msg_type;
 
+	/* Determine message type that is sent next (needed for logging) */
 	if (response->accepted)
 		resp_msg_type = SGSAP_MSGT_LOC_UPD_ACK;
+	else if(response->error)
+		resp_msg_type = SGSAP_MSGT_RESET_IND;
 	else
 		resp_msg_type = SGSAP_MSGT_LOC_UPD_REJ;
 
+	/* Determine MME */
 	mme = sgs_mme_ctx_by_vsub(vsub, resp_msg_type);
 	if (!mme)
 		return;
 
+	/* Handle error (HLR failure) */
+	if (response->error) {
+		osmo_fsm_inst_dispatch(mme->fi, SGS_VLRR_E_START_RESET, NULL);
+		return;
+	}
+
+	/* Handle LU accept/reject */
 	if (response->accepted) {
 		if (vsub->tmsi_new != GSM_RESERVED_TMSI) {
 			new_id_len = gsm48_generate_mid_from_tmsi(new_id, vsub->tmsi_new);
@@ -1101,6 +1112,10 @@
 		reset_params.vlr_name_present = true;
 		reset_ind = gsm29118_create_reset_ind(&reset_params);
 		sgs_tx(sgc, reset_ind);
+
+		/* Perform a reset of the SGS FSM of all subscribers that are present in the VLR */
+		vlr_sgs_reset(gsm_network->vlr);
+
 		osmo_fsm_inst_state_chg(fi, SGS_VLRR_ST_WAIT_ACK, sgs->cfg.timer[SGS_STATE_TS11], 11);
 		break;
 	default:
@@ -1168,6 +1183,7 @@
 static struct osmo_fsm sgs_vlr_reset_fsm = {
 	.name = "SGs-VLR-RESET",
 	.states = sgs_vlr_reset_fsm_states,
+	.num_states = ARRAY_SIZE(sgs_vlr_reset_fsm_states),
 	.allstate_event_mask = S(SGS_VLRR_E_START_RESET),
 	.allstate_action = sgs_vlr_reset_fsm_allstate,
 	.timer_cb = sgs_vlr_reset_fsm_timer_cb,
diff --git a/src/libvlr/vlr.c b/src/libvlr/vlr.c
index cd4209d..957b7e7 100644
--- a/src/libvlr/vlr.c
+++ b/src/libvlr/vlr.c
@@ -864,7 +864,7 @@
 static int vlr_subscr_handle_lu_res(struct vlr_subscr *vsub,
 				    const struct osmo_gsup_message *gsup)
 {
-	struct sgs_lu_response sgs_lu_response;
+	struct sgs_lu_response sgs_lu_response = {0};
 	bool sgs_lu_in_progress = false;
 
 	if (vsub->sgs_fsm->state == SGS_UE_ST_LA_UPD_PRES)
@@ -895,7 +895,7 @@
 static int vlr_subscr_handle_lu_err(struct vlr_subscr *vsub,
 				    const struct osmo_gsup_message *gsup)
 {
-	struct sgs_lu_response sgs_lu_response;
+	struct sgs_lu_response sgs_lu_response = {0};
 	bool sgs_lu_in_progress = false;
 
 	if (vsub->sgs_fsm->state == SGS_UE_ST_LA_UPD_PRES)
diff --git a/src/libvlr/vlr_sgs_fsm.c b/src/libvlr/vlr_sgs_fsm.c
index ee1d748..053701e 100644
--- a/src/libvlr/vlr_sgs_fsm.c
+++ b/src/libvlr/vlr_sgs_fsm.c
@@ -47,24 +47,6 @@
 	{0, NULL}
 };
 
-/* Initiate location update and change to SGS_UE_ST_LA_UPD_PRES state */
-static void perform_lu(struct osmo_fsm_inst *fi)
-{
-	struct vlr_subscr *vsub = fi->priv;
-	int rc;
-	osmo_fsm_inst_state_chg(fi, SGS_UE_ST_LA_UPD_PRES, 0, 0);
-	vsub->ms_not_reachable_flag = false;
-
-	/* Note: At the moment we allocate a new TMSI on each LU. */
-	rc = vlr_subscr_alloc_tmsi(vsub);
-	if (rc != 0)
-		LOGPFSML(fi, LOGL_ERROR, "(sub %s) VLR LU tmsi allocation failed\n", vlr_subscr_name(vsub));
-
-	rc = vlr_subscr_req_lu(vsub);
-	if (rc != 0)
-		LOGPFSML(fi, LOGL_ERROR, "(sub %s) HLR LU request failed\n", vlr_subscr_name(vsub));
-}
-
 /* Send the SGs Association to NULL state immediately */
 static void to_null(struct osmo_fsm_inst *fi)
 {
@@ -84,6 +66,37 @@
 		osmo_timer_del(&vsub->sgs.Ts5);
 }
 
+/* Initiate location update and change to SGS_UE_ST_LA_UPD_PRES state */
+static void perform_lu(struct osmo_fsm_inst *fi)
+{
+	struct vlr_subscr *vsub = fi->priv;
+	struct sgs_lu_response sgs_lu_response = {0};
+	int rc;
+
+	/* Note: At the moment we allocate a new TMSI on each LU. */
+	rc = vlr_subscr_alloc_tmsi(vsub);
+	if (rc != 0) {
+		LOGPFSML(fi, LOGL_ERROR, "(sub %s) VLR LU tmsi allocation failed\n", vlr_subscr_name(vsub));
+		goto error;
+	}
+
+	rc = vlr_subscr_req_lu(vsub);
+	if (rc != 0) {
+		LOGPFSML(fi, LOGL_ERROR, "(sub %s) HLR LU request failed\n", vlr_subscr_name(vsub));
+		goto error;
+	}
+
+	osmo_fsm_inst_state_chg(fi, SGS_UE_ST_LA_UPD_PRES, 0, 0);
+	vsub->ms_not_reachable_flag = false;
+	return;
+	
+error:
+	to_null(fi);
+	sgs_lu_response.error = true;
+	sgs_lu_response.vsub = vsub;
+	vsub->sgs.response_cb(&sgs_lu_response);
+}
+
 /* Respawn a pending paging (Timer is reset and a new paging request is sent) */
 static void respawn_paging(struct vlr_subscr *vsub)
 {

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

Gerrit-Project: osmo-msc
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Icc7df92879728bc98c85fc1d5d8b4c6246501b12
Gerrit-Change-Number: 13559
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190409/6bf31354/attachment.htm>


More information about the gerrit-log mailing list