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


Change subject: Make sure to NOTIFY current state to peer after ASP UP ACK / 
REG RESP
......................................................................

Make sure to NOTIFY current state to peer after ASP UP ACK / REG RESP

Change-Id: I3dffa2e9c554f03c7c721b757ff33a89961665b5
---
M src/xua_as_fsm.c
1 file changed, 80 insertions(+), 14 deletions(-)



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

diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index 577c7d3..ab4ffda 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -39,6 +39,19 @@
        return msg;
 }

+static void tx_notify(struct osmo_ss7_asp *asp, const struct 
osmo_xlm_prim_notify *npar)
+{
+       const char *type_name, *info_name, *info_str;
+       type_name = get_value_string(m3ua_ntfy_type_names, npar->status_type);
+       info_name = m3ua_ntfy_info_name(npar->status_type, npar->status_info);
+       info_str = npar->info_string ? npar->info_string : "";
+
+       LOGPASP(asp, DLSS7, LOGL_INFO, "Tx NOTIFY Type %s:%s (%s)\n",
+               type_name, info_name, info_str);
+       struct msgb *msg = encode_notify(npar);
+       osmo_ss7_asp_send(asp, msg);
+}
+
 static int as_notify_all_asp(struct osmo_ss7_as *as, struct 
osmo_xlm_prim_notify *npar)
 {
        struct msgb *msg;
@@ -184,6 +197,37 @@
        bool ipa_route_created;
 };

+static void fill_notify_statchg_pars(const struct osmo_fsm_inst *fi, struct 
osmo_xlm_prim_notify *npar)
+{
+       struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
+       struct osmo_ss7_as *as = xafp->as;
+       *npar = (struct osmo_xlm_prim_notify){
+               .status_type = M3UA_NOTIFY_T_STATCHG,
+       };
+
+       switch (fi->state) {
+       case XUA_AS_S_INACTIVE:
+               npar->status_info = M3UA_NOTIFY_I_AS_INACT;
+               break;
+       case XUA_AS_S_ACTIVE:
+               npar->status_info = M3UA_NOTIFY_I_AS_ACT;
+               break;
+       case XUA_AS_S_PENDING:
+               npar->status_info = M3UA_NOTIFY_I_AS_PEND;
+               break;
+       case XUA_AS_S_DOWN:
+       default:
+               /* Nothing will be sent anyway... */
+               return;
+       }
+
+       /* Add the routing context, if it is configured */
+       if (as->cfg.routing_key.context) {
+               npar->presence |= NOTIFY_PAR_P_ROUTE_CTX;
+               npar->route_ctx = as->cfg.routing_key.context;
+       }
+}
+
 /* is the given AS one with a single ASP of IPA type? */
 static bool is_single_ipa_asp(struct osmo_ss7_as *as)
 {
@@ -351,21 +395,21 @@
 {
        struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
        struct osmo_ss7_as *as = xafp->as;
-       struct osmo_xlm_prim_notify npar = {
-               .status_type = M3UA_NOTIFY_T_STATCHG,
-       };
+       struct osmo_xlm_prim_notify npar;
+
+       fill_notify_statchg_pars(fi, &npar);

        switch (fi->state) {
        case XUA_AS_S_INACTIVE:
-               npar.status_info = M3UA_NOTIFY_I_AS_INACT;
+               /* continue below */
                break;
        case XUA_AS_S_ACTIVE:
                if (is_single_ipa_asp(as))
                        ipa_add_route(fi);
-               npar.status_info = M3UA_NOTIFY_I_AS_ACT;
+               /* continue below */
                break;
        case XUA_AS_S_PENDING:
-               npar.status_info = M3UA_NOTIFY_I_AS_PEND;
+               /* continue below */
                break;
        case XUA_AS_S_DOWN:
                if (is_single_ipa_asp(as))
@@ -384,11 +428,7 @@
                return;
        }

-       /* Add the routing context, if it is configured */
-       if (as->cfg.routing_key.context) {
-               npar.presence |= NOTIFY_PAR_P_ROUTE_CTX;
-               npar.route_ctx = as->cfg.routing_key.context;
-       }
+       fill_notify_statchg_pars(fi, &npar);

        /* TODO: ASP-Id of ASP triggering this state change */

@@ -410,6 +450,7 @@
 {
        struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
        struct osmo_ss7_asp *asp = data;
+       struct osmo_xlm_prim_notify npar;

        switch (event) {
        case XUA_ASPAS_ASP_DOWN_IND:
@@ -424,7 +465,13 @@
                osmo_fsm_inst_state_chg(fi, XUA_AS_S_ACTIVE, 0, 0);
                break;
        case XUA_ASPAS_ASP_INACTIVE_IND:
-               /* ignore */
+               /* RFC4666 4.3.4.5: "When an ASP moves from ASP-DOWN to 
ASP-INACTIVE within a
+                * particular AS, a Notify message SHOULD be sent, by the 
ASP-UP receptor,
+                * after sending the ASP-UP-ACK, in order to inform the ASP of 
the current AS
+                * state."
+                */
+               fill_notify_statchg_pars(fi, &npar);
+               tx_notify(asp, &npar);
                break;
        }
 }
@@ -434,13 +481,23 @@
        struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
        struct osmo_ss7_asp *asp;
        struct msgb *msg;
+       struct osmo_xlm_prim_notify npar;

        switch (event) {
        case XUA_ASPAS_ASP_DOWN_IND:
        case XUA_ASPAS_ASP_INACTIVE_IND:
                asp = data;
                if (check_any_other_asp_in_active(xafp->as, asp)) {
-                       /* ignore, we stay AS_ACTIVE */
+                       if (event == XUA_ASPAS_ASP_INACTIVE_IND) {
+                               /* We stay in ACTIVE.
+                               * RFC4666 4.3.4.5: "When an ASP moves from 
ASP-DOWN to ASP-INACTIVE within a
+                               * particular AS, a Notify message SHOULD be 
sent, by the ASP-UP receptor,
+                               * after sending the ASP-UP-ACK, in order to 
inform the ASP of the current AS
+                               * state."
+                               */
+                               fill_notify_statchg_pars(fi, &npar);
+                               tx_notify(asp, &npar);
+                       } /* ASP_DOWN_IND: ignore, nothing to be sent */
                } else {
                        uint32_t recovery_msec = 
xafp->as->cfg.recovery_timeout_msec;
                        osmo_fsm_inst_state_chg(fi, XUA_AS_S_PENDING, 0, 0);
@@ -467,7 +524,9 @@
 static void xua_as_fsm_pending(struct osmo_fsm_inst *fi, uint32_t event, void 
*data)
 {
        struct xua_as_fsm_priv *xafp = (struct xua_as_fsm_priv *) fi->priv;
+       struct osmo_ss7_asp *asp;
        struct msgb *msg;
+       struct osmo_xlm_prim_notify npar;

        switch (event) {
        case XUA_ASPAS_ASP_ACTIVE_IND:
@@ -479,7 +538,14 @@
                        xua_as_transmit_msg(xafp->as, msg);
                break;
        case XUA_ASPAS_ASP_INACTIVE_IND:
-               /* ignore */
+               /* RFC4666 4.3.4.5: "When an ASP moves from ASP-DOWN to 
ASP-INACTIVE within a
+                * particular AS, a Notify message SHOULD be sent, by the 
ASP-UP receptor,
+                * after sending the ASP-UP-ACK, in order to inform the ASP of 
the current AS
+                * state."
+                */
+                asp = data;
+                fill_notify_statchg_pars(fi, &npar);
+                tx_notify(asp, &npar);
                break;
        case XUA_ASPAS_ASP_DOWN_IND:
                /* ignore */

--
To view, visit https://gerrit.osmocom.org/c/libosmo-sigtran/+/39640?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: I3dffa2e9c554f03c7c721b757ff33a89961665b5
Gerrit-Change-Number: 39640
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <pes...@sysmocom.de>

Reply via email to