[PATCH 7/7] gb: Create new NSVC object instead of patching the NSVCI

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
Wed Oct 23 23:33:25 UTC 2013


When a RESET is received on the same link with a different NSVCI from
a BSS on a dynamically created NS connection do not patch the nsvc
object but create a new one instead. Thus the NSVCI is never modified
at a nsvc object after the NS-VC has been established.

Sponsored-by: On-Waves ehf
---
 src/gb/gprs_ns.c         |   16 ++++++++++++----
 tests/gb/gprs_ns_test.c  |    5 +++--
 tests/gb/gprs_ns_test.ok |   35 +++++++++++++++++++++++++----------
 3 files changed, 40 insertions(+), 16 deletions(-)

diff --git a/src/gb/gprs_ns.c b/src/gb/gprs_ns.c
index 043a66c..1754501 100644
--- a/src/gb/gprs_ns.c
+++ b/src/gb/gprs_ns.c
@@ -729,9 +729,6 @@ static int gprs_nsvc_replace_if_found(uint16_t nsvci,
 
 	talloc_free(old_peer);
 
-	/* Do statistics */
-	rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
-
 	return 1;
 }
 
@@ -784,7 +781,16 @@ static int gprs_ns_rx_reset(struct gprs_nsvc **nsvc, struct msgb *msg)
 		}
 
 		/* NS-VCI has changed */
-		gprs_nsvc_replace_if_found(nsvci, nsvc, &orig_nsvc);
+		if (!gprs_nsvc_replace_if_found(nsvci, nsvc, &orig_nsvc)) {
+			LOGP(DNS, LOGL_INFO, "Creating NS-VC %d replacing %d "
+			     "at %s\n",
+			     nsvci, (*nsvc)->nsvci,
+			     gprs_ns_ll_str(*nsvc));
+			orig_nsvc = *nsvc;
+			*nsvc = gprs_nsvc_create((*nsvc)->nsi, nsvci);
+			(*nsvc)->nsvci_is_valid = 1;
+			(*nsvc)->nsei  = nsei;
+		}
 	}
 
 	if ((*nsvc)->nsvci_is_valid && (*nsvc)->nsei != nsei) {
@@ -810,6 +816,7 @@ static int gprs_ns_rx_reset(struct gprs_nsvc **nsvc, struct msgb *msg)
 	(*nsvc)->state = NSE_S_BLOCKED | NSE_S_ALIVE;
 
 	if (orig_nsvc) {
+		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */
@@ -916,6 +923,7 @@ static int gprs_ns_rx_reset_ack(struct gprs_nsvc **nsvc, struct msgb *msg)
 		}
 
 		/* Notify others */
+		rate_ctr_inc(&(*nsvc)->ctrg->ctr[NS_CTR_REPLACED]);
 		ns_osmo_signal_dispatch_replaced(*nsvc, orig_nsvc);
 
 		/* Update the ll info fields */
diff --git a/tests/gb/gprs_ns_test.c b/tests/gb/gprs_ns_test.c
index 546c20a..c88792c 100644
--- a/tests/gb/gprs_ns_test.c
+++ b/tests/gb/gprs_ns_test.c
@@ -435,11 +435,12 @@ static void gprs_dump_nsi(struct gprs_ns_inst *nsi)
 	printf("Current NS-VCIs:\n");
 	llist_for_each_entry(nsvc, &nsi->gprs_nsvcs, list) {
 		struct sockaddr_in *peer = &(nsvc->ip.bts_addr);
-		printf("    VCI 0x%04x, NSEI 0x%04x, peer 0x%08x:%d%s%s\n",
+		printf("    VCI 0x%04x, NSEI 0x%04x, peer 0x%08x:%d%s%s%s\n",
 		       nsvc->nsvci, nsvc->nsei,
 		       ntohl(peer->sin_addr.s_addr), ntohs(peer->sin_port),
 		       nsvc->state & NSE_S_BLOCKED ? ", blocked" : "",
-		       nsvc->state & NSE_S_ALIVE   ? "" : ", dead"
+		       nsvc->state & NSE_S_ALIVE   ? "" : ", dead",
+		       nsvc->nsvci_is_valid   ? "" : ", invalid VCI"
 		      );
 		dump_rate_ctr_group(stdout, "        ", nsvc->ctrg);
 	}
diff --git a/tests/gb/gprs_ns_test.ok b/tests/gb/gprs_ns_test.ok
index 5f90d03..8a61450 100644
--- a/tests/gb/gprs_ns_test.ok
+++ b/tests/gb/gprs_ns_test.ok
@@ -445,6 +445,7 @@ Current NS-VCIs:
 PROCESSING RESET from 0x01020304:2222
 02 00 81 01 01 82 f0 01 04 82 10 00 
 
+==> got signal NS_REPLACED: 0xf001/0.0.0.0:0 -> 0x1001/1.2.3.4:2222
 ==> got signal NS_RESET, NS-VC 0xf001/1.2.3.4:2222
 MESSAGE to BSS, msg length 9
 03 01 82 f0 01 04 82 10 00 
@@ -455,17 +456,20 @@ MESSAGE to BSS, msg length 1
 result (RESET) = 9
 
 Current NS-VCIs:
-    VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
     VCI 0xf001, NSEI 0x1000, peer 0x01020304:2222, blocked
+         NS-VC replaced other count: 1
+    VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
+    VCI 0x1001, NSEI 0xf000, peer 0x00000000:0, blocked
          NS-VC Block count         : 3
          NS-VC replaced other count: 1
-         NS-VC changed NSEI count  : 2
+         NS-VC changed NSEI count  : 1
 
 --- RESET with old NSEI, NSVCI, BSS -> SGSN ---
 
 PROCESSING RESET from 0x01020304:2222
 02 00 81 01 01 82 10 01 04 82 10 00 
 
+==> got signal NS_REPLACED: 0x1001/0.0.0.0:0 -> 0xf001/1.2.3.4:2222
 ==> got signal NS_RESET, NS-VC 0x1001/1.2.3.4:2222
 MESSAGE to BSS, msg length 9
 03 01 82 10 01 04 82 10 00 
@@ -476,10 +480,12 @@ MESSAGE to BSS, msg length 1
 result (RESET) = 9
 
 Current NS-VCIs:
+    VCI 0xf001, NSEI 0x1000, peer 0x00000000:0, blocked
+         NS-VC replaced other count: 1
     VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
     VCI 0x1001, NSEI 0x1000, peer 0x01020304:2222, blocked
          NS-VC Block count         : 3
-         NS-VC replaced other count: 1
+         NS-VC replaced other count: 2
          NS-VC changed NSEI count  : 2
 
 --- Unexpected RESET_ACK VC 1, BSS -> SGSN ---
@@ -490,10 +496,12 @@ PROCESSING RESET_ACK from 0x01020304:2222
 result (RESET_ACK) = 0
 
 Current NS-VCIs:
+    VCI 0xf001, NSEI 0x1000, peer 0x00000000:0, blocked
+         NS-VC replaced other count: 1
     VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
     VCI 0x1001, NSEI 0x1000, peer 0x01020304:2222, blocked
          NS-VC Block count         : 3
-         NS-VC replaced other count: 1
+         NS-VC replaced other count: 2
          NS-VC changed NSEI count  : 2
 
 ---  RESET_ACK with invalid NSEI, BSS -> SGSN ---
@@ -510,10 +518,12 @@ MESSAGE to BSS, msg length 1
 result (RESET_ACK) = 1
 
 Current NS-VCIs:
+    VCI 0xf001, NSEI 0x1000, peer 0x00000000:0, blocked
+         NS-VC replaced other count: 1
     VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
     VCI 0x1001, NSEI 0xf000, peer 0x01020304:2222, blocked
          NS-VC Block count         : 4
-         NS-VC replaced other count: 1
+         NS-VC replaced other count: 2
          NS-VC changed NSEI count  : 3
 
 ---  RESET_ACK with invalid NSVCI, BSS -> SGSN ---
@@ -524,16 +534,21 @@ MESSAGE to BSS, msg length 12
 PROCESSING RESET_ACK from 0x01020304:2222
 03 01 82 f0 01 04 82 10 00 
 
-==> got signal NS_MISMATCH: 0x1001/1.2.3.4:2222 pdu=3, ie=1
-result (RESET_ACK) = -22
+==> got signal NS_REPLACED: 0xf001/0.0.0.0:0 -> 0x1001/1.2.3.4:2222
+MESSAGE to BSS, msg length 1
+0a 
+
+result (RESET_ACK) = 1
 
 Current NS-VCIs:
+    VCI 0xf001, NSEI 0x1000, peer 0x01020304:2222, blocked
+         NS-VC Block count         : 1
+         NS-VC replaced other count: 2
     VCI 0x2001, NSEI 0x2000, peer 0x01020304:1111
-    VCI 0x1001, NSEI 0xf000, peer 0x01020304:2222, blocked
+    VCI 0x1001, NSEI 0xf000, peer 0x00000000:0, blocked
          NS-VC Block count         : 4
-         NS-VC replaced other count: 1
+         NS-VC replaced other count: 2
          NS-VC changed NSEI count  : 3
-         NS-VCI was invalid count  : 1
 
 Current NS-VCIs:
 
-- 
1.7.9.5





More information about the OpenBSC mailing list