sccplite: Use mgwpool config to set up socket forwarding IPA-MGCP from MSC to MGW

In SCCPlite, the BSC receives the CN-side MGCP from the MSC through an
IPA conn, and it then forwards those messages to its co-located MGW
through a rawUDP socket created at startup.

This forwarding UDP socket still relied exclusively on the "mgw.conf"
struct which was filled only by the old VTY interface which was been
deprecated lately.

This patch moves the mgw-pool setup before the msc setup so that if the
VTY config file still uses the old VTY, the single MGW is added to the
MGW pool through mgcp_client_pool_register_single(). It then simply
picks the first available MGW from the pool when creating the raw UDP
MGCP-forwarding socket.

This means SCCPLite is still left with supporting only 1 MGW. If more
than one MGW is defined in the pool, then when the call is being set up
a different MGW could be picked from the pool while the CN-side MGCP
would still be sent to the MGW pool selected at osm-bsc startup.

This limitation coul be removed later on  by adding a new VTY command
under the "msc" to pin calls for an MSC to an MGW with a given "mgw_nr"
from the pool, and that same MGW be looked for in the pool every time a
new call is being established.
Another possibility would be to avoid creating the "connected" UDP
socket at osmo-bsc startup, and rather use it in non-connected mode and
transmit (sendto) using the mgcp_client remote address during call
In any case, this is left as future excercise since so far there hasn't
been any need for multiple MGWs in SCCPLite setups.

Related: SYS#5987
Change-Id: If105dee52b8d36161c759f979eaef4579b47d365
This commit is contained in:
Pau Espin 2022-10-26 11:18:23 +02:00
parent 50c5f50f83
commit da4af65a51
2 changed files with 16 additions and 10 deletions

View File

@ -989,6 +989,9 @@ int main(int argc, char **argv)
if (bsc_mgw_setup() != 0)
llist_for_each_entry(msc, &bsc_gsmnet->mscs, entry) {
if (osmo_bsc_msc_init(msc) != 0) {
LOGP(DMSC, LOGL_ERROR, "Failed to start up. Exiting.\n");
@ -996,9 +999,6 @@ int main(int argc, char **argv)
if (bsc_mgw_setup() != 0)
if (osmo_bsc_sigtran_init(&bsc_gsmnet->mscs) != 0) {
LOGP(DNM, LOGL_ERROR, "Failed to initialize sigtran backhaul.\n");

View File

@ -40,6 +40,7 @@
#include <osmocom/abis/ipa.h>
#include <osmocom/mgcp_client/mgcp_client.h>
#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <sys/socket.h>
#include <netinet/tcp.h>
@ -163,27 +164,32 @@ static const struct osmo_stat_item_group_desc msc_statg_desc = {
int osmo_bsc_msc_init(struct bsc_msc_data *msc)
struct gsm_network *net = msc->network;
uint16_t mgw_port;
struct mgcp_client *mgcp_cli;
int rc;
/* Everything below refers to SCCP-Lite MSC connections only. */
if (msc_is_aoip(msc))
return 0;
if (net->mgw.conf->remote_port >= 0)
mgw_port = net->mgw.conf->remote_port;
/* Note: MGW is preselected here at startup, which means currently
* osmo-bsc configured for SCCPLite doesn't support MGW pools with more
* than 1 MGW.
mgcp_cli = mgcp_client_pool_get(net->mgw.mgw_pool);
rc = osmo_sock_init2_ofd(&msc->mgcp_ipa.ofd, AF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP,
msc->mgcp_ipa.local_addr, msc->mgcp_ipa.local_port,
net->mgw.conf->remote_addr, mgw_port,
if (rc < 0) {
LOGP(DMSC, LOGL_ERROR, "msc %u: Could not create/connect/bind MGCP proxy socket: %d\n",
msc->nr, rc);
return rc;
LOGP(DMSC, LOGL_INFO, "msc %u: Socket forwarding IPA-encapsulated MGCP messages towards MGW: %s\n",
msc->nr, osmo_sock_get_name2(msc->mgcp_ipa.ofd.fd));
return 0;