laforge submitted this change.

View Change

Approvals: pespin: Looks good to me, approved Jenkins Builder: Verified
TCAP: Refactoring unroutable messages into own function

In preparation of adding another method to handle those.

Change-Id: Ib4d114273423730418458767d17b11de9bd815d4
---
M src/tcap_as_loadshare.c
1 file changed, 65 insertions(+), 12 deletions(-)

diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c
index 058e0c3..a24d56e 100644
--- a/src/tcap_as_loadshare.c
+++ b/src/tcap_as_loadshare.c
@@ -454,6 +454,42 @@
return rc;
}

+/*! When a TCAP MSU from an ongoing session (TCAP != Begin) could not be routed either by the TCAP session tracking or
+ * by the TID range, such messages will be passed to this function.
+ *
+ * \param[out] rasp the new ASP where the TCAP MSU should be send out (can be NULL)
+ * \param[in] as the AS to which this MSU was routed to
+ * \param[in] mtp
+ * \param[in] sccp_msg
+ * \return 0 on success
+ */
+static int asp_loadshare_tcap_handle_unroutable(struct osmo_ss7_asp **rasp,
+ struct osmo_ss7_as *as,
+ const struct osmo_mtp_transfer_param *mtp,
+ const struct msgb *sccp_msg)
+{
+ struct osmo_ss7_asp *asp = NULL;
+ int rc = -ENOKEY;
+
+ OSMO_ASSERT(rasp);
+
+ switch (as->cfg.loadshare.tcap.unroutable_tcap_msg) {
+ case SS7_AS_TCAP_UNROUTABLE_LOAD_SHARE_AS:
+ asp = select_asp_tcap_enabled_rr(as);
+ if (asp)
+ rc = 0;
+ break;
+ case SS7_AS_TCAP_UNROUTABLE_REJECT_UDTS:
+ default:
+ /* default case, asp stays NULL, will reject when returning -ENOKEY */
+ rc = -ENOKEY;
+ break;
+ }
+
+ *rasp = asp;
+ return rc;
+}
+
/*! Traffic STP -> AS -> ASP (Tx path) Loadshare towards the TCAP routing AS
*
* \param[out] rasp the selected ASP if any, can be NULL
@@ -582,16 +618,24 @@
LOGPAS(as, DLTCAP, LOGL_INFO, "Couldn't find cached ASP for TCAP Continue, dtid %u/otid %u, using tcap route", parsed.dtid, parsed.otid);
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_MISS);
asp = tcap_as_asp_find_by_tcap_id(as, &calling_addr, &called_addr, parsed.dtid);
- if (!asp && as->cfg.loadshare.tcap.unroutable_tcap_msg == SS7_AS_TCAP_UNROUTABLE_LOAD_SHARE_AS) {
- asp = select_asp_tcap_enabled_rr(as);
- if (asp)
- rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_FALLBACK);
+ if (!asp) {
+ /* Couldn't find a matching TCAP endpoint for an ongoing session */
+ rc = asp_loadshare_tcap_handle_unroutable(&asp, as, mtp, sccp_msg);
+ if (rc)
+ goto out_free_sua;
+
+ if (!asp) {
+ rc = -ENOKEY;
+ goto out_free_sua;
+ }
+
+ rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_FALLBACK);
}

- if (asp)
- tcap_trans_track_entry_create(as, asp, &called_addr, &parsed.dtid, &calling_addr, &parsed.otid);
+ tcap_trans_track_entry_create(as, asp, &called_addr, &parsed.dtid, &calling_addr, &parsed.otid);
}
- rc = asp ? 0 : -ENOKEY;
+
+ rc = 0;
break;
case TCAP_TCMessage_PR_abort:
case TCAP_TCMessage_PR_end:
@@ -606,14 +650,23 @@
LOGPAS(as, DLTCAP, LOGL_INFO, "Couldn't find cached ASP for TCAP End, dtid %u, using tcap route\n", parsed.dtid);
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_MISS);
asp = tcap_as_asp_find_by_tcap_id(as, &calling_addr, &called_addr, parsed.dtid);
- if (!asp && as->cfg.loadshare.tcap.unroutable_tcap_msg == SS7_AS_TCAP_UNROUTABLE_LOAD_SHARE_AS) {
- asp = select_asp_tcap_enabled_rr(as);
- if (asp)
- rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_FALLBACK);
+ if (!asp) {
+ /* Couldn't find a matching TCAP endpoint for an ongoing session */
+ rc = asp_loadshare_tcap_handle_unroutable(&asp, as, mtp, sccp_msg);
+ if (rc)
+ goto out_free_sua;
+
+ if (!asp) {
+ rc = -ENOKEY;
+ goto out_free_sua;
+ }
+
+ rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TCAP_ASP_FALLBACK);
}
/* Don't create an entry for an End */
}
- rc = asp ? 0 : -ENOKEY;
+
+ rc = 0;
break;
case TCAP_TCMessage_PR_unidirectional:
case TCAP_TCMessage_PR_NOTHING:

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

Gerrit-MessageType: merged
Gerrit-Project: libosmo-sigtran
Gerrit-Branch: master
Gerrit-Change-Id: Ib4d114273423730418458767d17b11de9bd815d4
Gerrit-Change-Number: 43007
Gerrit-PatchSet: 5
Gerrit-Owner: lynxis lazus <lynxis@fe80.eu>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: daniel <dwillmann@sysmocom.de>
Gerrit-Reviewer: laforge <laforge@osmocom.org>
Gerrit-Reviewer: pespin <pespin@sysmocom.de>