pespin has uploaded this change for review. (
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39675?usp=email )
Change subject: as: Introduce internal ss7_as_add_asp() to avoid unnecessary asp lookup
......................................................................
as: Introduce internal ss7_as_add_asp() to avoid unnecessary asp lookup
Change-Id: Id75fde04e39747fd3a7a1b169f7b925e5a8064d9
---
M src/osmo_ss7_as.c
M src/sccp_user.c
M src/ss7_as.h
M src/xua_asp_fsm.c
M src/xua_rkm.c
5 files changed, 26 insertions(+), 14 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran refs/changes/75/39675/1
diff --git a/src/osmo_ss7_as.c b/src/osmo_ss7_as.c
index ab48ca8..6aadb8f 100644
--- a/src/osmo_ss7_as.c
+++ b/src/osmo_ss7_as.c
@@ -110,21 +110,16 @@
* \param[in] as Application Server to which \ref asp is added
* \param[in] asp Application Server Process to be added to \ref as
* \returns 0 on success; negative in case of error */
-int osmo_ss7_as_add_asp(struct osmo_ss7_as *as, const char *asp_name)
+int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
{
- struct osmo_ss7_asp *asp;
unsigned int i;
-
- OSMO_ASSERT(ss7_initialized);
- asp = osmo_ss7_asp_find_by_name(as->inst, asp_name);
- if (!asp)
- return -ENODEV;
-
- LOGPAS(as, DLSS7, LOGL_INFO, "Adding ASP %s to AS\n", asp->cfg.name);
+ OSMO_ASSERT(asp);
if (osmo_ss7_as_has_asp(as, asp))
return 0;
+ LOGPAS(as, DLSS7, LOGL_INFO, "Adding ASP %s to AS\n", asp->cfg.name);
+
for (i = 0; i < ARRAY_SIZE(as->cfg.asps); i++) {
if (!as->cfg.asps[i]) {
as->cfg.asps[i] = asp;
@@ -137,6 +132,22 @@
return -ENOSPC;
}
+/*! \brief Add given ASP to given AS
+ * \param[in] as Application Server to which \ref asp is added
+ * \param[in] asp_name Name of Application Server Process to be added to \ref as
+ * \returns 0 on success; negative in case of error */
+int osmo_ss7_as_add_asp(struct osmo_ss7_as *as, const char *asp_name)
+{
+ struct osmo_ss7_asp *asp;
+
+ OSMO_ASSERT(ss7_initialized);
+ asp = osmo_ss7_asp_find_by_name(as->inst, asp_name);
+ if (!asp)
+ return -ENODEV;
+
+ return ss7_as_add_asp(as, asp);
+}
+
/*! \brief Delete given ASP from given AS
* \param[in] as Application Server from which \ref asp is deleted
* \param[in] asp Application Server Process to delete from \ref as
diff --git a/src/sccp_user.c b/src/sccp_user.c
index d60d66a..a32bbaa 100644
--- a/src/sccp_user.c
+++ b/src/sccp_user.c
@@ -633,7 +633,7 @@
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));
- osmo_ss7_as_add_asp(as, asp->cfg.name);
+ ss7_as_add_asp(as, asp);
break;
}
if (!asp) {
@@ -657,7 +657,7 @@
ss7_asp_peer_set_hosts(&asp->cfg.local, asp, &default_local_ip, 1);
if (default_remote_ip)
ss7_asp_peer_set_hosts(&asp->cfg.remote, asp, &default_remote_ip, 1);
- osmo_ss7_as_add_asp(as, asp->cfg.name);
+ ss7_as_add_asp(as, asp);
/* Make sure proper defaults are applied if app didn't
provide specific default values, then restart the ASP: */
ss7_asp_restart_after_reconfigure(asp);
@@ -866,7 +866,7 @@
goto out_asp;
asp->cfg.is_server = true;
asp->cfg.role = OSMO_SS7_ASP_ROLE_SG;
- osmo_ss7_as_add_asp(as, asp_name);
+ ss7_as_add_asp(as, asp);
talloc_free(asp_name);
talloc_free(as_name);
osmo_ss7_asp_restart(asp);
diff --git a/src/ss7_as.h b/src/ss7_as.h
index 4a7c50d..db7372c 100644
--- a/src/ss7_as.h
+++ b/src/ss7_as.h
@@ -68,6 +68,7 @@
};
unsigned int osmo_ss7_as_count_asp(const struct osmo_ss7_as *as);
+int ss7_as_add_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
#define LOGPAS(as, subsys, level, fmt, args ...) \
_LOGSS7((as)->inst, subsys, level, "AS(%s) " fmt, (as)->cfg.name, ##
args)
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 0e39b0d..9ad9dce 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -958,7 +958,7 @@
iafp->ipa_unit->unit_name);
goto out_err;
}
- osmo_ss7_as_add_asp(as, asp->cfg.name);
+ ss7_as_add_asp(as, asp);
/* TODO: OAP Authentication? */
/* Send ID_ACK */
if (fd >= 0) {
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index 9e77095..98f41c5 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -297,7 +297,7 @@
}
/* Success: Add just-create AS to connected ASP + report success */
- osmo_ss7_as_add_asp(as, asp->cfg.name);
+ ss7_as_add_asp(as, asp);
msgb_append_reg_res(resp, rk_id, M3UA_RKM_REG_SUCCESS, rctx);
/* append to list of newly assigned as */
newly_assigned_as[(*nas_idx)++] = as;
--
To view, visit
https://gerrit.osmocom.org/c/libosmo-sigtran/+/39675?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: newchange
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Id75fde04e39747fd3a7a1b169f7b925e5a8064d9
Gerrit-Change-Number: 39675
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pespin(a)sysmocom.de>