msuraev has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-sccp/+/31295 )
Change subject: SS7: do not attempt transfer if AS is down ......................................................................
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 --- M include/osmocom/sigtran/osmo_ss7.h M src/osmo_ss7.c M src/osmo_ss7_hmrt.c 3 files changed, 33 insertions(+), 0 deletions(-)
Approvals: dexter: Looks good to me, but someone else must approve pespin: Looks good to me, but someone else must approve msuraev: Looks good to me, approved Jenkins Builder: Verified
diff --git a/include/osmocom/sigtran/osmo_ss7.h b/include/osmocom/sigtran/osmo_ss7.h index 1755859..cd1779c 100644 --- a/include/osmocom/sigtran/osmo_ss7.h +++ b/include/osmocom/sigtran/osmo_ss7.h @@ -352,6 +352,7 @@ 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); diff --git a/src/osmo_ss7.c b/src/osmo_ss7.c index a4af727..3dc0d51 100644 --- a/src/osmo_ss7.c +++ b/src/osmo_ss7.c @@ -1143,6 +1143,18 @@ 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 ***********************************************************************/ diff --git a/src/osmo_ss7_hmrt.c b/src/osmo_ss7_hmrt.c index f5fcd64..3ac43b8 100644 --- a/src/osmo_ss7_hmrt.c +++ b/src/osmo_ss7_hmrt.c @@ -228,6 +228,12 @@ 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) {