pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmo-sigtran/+/41515?usp=email )


Change subject: xua_asp_fsm: Move common ipa/xua ASP_DOWN onenter code to 
helper function
......................................................................

xua_asp_fsm: Move common ipa/xua ASP_DOWN onenter code to helper function

This is a preparation patch since that function (and AS loop inside it)
will be doing more stuff in the future, like tearing down TCAP
loadsharing state.

Change-Id: Ia445ebc9a3bbad903d26259453e403fd450e8075
---
M src/xua_asp_fsm.c
M src/xua_internal.h
M src/xua_rkm.c
3 files changed, 26 insertions(+), 32 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmo-sigtran 
refs/changes/15/41515/1

diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c
index d10420f..7a6979d 100644
--- a/src/xua_asp_fsm.c
+++ b/src/xua_asp_fsm.c
@@ -477,6 +477,30 @@

 }

+static void common_asp_fsm_down_onenter(struct osmo_ss7_asp *asp)
+{
+       struct osmo_ss7_as *as, *as2;
+       struct osmo_ss7_instance *inst = asp->inst;
+
+       /* First notify all AS associated to the ASP that it went down: */
+       dispatch_to_all_as(asp->fi, XUA_ASPAS_ASP_DOWN_IND, asp);
+
+       /* Implicit clean up tasks: */
+       llist_for_each_entry_safe(as, as2, &inst->as_list, list) {
+               if (!osmo_ss7_as_has_asp(as, asp))
+                       continue;
+               if (as->rkm_dyn_allocated) {
+                       /* RFC 4666 4.4.2: "An ASP SHOULD deregister from all 
Application Servers
+                        * of which it is a member before attempting to move to 
the ASP-Down state [...]
+                        * If a Deregistration results in no more ASPs in an 
Application Server,
+                        * an SG MAY delete the Routing Key data."
+                        * In case it didn't deregsitrer explicitly, make sure 
to implicitly deregister it:
+                        */
+                       ss7_as_del_asp(as, asp);
+               }
+       }
+}
+
 #define ENSURE_ASP_OR_IPSP(fi, event)                                  \
        do {                                                            \
                struct xua_asp_fsm_priv *_xafp = fi->priv;              \
@@ -513,14 +537,7 @@
        struct xua_asp_fsm_priv *xafp = fi->priv;
        struct osmo_ss7_asp *asp = xafp->asp;
        xua_t_beat_stop(fi);
-       dispatch_to_all_as(fi, XUA_ASPAS_ASP_DOWN_IND, asp);
-       /* RFC 4666 4.4.2: "An ASP SHOULD deregister from all Application 
Servers of which it is a
-        * member before attempting to move to the ASP-Down state [...]
-        * If a Deregistration results in no more ASPs in an Application 
Server, an SG MAY delete
-        * the Routing Key data."
-        * In case it didn't deregsitrer explicitly, make sure to implicitly 
deregister it:
-        */
-       xua_rkm_cleanup_dyn_as_for_asp(asp);
+       common_asp_fsm_down_onenter(asp);
 }

 static void xua_asp_fsm_down(struct osmo_fsm_inst *fi, uint32_t event, void 
*data)
@@ -1107,14 +1124,7 @@
        struct xua_asp_fsm_priv *xafp = fi->priv;
        struct osmo_ss7_asp *asp = xafp->asp;
        ipa_t_beat_stop(fi);
-       dispatch_to_all_as(fi, XUA_ASPAS_ASP_DOWN_IND, asp);
-       /* RFC 4666 4.4.2: "An ASP SHOULD deregister from all Application 
Servers of which it is a
-        * member before attempting to move to the ASP-Down state [...]
-        * If a Deregistration results in no more ASPs in an Application 
Server, an SG MAY delete
-        * the Routing Key data."
-        * In case it didn't deregsitrer explicitly, make sure to implicitly 
deregister it:
-        */
-       xua_rkm_cleanup_dyn_as_for_asp(asp);
+       common_asp_fsm_down_onenter(asp);
 }

 static void ipa_asp_fsm_down(struct osmo_fsm_inst *fi, uint32_t event, void 
*data)
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 90a68be..a6cb961 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -92,7 +92,6 @@
 int m3ua_decode_notify(struct osmo_xlm_prim_notify *npar, void *ctx,
                        const struct xua_msg *xua);
 int m3ua_rx_rkm(struct osmo_ss7_asp *asp, struct xua_msg *xua);
-void xua_rkm_cleanup_dyn_as_for_asp(struct osmo_ss7_asp *asp);

 struct osmo_xlm_prim *xua_xlm_prim_alloc(enum osmo_xlm_prim_type prim_type,
                                         enum osmo_prim_operation op);
diff --git a/src/xua_rkm.c b/src/xua_rkm.c
index 2de830f..9713e3a 100644
--- a/src/xua_rkm.c
+++ b/src/xua_rkm.c
@@ -623,18 +623,3 @@
        msgb_free(prim->oph.msg);
        return 0;
 }
-
-/* clean-up any dynamically created ASs + routes */
-void xua_rkm_cleanup_dyn_as_for_asp(struct osmo_ss7_asp *asp)
-{
-       struct osmo_ss7_instance *inst = asp->inst;
-       struct osmo_ss7_as *as, *as2;
-
-       llist_for_each_entry_safe(as, as2, &inst->as_list, list) {
-               if (!as->rkm_dyn_allocated)
-                       continue;
-               if (!osmo_ss7_as_has_asp(as, asp))
-                       continue;
-               ss7_as_del_asp(as, asp);
-       }
-}

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/41515?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: Ia445ebc9a3bbad903d26259453e403fd450e8075
Gerrit-Change-Number: 41515
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to