From 1968ca922bc0eed19543242fd2a3053a3a68ef5d Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Fri, 11 Mar 2022 13:13:08 +0100 Subject: [PATCH] sccp_sap_up_ran: ignore RAN until MSC is connected Related: SYS#5560 Change-Id: Idf9501412484fa92e8836952609fba7c5443d6c9 --- include/osmocom/bsc_nat/msc.h | 2 ++ src/osmo-bsc-nat/bsc_nat_fsm.c | 8 ++++++++ src/osmo-bsc-nat/msc_fsm.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/include/osmocom/bsc_nat/msc.h b/include/osmocom/bsc_nat/msc.h index 47b4d13..db42526 100644 --- a/include/osmocom/bsc_nat/msc.h +++ b/include/osmocom/bsc_nat/msc.h @@ -36,4 +36,6 @@ struct msc *msc_get(void); void msc_tx_reset(struct msc *msc); void msc_rx_reset_ack(struct msc *msc); +bool msc_is_connected(struct msc *msc); + void msc_free(struct msc *msc); diff --git a/src/osmo-bsc-nat/bsc_nat_fsm.c b/src/osmo-bsc-nat/bsc_nat_fsm.c index 1d92ba3..ad10ea2 100644 --- a/src/osmo-bsc-nat/bsc_nat_fsm.c +++ b/src/osmo-bsc-nat/bsc_nat_fsm.c @@ -29,6 +29,7 @@ #include #include #include +#include #define DEFAULT_PC_RAN "0.23.1" /* same as default for OsmoMSC */ #define DEFAULT_PC_CN "0.23.3" /* same as default for OsmoBSC */ @@ -208,10 +209,17 @@ static int sccp_sap_up_ran(struct osmo_prim_hdr *oph, void *scu) struct osmo_scu_prim *prim = (struct osmo_scu_prim *) oph; struct osmo_sccp_addr *addr; /* BSC's address */ struct osmo_sccp_addr peer_addr_out; + struct msc *msc; int rc = -1; LOGP(DMAIN, LOGL_DEBUG, "Rx %s from RAN\n", osmo_scu_prim_name(oph)); + msc = msc_get(); + if (!msc_is_connected(msc)) { + LOGP(DMAIN, LOGL_DEBUG, "Ignoring message from RAN, MSC is not connected yet\n"); + goto error; + } + switch (OSMO_PRIM_HDR(oph)) { case OSMO_PRIM(OSMO_SCU_PRIM_N_CONNECT, PRIM_OP_INDICATION): /* indication of new inbound connection request */ diff --git a/src/osmo-bsc-nat/msc_fsm.c b/src/osmo-bsc-nat/msc_fsm.c index d8b89c6..e660c57 100644 --- a/src/osmo-bsc-nat/msc_fsm.c +++ b/src/osmo-bsc-nat/msc_fsm.c @@ -152,3 +152,8 @@ void msc_rx_reset_ack(struct msc *msc) { osmo_fsm_inst_dispatch(msc->fi, MSC_FSM_EV_RX_RESET_ACK, NULL); } + +bool msc_is_connected(struct msc *msc) +{ + return msc->fi->state == MSC_FSM_ST_CONNECTED; +}