aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Couzens <lynxis@fe80.eu>2021-06-15 21:35:45 +0200
committerlaforge <laforge@osmocom.org>2021-06-25 08:12:39 +0000
commite09deb63552370a2603e00413001223c8ea10c1c (patch)
tree55eeb4a80ec182d3b0926c1dc51d2b1b5660d736
parentd5cd8c61cb17f94184e3fd9f3123861d86f060ba (diff)
gprs_ns2: fix missing notify towards the NSE when NSVC become blocked
The NSE wasn't notified when a NSVC went into the BLOCKED state from an UNBLOCKED state. Related: OS#5182 Change-Id: I09634e414e9bb966e6b5809b7de1b59fbabd413d
-rw-r--r--src/gb/gprs_ns2_vc_fsm.c1
-rw-r--r--tests/gb/gprs_ns2_test.c67
-rw-r--r--tests/gb/gprs_ns2_test.ok5
3 files changed, 73 insertions, 0 deletions
diff --git a/src/gb/gprs_ns2_vc_fsm.c b/src/gb/gprs_ns2_vc_fsm.c
index 341a5a1a..70258ccd 100644
--- a/src/gb/gprs_ns2_vc_fsm.c
+++ b/src/gb/gprs_ns2_vc_fsm.c
@@ -338,6 +338,7 @@ static void ns2_st_blocked_onenter(struct osmo_fsm_inst *fi, uint32_t old_state)
rate_ctr_inc(rate_ctr_group_get_ctr(priv->nsvc->ctrg, NS_CTR_BLOCKED));
}
+ ns2_nse_notify_unblocked(priv->nsvc, false);
if (priv->om_blocked) {
/* we are already blocked after a RESET */
if (old_state == GPRS_NS2_ST_RESET) {
diff --git a/tests/gb/gprs_ns2_test.c b/tests/gb/gprs_ns2_test.c
index cc1b2f1f..c53cc6d6 100644
--- a/tests/gb/gprs_ns2_test.c
+++ b/tests/gb/gprs_ns2_test.c
@@ -302,6 +302,72 @@ void test_block_unblock_nsvc(void *ctx)
printf("--- Finish NSE block unblock nsvc\n");
}
+/* setup NSE with 2x NSVCs.
+ * block 1st NSVC
+ * block 2nd NSVC
+ * unblock 1st NSVC */
+void test_block_unblock_nsvc2(void *ctx)
+{
+ struct gprs_ns2_inst *nsi;
+ struct gprs_ns2_vc_bind *bind[2];
+ struct gprs_ns2_nse *nse;
+ struct gprs_ns2_vc *nsvc[2];
+ struct gprs_ns_hdr *nsh;
+ struct msgb *msg;
+ char idbuf[32];
+ int i;
+
+ printf("--- Testing NSE block unblock nsvc2\n");
+ 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");
+ nse = gprs_ns2_create_nse(nsi, 1001, GPRS_NS2_LL_UDP, GPRS_NS2_DIALECT_STATIC_RESETBLOCK);
+ OSMO_ASSERT(nse);
+
+ for (i=0; i<2; i++) {
+ printf("---- Create NSVC[i]\n");
+ 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);
+ OSMO_ASSERT(nsvc[i]);
+ nsvc[i]->fi->state = 3; /* HACK: 3 = GPRS_NS2_ST_UNBLOCKED */
+ /* ensure the fi->state works correct */
+ OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[i]));
+ ns2_nse_notify_unblocked(nsvc[i], true);
+ }
+
+ OSMO_ASSERT(nse->alive);
+ /* both nsvcs are unblocked and alive. Let's block them. */
+ OSMO_ASSERT(!find_pdu(bind[0], NS_PDUT_BLOCK));
+ clear_pdus(bind[0]);
+ ns2_vc_block(nsvc[0]);
+ OSMO_ASSERT(find_pdu(bind[0], NS_PDUT_BLOCK));
+ clear_pdus(bind[0]);
+ OSMO_ASSERT(nse->alive);
+
+ OSMO_ASSERT(!find_pdu(bind[1], NS_PDUT_BLOCK));
+ clear_pdus(bind[1]);
+ ns2_vc_block(nsvc[1]);
+ OSMO_ASSERT(find_pdu(bind[1], NS_PDUT_BLOCK));
+ clear_pdus(bind[1]);
+ OSMO_ASSERT(!nse->alive);
+
+ /* now unblocking the 1st NSVC */
+ ns2_vc_unblock(nsvc[0]);
+ OSMO_ASSERT(find_pdu(bind[0], NS_PDUT_UNBLOCK));
+ clear_pdus(bind[0]);
+ msg = msgb_alloc_headroom(NS_ALLOC_SIZE, NS_ALLOC_HEADROOM, "test_unblock");
+ msg->l2h = msgb_put(msg, sizeof(*nsh));
+ nsh = (struct gprs_ns_hdr *) msg->l2h;
+ nsh->pdu_type = NS_PDUT_UNBLOCK_ACK;
+ ns2_recv_vc(nsvc[0], msg);
+ OSMO_ASSERT(nse->alive);
+
+ OSMO_ASSERT(ns2_vc_is_unblocked(nsvc[0]));
+ gprs_ns2_free(nsi);
+ printf("--- Finish NSE block unblock nsvc2\n");
+}
+
static struct msgb *generate_unitdata(const char *msgname)
{
struct gprs_ns_hdr *nsh;
@@ -533,6 +599,7 @@ int main(int argc, char **argv)
printf("===== NS2 protocol test START\n");
test_nse_transfer_cap(ctx);
test_block_unblock_nsvc(ctx);
+ test_block_unblock_nsvc2(ctx);
test_unitdata(ctx);
test_unitdata_weights(ctx);
test_mtu(ctx);
diff --git a/tests/gb/gprs_ns2_test.ok b/tests/gb/gprs_ns2_test.ok
index 40a1528b..148b6a46 100644
--- a/tests/gb/gprs_ns2_test.ok
+++ b/tests/gb/gprs_ns2_test.ok
@@ -11,6 +11,11 @@
---- Create NSVC[i]
---- Create NSVC[i]
--- Finish NSE block unblock nsvc
+--- Testing NSE block unblock nsvc2
+---- Create NSE + Binds
+---- Create NSVC[i]
+---- Create NSVC[i]
+--- Finish NSE block unblock nsvc2
--- Testing unitdata test
---- Create NSE + Binds
---- Create NSVC[0]