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


Change subject: Send DUNA during ASP ACT time
......................................................................

Send DUNA during ASP ACT time

As explained in RFC 4666 4.5.1, this helps ASPs figuring quickly
figuring out that some destinations may not be available.

Change-Id: Id9d92c3fda7423a9c79fffac6b650abba9651853
---
M src/xua_as_fsm.c
M src/xua_internal.h
M src/xua_snm.c
3 files changed, 52 insertions(+), 3 deletions(-)



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

diff --git a/src/xua_as_fsm.c b/src/xua_as_fsm.c
index 8e4282c..619142a 100644
--- a/src/xua_as_fsm.c
+++ b/src/xua_as_fsm.c
@@ -12,6 +12,7 @@
 #include <arpa/inet.h>

 #include <osmocom/core/fsm.h>
+#include <osmocom/core/linuxlist.h>
 #include <osmocom/core/utils.h>
 #include <osmocom/core/timer.h>
 #include <osmocom/core/prim.h>
@@ -64,6 +65,41 @@
        osmo_ss7_asp_send(asp, msg);
 }

+/* RFC 4666 4.5.1: "For the particular case that an ASP becomes active for an 
AS and
+ * destinations normally accessible to the AS are inaccessible, restricted, or 
congested,
+ * the SG MAY send DUNA, DRST, or SCON messages for the inaccessible, 
restricted, or
+ * congested destinations to the ASP newly active for the AS to prevent the 
ASP from
+ * sending traffic for destinations that it might not otherwise know that are 
inaccessible,
+ * restricted, or congested" */
+static void as_tx_duna_during_asp_act(struct osmo_ss7_as *as, struct 
osmo_ss7_asp *asp)
+{
+       struct osmo_ss7_instance *inst = as->inst;
+       struct osmo_ss7_route_table *rtbl = inst->rtable_system;
+       struct osmo_ss7_as *as_it;
+       uint32_t aff_pc[32];
+       unsigned int num_aff_pc = 0;
+       uint32_t rctx_be = htonl(as->cfg.routing_key.context);
+
+       /* Send up to 32 PC per DUNA: */
+       llist_for_each_entry(as_it, &inst->as_list, list) {
+               if (as == as_it)
+                       continue;
+               if (ss7_route_table_dpc_is_accessible_skip_as(rtbl, 
as_it->cfg.routing_key.pc, as))
+                       continue;
+               aff_pc[num_aff_pc++] = htonl(as_it->cfg.routing_key.pc); /* 
mask = 0 */
+               if (num_aff_pc == ARRAY_SIZE(aff_pc)) {
+                       xua_tx_snm_available(asp, &rctx_be, 1,
+                                            aff_pc, num_aff_pc,
+                                            "RFC4666 4.5.1", false);
+                       num_aff_pc = 0;
+               }
+       }
+       if (num_aff_pc > 0)
+               xua_tx_snm_available(asp, &rctx_be, 1,
+                                    aff_pc, num_aff_pc,
+                                    "RFC4666 4.5.1", false);
+}
+
 static int as_notify_all_asp(struct osmo_ss7_as *as, struct 
osmo_xlm_prim_notify *npar)
 {
        struct msgb *msg;
@@ -622,8 +658,11 @@
                        osmo_fsm_inst_state_chg(fi, XUA_AS_S_DOWN, 0, 0);
                break;
        case XUA_ASPAS_ASP_ACTIVE_IND:
+               asp = data;
                /* one ASP transitions into ASP-ACTIVE */
                osmo_fsm_inst_state_chg(fi, XUA_AS_S_ACTIVE, 0, 0);
+               if (asp->cfg.role == OSMO_SS7_ASP_ROLE_SG)
+                       as_tx_duna_during_asp_act(xafp->as, asp);
                break;
        case XUA_ASPAS_ASP_INACTIVE_IND:
                inact_ind_pars = data;
@@ -666,6 +705,9 @@
                /* RFC466 sec 4.3.4.3 ASP Active Procedures*/
                if (xafp->as->cfg.mode == OSMO_SS7_AS_TMOD_OVERRIDE)
                        notify_any_other_active_asp_as_inactive(xafp->as, asp);
+               /* SG role: No need to send DUNA for unknown destinations here
+                * (see as_tx_duna_during_asp_act()), since the AS was already
+                * active so the peer should know current status. */
                break;
        case XUA_AS_E_TRANSFER_REQ:
                /* message for transmission */
@@ -694,6 +736,9 @@
                        llist_del(&xua->entry);
                        xua_as_transmit_msg(xafp->as, xua);
                }
+               /* SG role: No need to send DUNA for unknown destinations here
+                * (see as_tx_duna_during_asp_act()), since the AS was already
+                * active so the peer should know current status. */
                break;
        case XUA_ASPAS_ASP_INACTIVE_IND:
                inact_ind_pars = data;
diff --git a/src/xua_internal.h b/src/xua_internal.h
index 576708f..b0bc98c 100644
--- a/src/xua_internal.h
+++ b/src/xua_internal.h
@@ -45,6 +45,10 @@
 void m3ua_tx_dupu(struct osmo_ss7_asp *asp, const uint32_t *rctx, unsigned int 
num_rctx,
                  uint32_t dpc, uint16_t user, uint16_t cause, const char 
*info_str);

+void xua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t *rctx, 
unsigned int num_rctx,
+                         const uint32_t *aff_pc, unsigned int num_aff_pc,
+                         const char *info_str, bool available);
+
 void xua_snm_rx_daud(struct osmo_ss7_asp *asp, struct xua_msg *xua);
 void xua_snm_rx_duna(struct osmo_ss7_asp *asp, struct osmo_ss7_as *as, struct 
xua_msg *xua);
 void xua_snm_rx_dava(struct osmo_ss7_asp *asp, struct osmo_ss7_as *as, struct 
xua_msg *xua);
diff --git a/src/xua_snm.c b/src/xua_snm.c
index 207b042..6bbeec7 100644
--- a/src/xua_snm.c
+++ b/src/xua_snm.c
@@ -67,9 +67,9 @@
        return out;
 }

-static void xua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t 
*rctx, unsigned int num_rctx,
-                                const uint32_t *aff_pc, unsigned int 
num_aff_pc,
-                                const char *info_str, bool available)
+void xua_tx_snm_available(struct osmo_ss7_asp *asp, const uint32_t *rctx, 
unsigned int num_rctx,
+                         const uint32_t *aff_pc, unsigned int num_aff_pc,
+                         const char *info_str, bool available)
 {
        switch (asp->cfg.proto) {
        case OSMO_SS7_ASP_PROT_M3UA:

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

Reply via email to