Change in libosmocore[master]: gprs_ns2: sns: move alive timeout into own variable

lynxis lazus gerrit-no-reply at lists.osmocom.org
Tue Mar 2 09:15:16 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/23185 )


Change subject: gprs_ns2: sns: move alive timeout into own variable
......................................................................

gprs_ns2: sns: move alive timeout into own variable

It allows to span the timeout across fsm states.
In prepration to add a new state for local procedures.

Change-Id: I4b223118c7f250dbc8161cbf29cbd994c26c362f
---
M src/gb/gprs_ns2_sns.c
1 file changed, 17 insertions(+), 6 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/85/23185/1

diff --git a/src/gb/gprs_ns2_sns.c b/src/gb/gprs_ns2_sns.c
index a82da95..86b4fdf 100644
--- a/src/gb/gprs_ns2_sns.c
+++ b/src/gb/gprs_ns2_sns.c
@@ -137,6 +137,8 @@
 	int N;
 	/* true if at least one nsvc is alive */
 	bool alive;
+	/* alive timeout, to ensure at least one NSVC comes after X online */
+	struct osmo_timer_list alive_timeout;
 
 	/* local configuration to send to the remote end */
 	struct gprs_ns_ie_ip4_elem *ip4_local;
@@ -959,7 +961,8 @@
 		ns2_tx_sns_config_ack(gss->sns_nsvc, NULL);
 		/* start the test procedure on ALL NSVCs! */
 		gprs_ns2_start_alive_all_nsvcs(nse);
-		osmo_fsm_inst_state_chg(fi, GPRS_SNS_ST_CONFIGURED, ns_sns_configured_timeout(fi), 4);
+		osmo_timer_schedule(&gss->alive_timeout, ns_sns_configured_timeout(fi), 0);
+		osmo_fsm_inst_state_chg(fi, GPRS_SNS_ST_CONFIGURED, 0, 4);
 	} else {
 		/* just send CONFIG-ACK */
 		ns2_tx_sns_config_ack(gss->sns_nsvc, NULL);
@@ -1312,7 +1315,7 @@
 		ns2_sns_st_configured_change(fi, gss, tp);
 		break;
 	case GPRS_SNS_EV_REQ_NSVC_ALIVE:
-		osmo_timer_del(&fi->timer);
+		osmo_timer_del(&gss->alive_timeout);
 		break;
 	}
 }
@@ -1373,6 +1376,17 @@
 	},
 };
 
+/* timer to ensure the SNS doesn't configure NSVC, but then no NSVC come alive afterwards */
+static void ns2_sns_timeout_alive_cb(void *data)
+{
+	struct osmo_fsm_inst *fi = data;
+	struct gprs_ns2_nse *nse = nse_inst_from_fi(fi);
+
+	LOGPFSML(fi, LOGL_ERROR, "NSE %d: Config succeeded but no NS-VC came online. Selecting next IP-SNS endpoint.\n", nse->nsei);
+	osmo_fsm_inst_dispatch(fi, GPRS_SNS_EV_REQ_SELECT_ENDPOINT, NULL);
+}
+
+
 static int ns2_sns_fsm_bss_timer_cb(struct osmo_fsm_inst *fi)
 {
 	struct ns2_sns_state *gss = (struct ns2_sns_state *) fi->priv;
@@ -1405,10 +1419,6 @@
 			osmo_fsm_inst_state_chg(fi, GPRS_SNS_ST_CONFIG_SGSN, nsi->timeout[NS_TOUT_TSNS_PROV], 3);
 		}
 		break;
-	case 4:
-		LOGPFSML(fi, LOGL_ERROR, "NSE %d: Config succeeded but no NS-VC came online. Selecting next IP-SNS endpoint.\n", nse->nsei);
-		osmo_fsm_inst_dispatch(fi, GPRS_SNS_EV_REQ_SELECT_ENDPOINT, NULL);
-		break;
 	}
 	return 0;
 }
@@ -1542,6 +1552,7 @@
 	gss->nse = nse;
 	INIT_LLIST_HEAD(&gss->sns_endpoints);
 	INIT_LLIST_HEAD(&gss->binds);
+	osmo_timer_setup(&gss->alive_timeout, ns2_sns_timeout_alive_cb, fi);
 
 	return fi;
 err:

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4b223118c7f250dbc8161cbf29cbd994c26c362f
Gerrit-Change-Number: 23185
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210302/af146d02/attachment.htm>


More information about the gerrit-log mailing list