pespin submitted this change.

View Change

Approvals: osmith: Looks good to me, but someone else must approve Jenkins Builder: Verified laforge: Looks good to me, but someone else must approve pespin: Looks good to me, approved
xua_asp_fsm: XUA_ASP_E_ASPTM_ASPAC: Validate RCTX AS is associated to ASP

Previously we only validated that a local AS was configured for the
provided routing context, but we didn't validate that the AS was actually
associated to the requesting ASP.

Change-Id: Idcd51b9bbe38064ed03d076a76279384a3927334
---
M src/ss7_asp.c
M src/ss7_asp.h
M src/xua_asp_fsm.c
M tests/ss7/ss7_test.c
4 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/ss7_asp.c b/src/ss7_asp.c
index f83de19..ba3b95c 100644
--- a/src/ss7_asp.c
+++ b/src/ss7_asp.c
@@ -1578,6 +1578,21 @@
return _ss7_asp_get_all_rctx(asp, rctx, rctx_size, excl_as, false);
}

+/*! \brief Find Application Server associated to ASP by given routing context
+ * \param[in] asp Application Server Process through which to send
+ * \param[in] rctx Routing Context
+ * \returns pointer to Application Server on success; NULL otherwise */
+struct osmo_ss7_as *ss7_asp_find_as_by_rctx(const struct osmo_ss7_asp *asp, uint32_t rctx)
+{
+ struct ss7_as_asp_assoc *assoc;
+
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry) {
+ if (assoc->as->cfg.routing_key.context == rctx)
+ return assoc->as;
+ }
+ return NULL;
+}
+
/* Get first AS in the ASP, or NULL if no AS associated.
* This is useful for instance in IPA code, where we assume only up to 1 AS is configured per ASP. */
struct osmo_ss7_as *ss7_asp_get_first_as(const struct osmo_ss7_asp *asp)
diff --git a/src/ss7_asp.h b/src/ss7_asp.h
index 834f910..6b8e974 100644
--- a/src/ss7_asp.h
+++ b/src/ss7_asp.h
@@ -198,6 +198,7 @@
const struct osmo_ss7_as *excl_as);
unsigned int ss7_asp_get_all_rctx_be(const struct osmo_ss7_asp *asp, uint32_t *rctx, unsigned int rctx_size,
const struct osmo_ss7_as *excl_as);
+struct osmo_ss7_as *ss7_asp_find_as_by_rctx(const struct osmo_ss7_asp *asp, uint32_t rctx);
struct osmo_ss7_as *ss7_asp_get_first_as(const struct osmo_ss7_asp *asp);

int ss7_asp_determine_traf_mode(const struct osmo_ss7_asp *asp);
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 5cb28fc..d627795 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -704,7 +704,7 @@
if ((part = xua_msg_find_tag(xua_in, M3UA_IEI_ROUTE_CTX))) {
for (i = 0; i < part->len / sizeof(uint32_t); i++) {
uint32_t rctx = osmo_load32be(&part->dat[i * sizeof(uint32_t)]);
- as = osmo_ss7_as_find_by_rctx(asp->inst, rctx);
+ as = ss7_asp_find_as_by_rctx(asp, rctx);
if (!as) {
LOGPFSML(fi, LOGL_NOTICE,
"ASPAC: Couldn't find any AS with rctx=%u. Check your config!\n",
diff --git a/tests/ss7/ss7_test.c b/tests/ss7/ss7_test.c
index 977f1f4..aec886f 100644
--- a/tests/ss7/ss7_test.c
+++ b/tests/ss7/ss7_test.c
@@ -289,7 +289,11 @@
OSMO_ASSERT(asp);

OSMO_ASSERT(osmo_ss7_as_has_asp(as, asp) == false);
+ OSMO_ASSERT(ss7_asp_find_as_by_rctx(asp, as->cfg.routing_key.context) == NULL);
+
OSMO_ASSERT(osmo_ss7_as_add_asp(as, "asp1") == 0);
+ OSMO_ASSERT(osmo_ss7_as_has_asp(as, asp) == true);
+ OSMO_ASSERT(ss7_asp_find_as_by_rctx(asp, as->cfg.routing_key.context) == as);

osmo_ss7_asp_restart(asp);


To view, visit change 42530. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Idcd51b9bbe38064ed03d076a76279384a3927334
Gerrit-Change-Number: 42530
Gerrit-PatchSet: 2
Gerrit-Owner: pespin <pespin@sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: osmith <osmith@sysmocom.de>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>