From a140d44a4f1c362f8dc0bc25d876852a455eed6a Mon Sep 17 00:00:00 2001 From: Alexander Couzens Date: Mon, 12 Jul 2021 16:42:32 +0200 Subject: 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 --- tests/gb/gprs_ns2_test.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ tests/gb/gprs_ns2_test.ok | 7 +++++++ 2 files changed, 58 insertions(+) (limited to 'tests') diff --git a/tests/gb/gprs_ns2_test.c b/tests/gb/gprs_ns2_test.c index b96e739f..ad78a621 100644 --- a/tests/gb/gprs_ns2_test.c +++ b/tests/gb/gprs_ns2_test.c @@ -592,6 +592,56 @@ void test_mtu(void *ctx) 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]; + + 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 is 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 is 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 +661,7 @@ int main(int argc, char **argv) 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 148b6a46..16e66bb8 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 is alive +---- Check if NSE is dead +--- Finish force unconfigured test --- Testing mtu test ---- Create NSE + Binds ---- Create NSVC[0] -- cgit v1.2.3