Change in osmo-sgsn[master]: gbproxy: Ensure BVC0 is reset before handling PtP BVCs

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

daniel gerrit-no-reply at lists.osmocom.org
Mon Nov 30 13:29:42 UTC 2020


daniel has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-sgsn/+/21410 )


Change subject: gbproxy: Ensure BVC0 is reset before handling PtP BVCs
......................................................................

gbproxy: Ensure BVC0 is reset before handling PtP BVCs

Change-Id: I9c67f973f7bca00e8eb22a024ef2282c007dd84b
Related: SYS#5226
---
M src/gbproxy/gb_proxy.c
M tests/gbproxy/gbproxy_test.c
M tests/gbproxy/gbproxy_test.ok
3 files changed, 141 insertions(+), 38 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-sgsn refs/changes/10/21410/1

diff --git a/src/gbproxy/gb_proxy.c b/src/gbproxy/gb_proxy.c
index 3b55855..52ae4fe 100644
--- a/src/gbproxy/gb_proxy.c
+++ b/src/gbproxy/gb_proxy.c
@@ -1049,6 +1049,14 @@
 			LOGP(DGPRS, LOGL_INFO, "NSEI=%u Rx BVC RESET (BVCI=%u)\n",
 				nsei, bvci);
 			if (bvci == 0) {
+				struct gbproxy_nse *nse;
+				/* Ensure the NSE peer is there and clear all PtP BVCs */
+				nse = gbproxy_nse_by_nsei_or_new(cfg, nsei);
+				if (!nse)
+					LOGP(DGPRS, LOGL_ERROR, "Could not allocate NSE for NSEI=%u\n", nsei);
+
+				gbproxy_cleanup_peers(cfg, nsei, 0);
+
 				/* FIXME: only do this if SGSN is alive! */
 				LOGP(DGPRS, LOGL_INFO, "NSEI=%u Tx fake "
 					"BVC RESET ACK of BVCI=0\n", nsei);
@@ -1057,10 +1065,11 @@
 			}
 			from_peer = gbproxy_peer_by_bvci(cfg, bvci);
 			if (!from_peer) {
-				struct gbproxy_nse *nse = gbproxy_nse_by_nsei_or_new(cfg, nsei);
+				struct gbproxy_nse *nse = gbproxy_nse_by_nsei(cfg, nsei);
 				if (!nse) {
-					LOGP(DGPRS, LOGL_ERROR, "Could not allocate NSE for NSEI=%u\n", nsei);
-					return bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+					LOGP(DGPRS, LOGL_NOTICE, "Got PtP BVC reset before signalling reset for "
+						"BVCI=%u NSEI=%u\n", bvci, nsei);
+					return bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_STATE, NULL, msg);
 				}
 				/* if a PTP-BVC is reset, and we don't know that
 				 * PTP-BVCI yet, we should allocate a new peer */
@@ -1072,10 +1081,11 @@
 			/* Could have moved to a different NSE */
 			if (!check_peer_nsei(from_peer, nsei)) {
 				struct gbproxy_nse *nse_old = from_peer->nse;
-				struct gbproxy_nse *nse_new = gbproxy_nse_by_nsei_or_new(cfg, nsei);
+				struct gbproxy_nse *nse_new = gbproxy_nse_by_nsei(cfg, nsei);
 				if (!nse_new) {
-					LOGP(DGPRS, LOGL_ERROR, "Could not allocate NSE for NSEI=%u\n", nsei);
-					return bssgp_tx_status(BSSGP_CAUSE_PROTO_ERR_UNSPEC, NULL, msg);
+					LOGP(DGPRS, LOGL_NOTICE, "Got PtP BVC reset before signalling reset for "
+						"BVCI=%u NSEI=%u\n", bvci, nsei);
+					return bssgp_tx_status(BSSGP_CAUSE_PDU_INCOMP_STATE, NULL, msg);
 				}
 				LOGP(DGPRS, LOGL_NOTICE, "Peer for BVCI=%u moved from NSEI=%u to NSEI=%u\n", bvci, nse_old->nsei, nsei);
 
diff --git a/tests/gbproxy/gbproxy_test.c b/tests/gbproxy/gbproxy_test.c
index 7312d2d..80d207c 100644
--- a/tests/gbproxy/gbproxy_test.c
+++ b/tests/gbproxy/gbproxy_test.c
@@ -930,6 +930,7 @@
 	       "NSEI 0x%04x(%d)\n\n",
 	       nsei, nsei);
 	send_ns_avail(nsi, nsei);
+	send_bssgp_reset(nsi, nsei, 0);
 }
 
 static void setup_bssgp(struct gprs_ns2_inst *nsi,
diff --git a/tests/gbproxy/gbproxy_test.ok b/tests/gbproxy/gbproxy_test.ok
index 020aa7a..7d6812d 100644
--- a/tests/gbproxy/gbproxy_test.ok
+++ b/tests/gbproxy/gbproxy_test.ok
@@ -13,6 +13,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -48,6 +57,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 8192
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=8192 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x2002(8194)
 
 PROCESSING BVC_RESET from NSEI 8192
@@ -366,6 +384,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 --- Setup BVCI 1 ---
 
 Setup BSSGP: BVCI 0x1002(4098)
@@ -488,6 +515,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 8192
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=8192 BVCI=0):
+23 04 82 00 00 
+
 --- Setup BVCI 1 ---
 
 Setup BSSGP: BVCI 0x1002(4098)
@@ -660,6 +696,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 8192
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=8192 BVCI=0):
+23 04 82 00 00 
+
 --- Setup BVCI 1 ---
 
 Setup BSSGP: BVCI 0x1002(4098)
@@ -685,15 +730,11 @@
 NS2 UD REQUEST, prim 0, msg length 5, bvci 0x0000
 23 04 82 10 02 
 
-Message for BSS (NSEI=4096 BVCI=0):
+Message for BSS (NSEI=8192 BVCI=0):
 [L2]> [L3]> 23 04 82 10 02 
 
 Peers:
   NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 3
-    TLLI-Cache: 0
-  NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 1
     TLLI-Cache: 0
   NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
     NSEI mismatch                   : 1
@@ -730,10 +771,6 @@
   NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
     TLLI-Cache: 0
   NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 3
-    TLLI-Cache: 0
-  NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 1
     TLLI-Cache: 0
   NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
     NSEI mismatch                   : 1
@@ -761,7 +798,7 @@
 NS2 UD REQUEST, prim 0, msg length 0, bvci 0x1002
 
 
-Message for BSS (NSEI=4096 BVCI=4098):
+Message for BSS (NSEI=8192 BVCI=4098):
 [L2]> [L3]> 
 
 --- Send message from BSS 1 to SGSN and back, BVCI 2  (should fail) ---
@@ -782,10 +819,6 @@
   NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
     TLLI-Cache: 0
   NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 4
-    TLLI-Cache: 0
-  NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 1
     TLLI-Cache: 0
   NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
     NSEI mismatch                   : 2
@@ -806,10 +839,6 @@
   NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
     TLLI-Cache: 0
   NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 4
-    TLLI-Cache: 0
-  NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 1
     TLLI-Cache: 0
   NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
     NSEI mismatch                   : 2
@@ -822,11 +851,8 @@
 NS2 CALLBACK, prim 0, msg length 0, bvci 0x3002
 
 
-NS2 UD REQUEST, prim 0, msg length 0, bvci 0x3002
-
-
-Message for SGSN (NSEI=256 BVCI=12290):
-[L2]> [L3]> 
+Message for BSS (NSEI=8192 BVCI=0):
+41 07 81 05 04 82 30 02 15 80 
 
 PROCESSING (null) from NSEI 256
 
@@ -834,11 +860,8 @@
 NS2 CALLBACK, prim 0, msg length 0, bvci 0x3002
 
 
-NS2 UD REQUEST, prim 0, msg length 0, bvci 0x3002
-
-
-Message for BSS (NSEI=8192 BVCI=12290):
-[L2]> [L3]> 
+Message for SGSN (NSEI=256 BVCI=0):
+41 07 81 05 04 82 30 02 15 80 
 
 --- Send message from BSS 1 to SGSN and back, BVCI 4 ---
 
@@ -867,14 +890,11 @@
 [L2]> [L3]> 
 
 Gbproxy global:
+    Invalid BVC Identifier          : 1
 Peers:
   NSEI 8192, BVCI 16386, not blocked, RAI 112-332-16464-96
     TLLI-Cache: 0
   NSEI 8192, BVCI 4098, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 4
-    TLLI-Cache: 0
-  NSEI 8192, BVCI 12290, not blocked, RAI 112-332-16464-96
-    NSEI mismatch                   : 1
     TLLI-Cache: 0
   NSEI 4096, BVCI 8194, not blocked, RAI 112-332-16464-96
     NSEI mismatch                   : 2
@@ -893,6 +913,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -1271,6 +1300,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -1556,6 +1594,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -2205,6 +2252,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -2464,6 +2520,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -3180,6 +3245,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x0000(0)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -4322,6 +4396,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096
@@ -5930,6 +6013,15 @@
 
 NS2 CALLBACK, prim 2, bvci 0x0000
 
+PROCESSING BVC_RESET from NSEI 4096
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+NS2 CALLBACK, prim 0, msg length 18, bvci 0x0000
+22 04 82 00 00 07 81 08 08 88 11 22 33 40 50 60 10 00 
+
+Message for BSS (NSEI=4096 BVCI=0):
+23 04 82 00 00 
+
 Setup BSSGP: BVCI 0x1002(4098)
 
 PROCESSING BVC_RESET from NSEI 4096

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

Gerrit-Project: osmo-sgsn
Gerrit-Branch: master
Gerrit-Change-Id: I9c67f973f7bca00e8eb22a024ef2282c007dd84b
Gerrit-Change-Number: 21410
Gerrit-PatchSet: 1
Gerrit-Owner: daniel <dwillmann at sysmocom.de>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20201130/d584a3dd/attachment.htm>


More information about the gerrit-log mailing list