[PATCH 2/2] gbproxy: Handle S_NS_REPLACED signal

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
Fri Oct 11 20:23:13 UTC 2013


The signal is dispatched when a NS-VC object is replaced by another
one (with the same NS-VCI) for some reason. This patch changes the
gbproxy's signal handler to update the peer object accordingly in
this case.

This happens when the source port of a NS-VC changes to a new one
that has already been used by another NS-VC.

The patch is needed for (and relies on) the changes introduced by
libosmocore's commit 'gb: Fix gprs_ns_rx_reset to not create NS-VC
duplicates'.

Ticket: OW#874
Sponsored-by: On-Waves ehf
---
 openbsc/src/gprs/gb_proxy.c           |   35 +++++++++++++++++++++++++++++++++
 openbsc/tests/gbproxy/gbproxy_test.ok |    1 -
 2 files changed, 35 insertions(+), 1 deletion(-)

diff --git a/openbsc/src/gprs/gb_proxy.c b/openbsc/src/gprs/gb_proxy.c
index 3a9fe81..f6b27ae 100644
--- a/openbsc/src/gprs/gb_proxy.c
+++ b/openbsc/src/gprs/gb_proxy.c
@@ -603,6 +603,41 @@ int gbprox_signal(unsigned int subsys, unsigned int signal,
 	if (subsys != SS_L_NS)
 		return 0;
 
+	if (signal == S_NS_REPLACED) {
+		/* The old nsvc object is no longer used and will be replaced
+		 * by a new one. */
+		struct gbprox_peer *replaced_peer;
+
+		peer = peer_by_nsvc(nssd->old_nsvc);
+		if (!peer) {
+			LOGP(DGPRS, LOGL_NOTICE, "signal REPLACED for unknown peer "
+			     "NSEI=%u/NSVCI=%u\n",
+			     nssd->old_nsvc->nsei, nssd->old_nsvc->nsvci);
+			return 0;
+		}
+		if (peer->nsvc->nsei != nsvc->nsei) {
+			LOGP(DGPRS, LOGL_ERROR,
+			     "old and new NSEI of a peer don't match (%u -> %u), "
+			     "NSVCI=%u\n",
+			     peer->nsvc->nsei, nsvc->nsei, nsvc->nsvci);
+		}
+		replaced_peer = peer_by_nsvc(nsvc);
+		if (replaced_peer) {
+			/* This peer has used the nsvc object before. Since
+			 * that is going to be used for another peer, this peer
+			 * is going to be removed. */
+			LOGP(DGPRS, LOGL_NOTICE, "going to remove peer with BVCI=%u\n",
+			     replaced_peer->bvci);
+			peer_free(replaced_peer);
+		}
+
+		LOGP(DGPRS, LOGL_NOTICE, "going to replace the NS-VC object "
+		     "for peer NSEI=%u/NSVCI=%u\n", nsvc->nsei, nsvc->nsvci);
+
+		peer->nsvc = nsvc;
+		return 0;
+	}
+
 	if (signal == S_NS_RESET && nsvc->nsei == gbcfg.nsip_sgsn_nsei) {
 		/* We have received a NS-RESET from the NSEI and NSVC
 		 * of the SGSN.  This might happen with SGSN that start
diff --git a/openbsc/tests/gbproxy/gbproxy_test.ok b/openbsc/tests/gbproxy/gbproxy_test.ok
index da4158d..17478ad 100644
--- a/openbsc/tests/gbproxy/gbproxy_test.ok
+++ b/openbsc/tests/gbproxy/gbproxy_test.ok
@@ -352,6 +352,5 @@ Current NS-VCIs:
 
 Peers:
   NSEI 8192, BVCI 8194, not blocked, RAC 10-32-16464-96
-  NSEI 8192, BVCI 4098, not blocked, RAC 10-32-16464-96
 ===== NS protocol test END
 
-- 
1.7.9.5





More information about the OpenBSC mailing list