SS7: do not attempt transfer if AS is down

The attempt to route message via AS which is down will fail anyway:
let's make it explicit.

Add osmo_ss7_as_down() and use it to check AS state before transferring the message.

Change-Id: I0d5f3b6265e7fdaa79e32fbc30f829ef79e7dad1
This commit is contained in:
Max 2023-02-11 15:32:50 +03:00 committed by msuraev
parent e753f21047
commit 6e8241356b
3 changed files with 19 additions and 0 deletions

View File

@ -352,6 +352,7 @@ int osmo_ss7_as_del_asp(struct osmo_ss7_as *as, const char *asp_name);
void osmo_ss7_as_destroy(struct osmo_ss7_as *as);
bool osmo_ss7_as_has_asp(const struct osmo_ss7_as *as,
const struct osmo_ss7_asp *asp);
bool osmo_ss7_as_down(const struct osmo_ss7_as *as);
bool osmo_ss7_as_active(const struct osmo_ss7_as *as);
bool osmo_ss7_as_tmode_compatible_xua(struct osmo_ss7_as *as, uint32_t m3ua_tmt);
void osmo_ss7_asp_disconnect(struct osmo_ss7_asp *asp);

View File

@ -1143,6 +1143,18 @@ bool osmo_ss7_as_active(const struct osmo_ss7_as *as)
return as->fi->state == XUA_AS_S_ACTIVE;
}
/*! Determine if given AS is in the down state.
* \param[in] as Application Server.
* \returns true in case as is down; false otherwise. */
bool osmo_ss7_as_down(const struct osmo_ss7_as *as)
{
OSMO_ASSERT(as);
if (!as->fi)
return true;
return as->fi->state == XUA_AS_S_DOWN;
}
/***********************************************************************
* SS7 Application Server Process
***********************************************************************/

View File

@ -228,6 +228,12 @@ static int hmrt_message_for_routing(struct osmo_ss7_instance *inst,
dpc, osmo_ss7_pointcode_print(inst, dpc), rt_name);
}
if (osmo_ss7_as_down(as)) {
LOGP(DLSS7, LOGL_ERROR, "Unable to route HMRT message: the AS %s is down\n",
as->cfg.name);
return -ENETDOWN;
}
rate_ctr_inc2(as->ctrg, SS7_AS_CTR_TX_MSU_TOTAL);
switch (as->cfg.proto) {