lynxis submitted this change.
tcap_as_loadshare: refactor and cleanup tcap state
Ensures also static configured ASP will reset its TCAP state,
when the IPA connection goes down.
Change-Id: I4c748eb0fab83e0198637101a890ae4094e50116
---
M src/tcap_as_loadshare.c
M src/tcap_as_loadshare.h
M src/xua_asp_fsm.c
3 files changed, 40 insertions(+), 10 deletions(-)
diff --git a/src/tcap_as_loadshare.c b/src/tcap_as_loadshare.c
index 8e24882..4f1b10c 100644
--- a/src/tcap_as_loadshare.c
+++ b/src/tcap_as_loadshare.c
@@ -1085,29 +1085,55 @@
}
-static void _tcap_range_asp_down(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
+static void tcap_cleanup_state(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
{
int i;
struct tcap_range *tcrng;
struct hlist_node *tmp;
+ /* Update round robin state */
+ ss7_as_del_asp_update_llist_round_robin(as, asp, &as->tcap.last_asp_idx_sent);
+
tcap_trans_track_entries_free_by_asp(as, asp);
hash_for_each_safe(as->tcap.tid_ranges, i, tmp, tcrng, list) {
if (tcrng->asp == asp)
tcap_range_free(tcrng);
}
+
+ if (as->tcap.contains_pc || as->tcap.contains_ssn)
+ tcap_range_as_update_pc_ssn(as);
}
+/** When the ASP goes down
+ *
+ * @param[in] as
+ * @param[in] asp
+ */
+void tcap_asp_down(struct osmo_ss7_asp *asp)
+{
+ struct ss7_as_asp_assoc *assoc;
+
+ if (!asp->tcap.enabled)
+ return;
+
+ asp->tcap.enabled = false;
+
+ llist_for_each_entry(assoc, &asp->assoc_as_list, asp_entry)
+ tcap_cleanup_state(assoc->as, asp);
+}
+
+/** An AS becomes dissassociated from an ASP, ie. an ASP stops serving an AS
+ *
+ * @param[in] as
+ * @param[in] asp
+ */
void tcap_as_del_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp)
{
if (!asp->tcap.enabled)
return;
- /* Update round robin state */
- ss7_as_del_asp_update_llist_round_robin(as, asp, &as->tcap.last_asp_idx_sent);
- _tcap_range_asp_down(as, asp);
- if (as->tcap.contains_pc || as->tcap.contains_ssn)
- tcap_range_as_update_pc_ssn(as);
+ asp->tcap.enabled = false;
+ tcap_cleanup_state(as, asp);
}
void tcap_enable(struct osmo_ss7_as *as)
diff --git a/src/tcap_as_loadshare.h b/src/tcap_as_loadshare.h
index a361061..f790493 100644
--- a/src/tcap_as_loadshare.h
+++ b/src/tcap_as_loadshare.h
@@ -35,8 +35,11 @@
/* Traffic STP -> AS -> ASP (Tx path) Loadshare towards the TCAP routing AS */
int tcap_as_select_asp_loadshare(struct osmo_ss7_asp **asp, struct osmo_ss7_as *as, const struct xua_msg *xua);
-/* When the ASP got removed */
+/* When the ASP got dissassociated */
void tcap_as_del_asp(struct osmo_ss7_as *as, struct osmo_ss7_asp *asp);
+/* When the ASP goes down */
+void tcap_asp_down(struct osmo_ss7_asp *asp);
+
void tcap_enable(struct osmo_ss7_as *as);
void tcap_disable(struct osmo_ss7_as *as);
diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index 62bc932..2436da9 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -464,13 +464,14 @@
/* First notify all AS associated to the ASP that it went down: */
dispatch_to_all_as(asp->fi, XUA_ASPAS_ASP_DOWN_IND, asp);
+#ifdef WITH_TCAP_LOADSHARING
+ tcap_asp_down(asp);
+#endif
+
/* Implicit clean up tasks: */
asp->remote_asp_id_present = false;
llist_for_each_entry_safe(assoc, assoc2, &asp->assoc_as_list, asp_entry) {
struct osmo_ss7_as *as = assoc->as;
-#ifdef WITH_TCAP_LOADSHARING
- tcap_as_del_asp(as, asp);
-#endif
if (as->rkm_dyn_allocated) {
/* RFC 4666 4.4.2: "An ASP SHOULD deregister from all Application Servers
To view, visit change 44003. To unsubscribe, or for help writing mail filters, visit settings.