aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2020-10-09 17:18:29 +0200
committerNeels Hofmeyr <neels@hofmeyr.de>2020-10-15 05:28:44 +0200
commite95b92b63ec2032811267996e3fe17c3ff8326ff (patch)
treefb10240c8bb1e79fbed4eabdf05931812151dfdb
parent6efafb1219fbb6f4e0f7d29a4983ad74561c1a42 (diff)
BSSMAP RESET: move RESET-ACK into reset fsm
The Lb interface will need the same RESET-ACK logic. Change-Id: Idf4682319a0af5665e867dbc0515d1fe343d9daf
-rw-r--r--include/osmocom/bsc/bssmap_reset.h2
-rw-r--r--src/osmo-bsc/a_reset.c7
-rw-r--r--src/osmo-bsc/bssmap_reset.c34
-rw-r--r--src/osmo-bsc/osmo_bsc_bssap.c17
-rw-r--r--tests/handover/handover_test.c1
5 files changed, 51 insertions, 10 deletions
diff --git a/include/osmocom/bsc/bssmap_reset.h b/include/osmocom/bsc/bssmap_reset.h
index ba6425701..560c54307 100644
--- a/include/osmocom/bsc/bssmap_reset.h
+++ b/include/osmocom/bsc/bssmap_reset.h
@@ -2,6 +2,7 @@
#pragma once
enum bssmap_reset_fsm_event {
+ BSSMAP_RESET_EV_RX_RESET,
BSSMAP_RESET_EV_RX_RESET_ACK,
BSSMAP_RESET_EV_CONN_CFM_SUCCESS,
BSSMAP_RESET_EV_CONN_CFM_FAILURE,
@@ -11,6 +12,7 @@ struct bssmap_reset_cfg {
int conn_cfm_failure_threshold;
struct {
void (*tx_reset)(void *data);
+ void (*tx_reset_ack)(void *data);
void (*link_up)(void *data);
void (*link_lost)(void *data);
} ops;
diff --git a/src/osmo-bsc/a_reset.c b/src/osmo-bsc/a_reset.c
index feaf49106..23714992c 100644
--- a/src/osmo-bsc/a_reset.c
+++ b/src/osmo-bsc/a_reset.c
@@ -32,6 +32,12 @@ static void a_reset_tx_reset(void *data)
osmo_bsc_sigtran_tx_reset(msc);
}
+static void a_reset_tx_reset_ack(void *data)
+{
+ struct bsc_msc_data *msc = data;
+ osmo_bsc_sigtran_tx_reset_ack(msc);
+}
+
static void a_reset_link_up(void *data)
{
struct bsc_msc_data *msc = data;
@@ -56,6 +62,7 @@ void a_reset_alloc(struct bsc_msc_data *msc, const char *name)
.conn_cfm_failure_threshold = 3,
.ops = {
.tx_reset = a_reset_tx_reset,
+ .tx_reset_ack = a_reset_tx_reset_ack,
.link_up = a_reset_link_up,
.link_lost = a_reset_link_lost,
},
diff --git a/src/osmo-bsc/bssmap_reset.c b/src/osmo-bsc/bssmap_reset.c
index 98f6b65b0..9215e902a 100644
--- a/src/osmo-bsc/bssmap_reset.c
+++ b/src/osmo-bsc/bssmap_reset.c
@@ -32,6 +32,7 @@ enum bssmap_reset_fsm_state {
};
static const struct value_string bssmap_reset_fsm_event_names[] = {
+ OSMO_VALUE_STRING(BSSMAP_RESET_EV_RX_RESET),
OSMO_VALUE_STRING(BSSMAP_RESET_EV_RX_RESET_ACK),
OSMO_VALUE_STRING(BSSMAP_RESET_EV_CONN_CFM_FAILURE),
OSMO_VALUE_STRING(BSSMAP_RESET_EV_CONN_CFM_SUCCESS),
@@ -90,6 +91,12 @@ static void tx_reset(struct bssmap_reset *bssmap_reset)
bssmap_reset->cfg.ops.tx_reset(bssmap_reset->cfg.data);
}
+static void tx_reset_ack(struct bssmap_reset *bssmap_reset)
+{
+ if (bssmap_reset->cfg.ops.tx_reset_ack)
+ bssmap_reset->cfg.ops.tx_reset_ack(bssmap_reset->cfg.data);
+}
+
static void bssmap_reset_disc_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct bssmap_reset *bssmap_reset = (struct bssmap_reset*)fi->priv;
@@ -99,7 +106,21 @@ static void bssmap_reset_disc_onenter(struct osmo_fsm_inst *fi, uint32_t prev_st
static void bssmap_reset_disc_action(struct osmo_fsm_inst *fi, uint32_t event, void *data)
{
- bssmap_reset_fsm_state_chg(fi, BSSMAP_RESET_ST_CONN);
+ struct bssmap_reset *bssmap_reset = (struct bssmap_reset*)fi->priv;
+ switch (event) {
+
+ case BSSMAP_RESET_EV_RX_RESET:
+ tx_reset_ack(bssmap_reset);
+ bssmap_reset_fsm_state_chg(fi, BSSMAP_RESET_ST_CONN);
+ break;
+
+ case BSSMAP_RESET_EV_RX_RESET_ACK:
+ bssmap_reset_fsm_state_chg(fi, BSSMAP_RESET_ST_CONN);
+ break;
+
+ default:
+ OSMO_ASSERT(false);
+ }
}
static void bssmap_reset_conn_onenter(struct osmo_fsm_inst *fi, uint32_t prev_state)
@@ -115,8 +136,15 @@ static void bssmap_reset_conn_action(struct osmo_fsm_inst *fi, uint32_t event, v
switch (event) {
+ case BSSMAP_RESET_EV_RX_RESET:
+ /* We were connected, but the remote side has restarted. */
+ link_lost(bssmap_reset);
+ tx_reset_ack(bssmap_reset);
+ link_up(bssmap_reset);
+ break;
+
case BSSMAP_RESET_EV_RX_RESET_ACK:
- LOGPFSML(fi, LOGL_INFO, "Ignoring duplicate RESET ACK\n");
+ LOGPFSML(fi, LOGL_INFO, "Link is already up, ignoring RESET ACK\n");
break;
case BSSMAP_RESET_EV_CONN_CFM_FAILURE:
@@ -153,6 +181,7 @@ static struct osmo_fsm_state bssmap_reset_fsm_states[] = {
[BSSMAP_RESET_ST_DISC] = {
.name = "DISC",
.in_event_mask = 0
+ | S(BSSMAP_RESET_EV_RX_RESET)
| S(BSSMAP_RESET_EV_RX_RESET_ACK)
,
.out_state_mask = 0
@@ -165,6 +194,7 @@ static struct osmo_fsm_state bssmap_reset_fsm_states[] = {
[BSSMAP_RESET_ST_CONN] = {
.name = "CONN",
.in_event_mask = 0
+ | S(BSSMAP_RESET_EV_RX_RESET)
| S(BSSMAP_RESET_EV_RX_RESET_ACK)
| S(BSSMAP_RESET_EV_CONN_CFM_FAILURE)
| S(BSSMAP_RESET_EV_CONN_CFM_SUCCESS)
diff --git a/src/osmo-bsc/osmo_bsc_bssap.c b/src/osmo-bsc/osmo_bsc_bssap.c
index d37b3e044..f168b6501 100644
--- a/src/osmo-bsc/osmo_bsc_bssap.c
+++ b/src/osmo-bsc/osmo_bsc_bssap.c
@@ -45,6 +45,7 @@
#include <osmocom/core/socket.h>
#include <osmocom/core/sockaddr_str.h>
#include <osmocom/bsc/lcs_loc_req.h>
+#include <osmocom/bsc/bssmap_reset.h>
#define IP_V4_ADDR_LEN 4
@@ -96,17 +97,17 @@ static int bssmap_handle_reset(struct bsc_msc_data *msc,
osmo_sccp_addr_name(osmo_ss7_instance_find(msc->a.cs7_instance),
&msc->a.msc_addr));
- /* Instruct the bsc to close all open sigtran connections and to
- * close all active channels on the BTS side as well */
- osmo_bsc_sigtran_reset(msc);
-
update_msc_osmux_support(msc, msg, length);
- /* Inform the MSC that we have received the reset request and
- * that we acted accordingly */
- osmo_bsc_sigtran_tx_reset_ack(msc);
+ if (!msc->a.bssmap_reset) {
+ LOGP(DMSC, LOGL_ERROR, "(msc%d) missing RESET FSM\n", msc->nr);
+ /* Make sure to shut down all open connections, if any */
+ osmo_bsc_sigtran_reset(msc);
+ return -1;
+ }
- return 0;
+ /* Normal case: let the reset FSM orchestrate link down / link up callbacks. */
+ return osmo_fsm_inst_dispatch(msc->a.bssmap_reset->fi, BSSMAP_RESET_EV_RX_RESET, NULL);
}
/* Page a subscriber based on TMSI and LAC via the specified BTS.
diff --git a/tests/handover/handover_test.c b/tests/handover/handover_test.c
index 230192bf2..84a48af5d 100644
--- a/tests/handover/handover_test.c
+++ b/tests/handover/handover_test.c
@@ -1816,6 +1816,7 @@ enum handover_result bsc_tx_bssmap_ho_complete(struct gsm_subscriber_connection
struct gsm_lchan *lchan) { return HO_RESULT_OK; }
void bsc_tx_bssmap_ho_failure(struct gsm_subscriber_connection *conn) {}
void osmo_bsc_sigtran_tx_reset(void) {}
+void osmo_bsc_sigtran_tx_reset_ack(void) {}
void osmo_bsc_sigtran_reset(void) {}
void bssmap_reset_alloc(void) {}
void bssmap_reset_is_conn_ready(void) {}