[PATCH 2/2] gb: Fix gprs_active_nsvc_by_nsei()

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/OpenBSC@lists.osmocom.org/.

Jacob Erlbeck jerlbeck at sysmocom.de
Thu Oct 17 10:05:58 UTC 2013


The state matching condition is inverted. This is corrected by this
fix.

Sponsored-by: On-Waves ehf
---
 src/gb/gprs_ns.c         |    4 ++--
 tests/gb/gprs_ns_test.ok |   42 ++++++++++++++++++++++++++++++------------
 2 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index bdc7ae3..6a35ad3 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -158,8 +158,8 @@ static struct gprs_nsvc *gprs_active_nsvc_by_nsei(struct gprs_ns_inst *nsi,
 	struct gprs_nsvc *nsvc;
 	llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
 		if (nsvc->nsei == nsei) {
-			if (nsvc->state & NSE_S_BLOCKED ||
-			    !(nsvc->state & NSE_S_ALIVE))
+			if (!(nsvc->state & NSE_S_BLOCKED) &&
+			    nsvc->state & NSE_S_ALIVE)
 				return nsvc;
 		}
 	}
diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok
index 7366278..424d681 100644
--- a/tests/gb/gprs_ns_test.ok
+++ b/tests/gb/gprs_ns_test.ok
@@ -1,5 +1,5 @@
 ===== NS protocol test START
---- Setup, send BSSGB RESET ---
+--- Setup, send BSSGP RESET ---
 
 Setup NS-VC: remote 0x01020304:1111, NSVCI 0x1122(4386), NSEI 0x1122(4386)
 
@@ -143,6 +143,8 @@ Current NS-VCIs:
          NS-VC replaced other count: 1
          NS-VC changed NSEI        : 2
 
+Current NS-VCIs:
+
 --- Send message to SGSN ---
 
 SENDING BSSGP RESET to NSEI 0x0100, BVCI 0x0000
@@ -151,11 +153,24 @@ NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18
 
 result (BSSGP RESET) = -22
 
---- Setup blocked connection to SGSN ---
+--- Setup dead connection to SGSN ---
 
 MESSAGE to SGSN, msg length 12
 02 00 81 01 01 82 01 01 04 82 01 00 
 
+Current NS-VCIs:
+    VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked, dead
+
+--- Send message to SGSN ---
+
+SENDING BSSGP RESET to NSEI 0x0100, BVCI 0x0000
+NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18
+22 04 82 4a 2e 07 81 08 08 88 10 20 30 40 50 60 10 00 
+
+result (BSSGP RESET) = -16
+
+--- Make connection to SGSN alive ---
+
 PROCESSING RESET_ACK from 0x05060708:32000
 03 01 82 01 01 04 82 01 00 
 
@@ -172,16 +187,17 @@ MESSAGE to SGSN, msg length 1
 
 result (ALIVE_ACK) = 1
 
+Current NS-VCIs:
+    VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000, blocked
+         NS-VC Block count         : 1
+
 --- Send message to SGSN ---
 
 SENDING BSSGP RESET to NSEI 0x0100, BVCI 0x0000
 NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18
 22 04 82 4a 2e 07 81 08 08 88 10 20 30 40 50 60 10 00 
 
-MESSAGE to SGSN, msg length 22
-00 00 00 00 22 04 82 4a 2e 07 81 08 08 88 10 20 30 40 50 60 10 00 
-
-result (BSSGP RESET) = 22
+result (BSSGP RESET) = -16
 
 --- Unblock connection to SGSN ---
 
@@ -202,10 +218,6 @@ result (ALIVE) = 1
 Current NS-VCIs:
     VCI 0x0101, NSEI 0x0100, peer 0x05060708:32000
          NS-VC Block count         : 1
-    VCI 0x3344, NSEI 0x1122, peer 0x00000000:0, blocked
-    VCI 0x1122, NSEI 0x1122, peer 0x01020304:4444, blocked
-         NS-VC replaced other count: 1
-         NS-VC changed NSEI        : 2
 
 --- Send message to SGSN ---
 
@@ -213,7 +225,10 @@ SENDING BSSGP RESET to NSEI 0x0100, BVCI 0x0000
 NS UNITDATA MESSAGE to SGSN, BVCI 0x0000, msg length 18
 22 04 82 4a 2e 07 81 08 08 88 10 20 30 40 50 60 10 00 
 
-result (BSSGP RESET) = -16
+MESSAGE to SGSN, msg length 22
+00 00 00 00 22 04 82 4a 2e 07 81 08 08 88 10 20 30 40 50 60 10 00 
+
+result (BSSGP RESET) = 22
 
 --- Send empty message with BVCI to SGSN ---
 
@@ -221,7 +236,10 @@ SENDING [empty] to NSEI 0x0100, BVCI 0x0102
 NS UNITDATA MESSAGE to SGSN, BVCI 0x0102, msg length 0
 
 
-result ([empty]) = -16
+MESSAGE to SGSN, msg length 4
+00 00 01 02 
+
+result ([empty]) = 4
 
 ===== NS protocol test END
 
-- 
1.7.9.5





More information about the OpenBSC mailing list