summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2017-06-08 15:36:14 +0200
committerNeels Hofmeyr <nhofmeyr@sysmocom.de>2017-06-18 17:50:09 +0200
commit9b5dee4e33fc432898ecfe490e28e0748dea83c9 (patch)
tree098cd84bbf8f852771da551a32acdd35cb142095
parent21521acd3f9147db01fde7729181c26769efdc77 (diff)
mgcp: make sure all endpoints are closed on startup
If the MSC is crashing and restarting, it may leave some endpoints open. The endpoints can not be re-used until they are deleted (DLCX). This patch sends a DLCX to all possible endpoints (usually this is in a countable range) in order to clear possible open endpoints from a previous run
-rw-r--r--openbsc/include/openbsc/msc_ifaces.h1
-rw-r--r--openbsc/src/libmgcp/mgcpgw_client.c3
-rw-r--r--openbsc/src/libmsc/msc_ifaces.c18
-rw-r--r--openbsc/src/osmo-msc/msc_main.c4
4 files changed, 25 insertions, 1 deletions
diff --git a/openbsc/include/openbsc/msc_ifaces.h b/openbsc/include/openbsc/msc_ifaces.h
index e278f93..d9f681f 100644
--- a/openbsc/include/openbsc/msc_ifaces.h
+++ b/openbsc/include/openbsc/msc_ifaces.h
@@ -56,3 +56,4 @@ int msc_tx_common_id(struct gsm_subscriber_connection *conn);
int msc_call_assignment(struct gsm_trans *trans);
int msc_call_bridge(struct gsm_trans *trans1, struct gsm_trans *trans2);
void msc_call_release(struct gsm_trans *trans);
+void msc_call_release_all(struct mgcpgw_client *mgcp);
diff --git a/openbsc/src/libmgcp/mgcpgw_client.c b/openbsc/src/libmgcp/mgcpgw_client.c
index 0c5b5ca..4ccff84 100644
--- a/openbsc/src/libmgcp/mgcpgw_client.c
+++ b/openbsc/src/libmgcp/mgcpgw_client.c
@@ -402,7 +402,8 @@ int mgcpgw_client_connect(struct mgcpgw_client *mgcp)
mgcp->remote_addr = htonl(addr.sin_addr.s_addr);
- osmo_wqueue_init(wq, 10);
+ osmo_wqueue_init(wq, (mgcp->actual.last_endpoint - mgcp->actual.first_endpoint) + 10);
+
wq->bfd.when = BSC_FD_READ;
wq->bfd.data = mgcp;
wq->read_cb = mgcp_do_read;
diff --git a/openbsc/src/libmsc/msc_ifaces.c b/openbsc/src/libmsc/msc_ifaces.c
index 9533dde..43959c1 100644
--- a/openbsc/src/libmsc/msc_ifaces.c
+++ b/openbsc/src/libmsc/msc_ifaces.c
@@ -345,3 +345,21 @@ void msc_call_release(struct gsm_trans *trans)
/* Release endpoint id */
mgcpgw_client_release_endpoint(conn->iu.mgcp_rtp_endpoint, mgcp);
}
+
+void msc_call_release_all(struct mgcpgw_client *mgcp)
+{
+ struct msgb *msg;
+ unsigned int i;
+
+ uint16_t first_endpoint = mgcp->actual.first_endpoint;
+ uint16_t last_endpoint = mgcp->actual.last_endpoint;
+
+ for (i = first_endpoint; i < last_endpoint; i++) {
+ msg = mgcp_msg_dlcx(mgcp, i);
+ if (mgcpgw_client_tx(mgcp, msg, NULL, NULL))
+ LOGP(DMGCP, LOGL_ERROR,
+ "Failed to send DLCX message for endpoint %u\n", i);
+
+ mgcpgw_client_release_endpoint(i, mgcp);
+ }
+}
diff --git a/openbsc/src/osmo-msc/msc_main.c b/openbsc/src/osmo-msc/msc_main.c
index 83d8fa4..4319b84 100644
--- a/openbsc/src/osmo-msc/msc_main.c
+++ b/openbsc/src/osmo-msc/msc_main.c
@@ -496,6 +496,10 @@ TODO: we probably want some of the _net_ ctrl commands from bsc_base_ctrl_cmds_i
return 7;
}
+ /* Make sure all mgcp endpoints are cleared */
+ msc_call_release_all(msc_network->mgcpgw.client);
+
+
/* Set up A-Interface */
/* TODO: implement A-Interface and remove above legacy stuff. */