Browse Source

Initialize MGW pool on start up

Make the MGW pool configurable in the VTY and connect to each configured
MGW instance on start up. This is in preparation for the
subscr_conn_fsm, which will allocate own MGCP connections while
processing BSSMAP assignment request and related messages.

Related: SYS#5560
Change-Id: I6030a1f5a9d5fb06f148b2a2e03ae57bcb6b3766
changes/07/27707/2
Oliver Smith 3 months ago
parent
commit
e04bf1402d
  1. 1
      configure.ac
  2. 1
      contrib/jenkins.sh
  3. 1
      contrib/osmo-bsc-nat.spec.in
  4. 1
      debian/control
  5. 7
      doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg
  6. 8
      include/osmocom/bsc_nat/bsc_nat.h
  7. 1
      include/osmocom/bsc_nat/vty.h
  8. 2
      src/osmo-bsc-nat/Makefile.am
  9. 14
      src/osmo-bsc-nat/bsc_nat.c
  10. 23
      src/osmo-bsc-nat/bsc_nat_fsm.c
  11. 6
      src/osmo-bsc-nat/vty.c

1
configure.ac

@ -57,6 +57,7 @@ PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.6.0)
PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.2.0)
PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.1.0)
PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.5.0)
PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.9.0)
dnl checks for header files
AC_HEADER_STDC

1
contrib/jenkins.sh

@ -33,6 +33,7 @@ osmo-build-dep.sh libosmocore "" --disable-doxygen
osmo-build-dep.sh libosmo-abis
osmo-build-dep.sh libosmo-netif
osmo-build-dep.sh libosmo-sccp
osmo-build-dep.sh osmo-mgw
# Additional configure options and depends
CONFIG=""

1
contrib/osmo-bsc-nat.spec.in

@ -35,6 +35,7 @@ BuildRequires: systemd-rpm-macros
BuildRequires: pkgconfig(libcrypto) >= 0.9.5
BuildRequires: pkgconfig(libosmo-netif) >= 1.1.0
BuildRequires: pkgconfig(libosmo-sigtran) >= 1.5.0
BuildRequires: pkgconfig(libosmo-mgcp-client) >= 1.9.0
BuildRequires: pkgconfig(libosmoabis) >= 1.2.0
BuildRequires: pkgconfig(libosmocore) >= 1.6.0
BuildRequires: pkgconfig(libosmoctrl) >= 1.6.0

1
debian/control vendored

@ -15,6 +15,7 @@ Build-Depends: debhelper (>=9),
libosmo-sigtran-dev (>= 1.5.0),
libosmo-abis-dev (>= 1.2.0),
libosmo-netif-dev (>= 1.1.0),
libosmo-mgcp-client-dev (>= 1.9.0),
osmo-gsm-manuals-dev (>= 1.2.0)
Standards-Version: 3.9.8
Vcs-Git: git://git.osmocom.org/osmo-bsc-nat.git

7
doc/examples/osmo-bsc-nat/osmo-bsc-nat.cfg

@ -17,3 +17,10 @@ cs7 instance 1
bsc-nat
cs7-instance-cn 0
cs7-instance-ran 1
mgw 0
mgw remote-ip 127.0.0.14
mgw remote-port 2427
mgw local-ip 127.0.0.15
mgw local-port 2427
mgw endpoint-domain bscnat

8
include/osmocom/bsc_nat/bsc_nat.h

@ -20,6 +20,8 @@
#pragma once
#include <osmocom/core/fsm.h>
#include <osmocom/core/tdef.h>
#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <osmocom/sigtran/sccp_sap.h>
enum bsc_nat_net {
@ -39,6 +41,11 @@ struct bsc_nat {
struct osmo_fsm_inst *fi;
struct llist_head subscr_conns; /* list of struct subscr_conn */
struct {
struct mgcp_client_pool *pool;
struct osmo_tdef *tdefs;
} mgw;
struct {
struct bsc_nat_sccp_inst *sccp_inst;
uint32_t subscr_conn_id_next;
@ -61,3 +68,4 @@ const char *bsc_nat_print_addr(enum bsc_nat_net net, struct osmo_sccp_addr *addr
extern void *tall_bsc_nat_ctx;
extern struct bsc_nat *g_bsc_nat;
extern struct osmo_tdef_group g_bsc_nat_tdef_group[];

1
include/osmocom/bsc_nat/vty.h

@ -24,6 +24,7 @@
#include <osmocom/vty/command.h>
enum bsc_nat_vty_nodes {
MGW_NODE,
BSC_NAT_NODE = _LAST_OSMOVTY_NODE,
};

2
src/osmo-bsc-nat/Makefile.am

@ -13,6 +13,7 @@ AM_CFLAGS = \
$(LIBOSMONETIF_CFLAGS) \
$(COVERAGE_CFLAGS) \
$(LIBOSMOABIS_CFLAGS) \
$(LIBOSMOMGCPCLIENT_CFLAGS) \
$(LIBOSMOSIGTRAN_CFLAGS) \
$(NULL)
@ -45,5 +46,6 @@ osmo_bsc_nat_LDADD = \
$(LIBOSMONETIF_LIBS) \
$(COVERAGE_LDFLAGS) \
$(LIBOSMOABIS_LIBS) \
$(LIBOSMOMGCPCLIENT_LIBS) \
$(LIBOSMOSIGTRAN_LIBS) \
$(NULL)

14
src/osmo-bsc-nat/bsc_nat.c

@ -28,6 +28,16 @@
#include <osmocom/bsc_nat/msc.h>
#include <osmocom/bsc_nat/subscr_conn.h>
struct osmo_tdef g_mgw_tdefs[] = {
{ .T = -2427, .default_val = 5, .desc = "timeout for MGCP response from MGW" },
{}
};
struct osmo_tdef_group g_bsc_nat_tdef_group[] = {
{ .name = "mgw", .tdefs = g_mgw_tdefs, .desc = "MGW (Media Gateway) interface" },
{}
};
struct bsc_nat *bsc_nat_alloc(void *tall_ctx)
{
struct bsc_nat *bsc_nat;
@ -35,6 +45,10 @@ struct bsc_nat *bsc_nat_alloc(void *tall_ctx)
bsc_nat = talloc_zero(tall_ctx, struct bsc_nat);
OSMO_ASSERT(bsc_nat);
bsc_nat->mgw.pool = mgcp_client_pool_alloc(bsc_nat);
bsc_nat->mgw.tdefs = g_mgw_tdefs;
osmo_tdefs_reset(bsc_nat->mgw.tdefs);
bsc_nat->cn.sccp_inst = talloc_zero(bsc_nat, struct bsc_nat_sccp_inst);
OSMO_ASSERT(bsc_nat->cn.sccp_inst);
talloc_set_name_const(bsc_nat->cn.sccp_inst, "struct bsc_nat_sccp_inst (CN)");

23
src/osmo-bsc-nat/bsc_nat_fsm.c

@ -344,6 +344,24 @@ static void sccp_inst_free(struct bsc_nat_sccp_inst *sccp_inst)
talloc_free(sccp_inst);
}
static int mgw_init(struct mgcp_client_pool *pool)
{
unsigned int pool_members_initialized;
/* Initialize MGW pool. This initalizes and connects all MGCP clients that are currently configured in
* the pool. Adding additional MGCP clients to the pool is possible but the user has to configure and
* (re)connect them manually from the VTY. */
pool_members_initialized = mgcp_client_pool_connect(pool);
if (!pool_members_initialized) {
LOGP(DMAIN, LOGL_ERROR, "Failed to initialize any MGW pool members!\n");
return -1;
}
LOGP(DMAIN, LOGL_NOTICE, "MGW pool with %u pool member(s) initialized\n", pool_members_initialized);
return 0;
}
static void st_starting_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
{
struct bsc_nat *bsc_nat = (struct bsc_nat *)fi->priv;
@ -358,6 +376,11 @@ static void st_starting_on_enter(struct osmo_fsm_inst *fi, uint32_t prev_state)
return;
}
if (mgw_init(bsc_nat->mgw.pool) < 0) {
osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STOPPED, 0, 0);
return;
}
osmo_fsm_inst_state_chg(fi, BSC_NAT_FSM_ST_STARTED, 0, 0);
}

6
src/osmo-bsc-nat/vty.c

@ -19,8 +19,10 @@
#include "config.h"
#include <unistd.h>
#include <osmocom/mgcp_client/mgcp_client_pool.h>
#include <osmocom/vty/command.h>
#include <osmocom/vty/logging.h>
#include <osmocom/vty/tdef_vty.h>
#include <osmocom/vty/telnet_interface.h>
#include <osmocom/bsc_nat/bsc_nat.h>
#include <osmocom/bsc_nat/vty.h>
@ -77,4 +79,8 @@ void bsc_nat_vty_init(void)
install_node(&bsc_nat_node, config_write_bsc_nat);
install_element(BSC_NAT_NODE, &cfg_cs7_instance_cn_cmd);
install_element(BSC_NAT_NODE, &cfg_cs7_instance_ran_cmd);
osmo_tdef_vty_groups_init(CONFIG_NODE, g_bsc_nat_tdef_group);
mgcp_client_pool_vty_init(CONFIG_NODE, MGW_NODE, "", g_bsc_nat->mgw.pool);
}

Loading…
Cancel
Save