Change in libosmo-sccp[master]: osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name

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

laforge gerrit-no-reply at lists.osmocom.org
Mon Jun 29 20:34:59 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/19014 )

Change subject: osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name
......................................................................

osmo_sccp_simple_client_on_ss7_id(): do not care about ASP name

Our manuals explain that the cs7 config automatically adds missing parts.
However, previous code requires an ASP to exactly match the default name that
the autoconfiguration would choose -- that is unintuitive.

If a config included only an ASP, or both AS and ASP but omitting to add the
ASP to the AS, auto configuration would pick it up iff it exactly had the name
the application chose. For osmo-bsc, that was 'asp-clnt-msc-0', if 'msc 0' is
the first MSC in the config file. For osmo-msc, it is 'asp-clnt-OsmoMSC-A' or
'asp-clnt-OsmoMSC-A-Iu' and so forth, so it is not always clear which name the
user should pick to get the ASP used by auto config.

Refactor so that any ASP with a matching protocol that is not associated with
any AS yet is picked up by the auto configuration, i.e. associated with the AS
etc., regardless of the name chosen in the config file.

Related: OS#4635
Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35
---
M src/sccp_user.c
1 file changed, 28 insertions(+), 8 deletions(-)

Approvals:
  Jenkins Builder: Verified
  pespin: Looks good to me, but someone else must approve
  laforge: Looks good to me, approved



diff --git a/src/sccp_user.c b/src/sccp_user.c
index d8a7357..e1329ac 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -25,6 +25,7 @@
 
 #include <stdbool.h>
 #include <string.h>
+#include <limits.h>
 
 #include <osmocom/core/linuxlist.h>
 #include <osmocom/core/logging.h>
@@ -574,13 +575,33 @@
 	 * we intend to use. */
 	asp = osmo_ss7_asp_find_by_proto(as, prot);
 	if (!asp) {
-		/* Check if the user has already created an ASP elsewhere under
-		 * the default asp name. */
-		asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
-		asp = osmo_ss7_asp_find_by_name(ss7, asp_name);
+		/* Check if the user has created an ASP for this proto that is not added on any AS yet. */
+		struct osmo_ss7_asp *asp_i;
+		llist_for_each_entry(asp_i, &ss7->asp_list, list) {
+			struct osmo_ss7_as *as_i;
+			bool is_on_as = false;
+			if (asp_i->cfg.proto != prot)
+				continue;
+			llist_for_each_entry(as_i, &ss7->as_list, list) {
+				if (!osmo_ss7_as_has_asp(as_i, asp_i))
+					continue;
+				is_on_as = true;
+				break;
+			}
+			if (is_on_as) {
+				/* This ASP is already on another AS. If it was on this AS, we'd have found it above. */
+				continue;
+			}
+			/* This ASP matches the protocol and is not yet associated to any AS. Use it. */
+			asp = asp_i;
+			LOGP(DLSCCP, LOGL_NOTICE, "%s: ASP %s for %s is not associated with any AS, using it\n",
+			     name, asp->cfg.name, osmo_ss7_asp_protocol_name(prot));
+			break;
+		}
 		if (!asp) {
-			LOGP(DLSCCP, LOGL_NOTICE, "%s: Creating ASP instance\n",
-			     name);
+			asp_name = talloc_asprintf(ctx, "asp-clnt-%s", name);
+			LOGP(DLSCCP, LOGL_NOTICE, "%s: No unassociated ASP for %s, creating new ASP %s\n",
+			     name, osmo_ss7_asp_protocol_name(prot), asp_name);
 			asp =
 			    osmo_ss7_asp_find_or_create(ss7, asp_name,
 							default_remote_port,
@@ -593,8 +614,7 @@
 			osmo_ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
 			osmo_ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);
 			asp->simple_client_allocated = true;
-		} else
-			talloc_free(asp_name);
+		}
 
 		osmo_ss7_as_add_asp(as, asp->cfg.name);
 	}

-- 
To view, visit https://gerrit.osmocom.org/c/libosmo-sccp/+/19014
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmo-sccp
Gerrit-Branch: master
Gerrit-Change-Id: I2954e0167729fd0b1a7d0144a5b5775fc1c44c35
Gerrit-Change-Number: 19014
Gerrit-PatchSet: 2
Gerrit-Owner: neels <nhofmeyr at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-Reviewer: pespin <pespin at sysmocom.de>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200629/44c93991/attachment.htm>


More information about the gerrit-log mailing list