cnpool: add context_map_cnlink_lost() handling

When proper RANAP RESET handling is in place [1], a specific CN link may
be detected to be disconnected or reconnected at any point.
[1] Id3eefdea889a736fd5957b80280fa45b9547b792

When that happens, all related context maps should disconnect RUA and
SCCP links immediately. Add the context map side of this, so that
context_map_cnlink_lost() is ready to be dispatched in [1].

Related: SYS#6412
Change-Id: Ic0a6fcfb747dc093528ca2bd12a269ad390d465c
This commit is contained in:
Neels Hofmeyr 2023-05-17 02:05:31 +02:00
parent 72f0884ee0
commit 77a21cff1d
3 changed files with 19 additions and 0 deletions

View File

@ -66,6 +66,8 @@ enum map_sccp_fsm_event {
/* The human admin asks to drop the current SCCP connection, by telnet VTY 'apply sccp' in presence of SCCP
* config changes. */
MAP_SCCP_EV_USER_ABORT,
/* The CN link has RESET */
MAP_SCCP_EV_CN_LINK_LOST,
};
/* For context_map_get_state(), to combine the RUA and SCCP states, for VTY reporting only. */
@ -186,6 +188,7 @@ int _map_sccp_dispatch(struct hnbgw_context_map *map, uint32_t event, struct msg
bool map_rua_is_active(struct hnbgw_context_map *map);
bool map_sccp_is_active(struct hnbgw_context_map *map);
void context_map_cnlink_lost(struct hnbgw_context_map *map);
void context_map_free(struct hnbgw_context_map *map);
unsigned int msg_has_l2_data(const struct msgb *msg);

View File

@ -183,6 +183,11 @@ void context_map_hnb_released(struct hnbgw_context_map *map)
map_rua_dispatch(map, MAP_RUA_EV_HNB_LINK_LOST, NULL);
}
void context_map_cnlink_lost(struct hnbgw_context_map *map)
{
map_sccp_dispatch(map, MAP_SCCP_EV_RAN_LINK_LOST, NULL);
}
void context_map_free(struct hnbgw_context_map *map)
{
/* guard against FSM termination infinitely looping back here */

View File

@ -55,6 +55,7 @@ static const struct value_string map_sccp_fsm_event_names[] = {
OSMO_VALUE_STRING(MAP_SCCP_EV_RAN_LINK_LOST),
OSMO_VALUE_STRING(MAP_SCCP_EV_RX_RELEASED),
OSMO_VALUE_STRING(MAP_SCCP_EV_USER_ABORT),
OSMO_VALUE_STRING(MAP_SCCP_EV_CN_LINK_LOST),
{}
};
@ -284,6 +285,7 @@ static void map_sccp_init_action(struct osmo_fsm_inst *fi, uint32_t event, void
case MAP_SCCP_EV_RAN_LINK_LOST:
case MAP_SCCP_EV_RAN_DISC:
case MAP_SCCP_EV_USER_ABORT:
case MAP_SCCP_EV_CN_LINK_LOST:
/* No CR has been sent yet, just go to disconnected state. */
if (msg_has_l2_data(ranap_msg))
LOG_MAP(map, DLSCCP, LOGL_ERROR, "SCCP not connected, cannot dispatch RANAP message\n");
@ -321,6 +323,7 @@ static void map_sccp_wait_cc_action(struct osmo_fsm_inst *fi, uint32_t event, vo
case MAP_SCCP_EV_RAN_LINK_LOST:
case MAP_SCCP_EV_RAN_DISC:
case MAP_SCCP_EV_USER_ABORT:
case MAP_SCCP_EV_CN_LINK_LOST:
/* RUA connection was terminated. First wait for the CC before releasing the SCCP conn. */
if (msg_has_l2_data(ranap_msg))
LOGPFSML(fi, LOGL_ERROR, "Connection not yet confirmed, cannot forward RANAP to CN\n");
@ -379,6 +382,8 @@ static void map_sccp_connected_action(struct osmo_fsm_inst *fi, uint32_t event,
* Disconnect on the SCCP layer, ungracefully. */
case MAP_SCCP_EV_USER_ABORT:
/* The user is asking for disconnection, so there is no Iu Release in progress. Disconnect now. */
case MAP_SCCP_EV_CN_LINK_LOST:
/* The CN peer has sent a RANAP RESET, so the old link that this map ran on is lost */
/* There won't be any ranap_msg, but if a caller wants to dispatch a msg, forward it before
* disconnecting. */
@ -448,6 +453,7 @@ static void map_sccp_wait_rlsd_action(struct osmo_fsm_inst *fi, uint32_t event,
return;
case MAP_SCCP_EV_USER_ABORT:
case MAP_SCCP_EV_CN_LINK_LOST:
/* Stop waiting for RLSD, send RLSD now. */
tx_sccp_rlsd(fi);
map_sccp_fsm_state_chg(MAP_SCCP_ST_DISCONNECTED);
@ -525,6 +531,7 @@ static const struct osmo_fsm_state map_sccp_fsm_states[] = {
| S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_RELEASED)
| S(MAP_SCCP_EV_USER_ABORT)
| S(MAP_SCCP_EV_CN_LINK_LOST)
,
.out_state_mask = 0
| S(MAP_SCCP_ST_INIT)
@ -542,6 +549,7 @@ static const struct osmo_fsm_state map_sccp_fsm_states[] = {
| S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_RELEASED)
| S(MAP_SCCP_EV_USER_ABORT)
| S(MAP_SCCP_EV_CN_LINK_LOST)
,
.out_state_mask = 0
| S(MAP_SCCP_ST_CONNECTED)
@ -559,6 +567,7 @@ static const struct osmo_fsm_state map_sccp_fsm_states[] = {
| S(MAP_SCCP_EV_RX_RELEASED)
| S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM)
| S(MAP_SCCP_EV_USER_ABORT)
| S(MAP_SCCP_EV_CN_LINK_LOST)
,
.out_state_mask = 0
| S(MAP_SCCP_ST_WAIT_RLSD)
@ -577,6 +586,7 @@ static const struct osmo_fsm_state map_sccp_fsm_states[] = {
| S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_RX_CONNECTION_CONFIRM)
| S(MAP_SCCP_EV_USER_ABORT)
| S(MAP_SCCP_EV_CN_LINK_LOST)
,
.out_state_mask = 0
| S(MAP_SCCP_ST_DISCONNECTED)
@ -591,6 +601,7 @@ static const struct osmo_fsm_state map_sccp_fsm_states[] = {
| S(MAP_SCCP_EV_RAN_DISC)
| S(MAP_SCCP_EV_RAN_LINK_LOST)
| S(MAP_SCCP_EV_USER_ABORT)
| S(MAP_SCCP_EV_CN_LINK_LOST)
,
.onenter = map_sccp_disconnected_onenter,
.action = map_sccp_disconnected_action,