Change in osmo-pcu[master]: gprs_bssgp: rework ns_create_nsvc

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

lynxis lazus gerrit-no-reply at lists.osmocom.org
Mon Feb 15 05:45:10 UTC 2021


lynxis lazus has uploaded this change for review. ( https://gerrit.osmocom.org/c/osmo-pcu/+/22913 )


Change subject: gprs_bssgp: rework ns_create_nsvc
......................................................................

gprs_bssgp: rework ns_create_nsvc

Add support for multiple SNS endpoints.
Move the NSE allocation to the top in preparation of IP-SNS binds.
The future gprs_ns2 library will require to manual add every bind to the NSE for IP-SNS.

Related: SYS#5354
Change-Id: I69cf48ab168a6dca4f649157bf6556d7cd27d4fb
---
M src/gprs_bssgp_pcu.c
1 file changed, 20 insertions(+), 16 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-pcu refs/changes/13/22913/1

diff --git a/src/gprs_bssgp_pcu.c b/src/gprs_bssgp_pcu.c
index a6b6f7e..7b28665 100644
--- a/src/gprs_bssgp_pcu.c
+++ b/src/gprs_bssgp_pcu.c
@@ -988,10 +988,20 @@
 	struct gprs_ns2_vc *nsvc;
 	struct gprs_ns2_vc_bind *bind[PCU_IF_NUM_NSVC] = { };
 	char name[5];
+	bool sns_configured = false;
 
 	if (!valid)
 		return -1;
 
+	bts->nse = gprs_ns2_nse_by_nsei(the_pcu->nsi, nsei);
+	if (!bts->nse)
+		bts->nse = gprs_ns2_create_nse(the_pcu->nsi, nsei,
+					       GPRS_NS2_LL_UDP, the_pcu->vty.ns_dialect);
+	if (!bts->nse) {
+		LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSE\n");
+		return 0;
+	}
+
 	for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
 		if (!(valid & (1 << i)))
 			continue;
@@ -1010,31 +1020,22 @@
 
 	if (!binds) {
 		LOGP(DBSSGP, LOGL_ERROR, "Failed to bind to any NS-VC\n");
+		gprs_ns2_free_nses(the_pcu->nsi);
 		return -1;
 	}
 
-	bts->nse = gprs_ns2_nse_by_nsei(the_pcu->nsi, nsei);
-	if (!bts->nse)
-		bts->nse = gprs_ns2_create_nse(the_pcu->nsi, nsei,
-					       GPRS_NS2_LL_UDP, the_pcu->vty.ns_dialect);
-
-	if (!bts->nse) {
-		LOGP(DBSSGP, LOGL_ERROR, "Failed to create NSE\n");
-		gprs_ns2_free_binds(the_pcu->nsi);
-		return 1;
-	}
-
 	for (i = 0; i < PCU_IF_NUM_NSVC; i++) {
 		if (!(binds & (1 << i)))
 			continue;
 
-		/* FIXME: for SNS we just use the first successful NS-VC instead of all for the initial connect */
 		if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS) {
 			rc = gprs_ns2_sns_add_endpoint(bts->nse, &remote[i]);
-			if (!rc)
+			if (rc && rc != -EALREADY) {
+				LOGP(DBSSGP, LOGL_ERROR, "Failed to add SNS endpoint %s!\n", osmo_sockaddr_to_str(&remote[i]));
 				return rc;
-			else
-				LOGP(DBSSGP, LOGL_ERROR, "Failed to connect to (SNS) towards SGSN %s!\n", osmo_sockaddr_to_str(&remote[i]));
+			} else {
+				sns_configured = true;
+			}
 		} else {
 			nsvc = gprs_ns2_ip_connect(bind[i], &remote[i], bts->nse, nsvci[i]);
 			if (nsvc)
@@ -1044,7 +1045,10 @@
 		}
 	}
 
-	return nsvcs ? 0 : -1;
+	if (the_pcu->vty.ns_dialect == GPRS_NS2_DIALECT_SNS)
+		return sns_configured ? 0 : 1;
+	else
+		return nsvcs ? 0 : -1;
 }
 
 struct nsvc_cb {

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

Gerrit-Project: osmo-pcu
Gerrit-Branch: master
Gerrit-Change-Id: I69cf48ab168a6dca4f649157bf6556d7cd27d4fb
Gerrit-Change-Number: 22913
Gerrit-PatchSet: 1
Gerrit-Owner: lynxis lazus <lynxis at fe80.eu>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20210215/581486b1/attachment.htm>


More information about the gerrit-log mailing list