Change in libosmocore[master]: gprs_ns2: ensure the NSE becomes dead when FR link went down

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Jul 12 15:04:55 UTC 2021


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


Change subject: gprs_ns2: ensure the NSE becomes dead when FR link went down
......................................................................

gprs_ns2: ensure the NSE becomes dead when FR link went down

The FR code is using force unconfigured to change the state of the NSVC
when the FR link goes down. The force unconfigured state didn't
notified the NSE when changing into this state.

Related: SYS#5533
Change-Id: I4d7bbbbce26f7cde99eebe96995c50b1e812e5bd
---
M src/gb/gprs_ns2_vc_fsm.c
M tests/gb/gprs_ns2_test.c
M tests/gb/gprs_ns2_test.ok
3 files changed, 62 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/22/24922/1

diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 05118b2..1f680f4 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -254,7 +254,10 @@
 
 static void ns2_st_unconfigured_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
 {
+	struct gprs_ns2_vc_priv *priv = fi->priv;
+
 	stop_test_procedure(fi->priv);
+	ns2_nse_notify_unblocked(priv->nsvc, false);
 }
 
 static void ns2_st_unconfigured(struct osmo_fsm_inst *fi, uint32_t event, void *data)
diff --git a/tests/gb/gprs_ns2_test.c b/tests/gb/gprs_ns2_test.c
index b96e739..e4756d2 100644
--- a/tests/gb/gprs_ns2_test.c
+++ b/tests/gb/gprs_ns2_test.c
@@ -592,6 +592,57 @@
 	printf("--- Finish unitdata test\n");
 }
 
+void test_unconfigured(void *ctx)
+{
+	struct gprs_ns2_inst *nsi;
+	struct gprs_ns2_vc_bind *bind[2];
+	struct gprs_ns2_vc_bind *loopbind;
+	struct gprs_ns2_nse *nse;
+	struct gprs_ns2_vc *nsvc[2];
+	struct gprs_ns2_vc *loop[2];
+
+	struct msgb *msg, *other;
+	char idbuf[32];
+	int i;
+
+	printf("--- Testing force unconfigured\n");
+	osmo_wqueue_clear(unitdata);
+	printf("---- Create NSE + Binds\n");
+	nsi = gprs_ns2_instantiate(ctx, ns_prim_cb, NULL);
+	bind[0] = dummy_bind(nsi, "bblock1");
+	bind[1] = dummy_bind(nsi, "bblock2");
+	loopbind = loopback_bind(nsi, "loopback");
+	nse = gprs_ns2_create_nse(nsi, 1004, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_RESETBLOCK);
+	OSMO_ASSERT(nse);
+
+	for (i=0; i<2; i++) {
+		printf("---- Create NSVC[%d]\n", i);
+		snprintf(idbuf, sizeof(idbuf), "NSE%05u-dummy-%i", nse->nsei, i);
+		nsvc[i] = ns2_vc_alloc(bind[i], nse, false, GPRS_NS2_VC_MODE_BLOCKRESET, idbuf);
+		loop[i] = loopback_nsvc(loopbind, nsvc[i]);
+		OSMO_ASSERT(nsvc[i]);
+		ns2_vc_fsm_start(nsvc[i]);
+		OSMO_ASSERT(!ns2_vc_is_unblocked(nsvc[i]));
+		ns2_tx_reset(loop[i], NS_CAUSE_OM_INTERVENTION);
+		ns2_tx_unblock(loop[i]);
+		OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[i]));
+	}
+
+	/* both nsvcs are unblocked and alive */
+	printf("---- Check if NSE should be alive\n");
+	OSMO_ASSERT(nse->alive);
+
+	ns2_vc_force_unconfigured(nsvc[0]);
+	OSMO_ASSERT(nse->alive);
+
+	ns2_vc_force_unconfigured(nsvc[1]);
+	printf("---- Check if NSE should be dead\n");
+	OSMO_ASSERT(!nse->alive);
+
+	gprs_ns2_free(nsi);
+	printf("--- Finish force unconfigured test\n");
+}
+
 int main(int argc, char **argv)
 {
 	void *ctx = talloc_named_const(NULL, 0, "gprs_ns2_test");
@@ -611,6 +662,7 @@
 	test_block_unblock_nsvc2(ctx);
 	test_unitdata(ctx);
 	test_unitdata_weights(ctx);
+	test_unconfigured(ctx);
 	test_mtu(ctx);
 	printf("===== NS2 protocol test END\n\n");
 
diff --git a/tests/gb/gprs_ns2_test.ok b/tests/gb/gprs_ns2_test.ok
index 148b6a4..8bae5b9 100644
--- a/tests/gb/gprs_ns2_test.ok
+++ b/tests/gb/gprs_ns2_test.ok
@@ -33,6 +33,13 @@
 ---- Send UNITDATA to all NSVCs
 ---- Send BSSGP data to the NSE to test unitdata over NSVC[1]
 --- Finish unitdata weight test
+--- Testing force unconfigured
+---- Create NSE + Binds
+---- Create NSVC[0]
+---- Create NSVC[1]
+---- Check if NSE should be alive
+---- Check if NSE should be dead
+--- Finish force unconfigured test
 --- Testing mtu test
 ---- Create NSE + Binds
 ---- Create NSVC[0]

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

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I4d7bbbbce26f7cde99eebe96995c50b1e812e5bd
Gerrit-Change-Number: 24922
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/20210712/090461a4/attachment.htm>


More information about the gerrit-log mailing list