aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Willmann <dwillmann@sysmocom.de>2017-03-02 17:13:03 +0100
committerDaniel Willmann <dwillmann@sysmocom.de>2018-01-30 18:58:27 +0100
commit0562d5acc0a843a7599ea3085cf36bc43d5050a6 (patch)
tree12d06d1f3b18127d0268f70f62b9338fe1d72434
parentc103ee2491cfad89ffbab00f49bcdcc78154ba5b (diff)
osmo-bsc_nat: Change the way bsc_nat_msc_is_connected() works
The function now takes a struct msc_config and returns true if that MSC is connected. The vty command show msc connection now shows a line per connected MSC. In bsc_nat.c where osmo-bsc_nat previously hung up on a BSC connection if the (one) MSC was not connected it now checks for the default MSC connection. Change-Id: I95fbe1b8ad6621aba9b4bd6b581abfde0cb31fd0 Ticket: SYS#3208 Sponsored-by: On-Waves ehf.
-rw-r--r--openbsc/include/openbsc/bsc_nat.h2
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat.c4
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_utils.c9
-rw-r--r--openbsc/src/osmo-bsc_nat/bsc_nat_vty.c17
4 files changed, 19 insertions, 13 deletions
diff --git a/openbsc/include/openbsc/bsc_nat.h b/openbsc/include/openbsc/bsc_nat.h
index 0803cef50..88d23f42a 100644
--- a/openbsc/include/openbsc/bsc_nat.h
+++ b/openbsc/include/openbsc/bsc_nat.h
@@ -423,7 +423,7 @@ int bsc_do_write(struct osmo_wqueue *queue, struct msgb *msg, int id);
int bsc_write_msg(struct osmo_wqueue *queue, struct msgb *msg);
int bsc_write_cb(struct osmo_fd *bfd, struct msgb *msg);
-int bsc_nat_msc_is_connected(struct bsc_nat *nat);
+int bsc_nat_msc_is_connected(struct msc_config *msc_conf);
int bsc_conn_type_to_ctr(struct nat_sccp_connection *conn);
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat.c b/openbsc/src/osmo-bsc_nat/bsc_nat.c
index 6a0ec85f9..17935fe2b 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat.c
@@ -1376,6 +1376,7 @@ static int ipaccess_bsc_read_cb(struct osmo_fd *bfd)
static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what)
{
struct bsc_connection *bsc;
+ struct msc_config *msc_conf;
int fd, rc, on;
struct sockaddr_in sa;
socklen_t sa_len = sizeof(sa);
@@ -1395,7 +1396,8 @@ static int ipaccess_listen_bsc_cb(struct osmo_fd *bfd, unsigned int what)
/*
* if we are not connected to a msc... just close the socket
*/
- if (!bsc_nat_msc_is_connected(nat)) {
+ msc_conf = msc_config_num(nat, nat->default_msc);
+ if (!msc_conf || !bsc_nat_msc_is_connected(msc_conf)) {
LOGP(DNAT, LOGL_NOTICE, "Disconnecting BSC due lack of MSC connection.\n");
close(fd);
return 0;
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
index 830205b99..efa123796 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_utils.c
@@ -524,13 +524,10 @@ const char *bsc_con_type_to_string(int type)
return con_types[type];
}
-int bsc_nat_msc_is_connected(struct bsc_nat *nat)
+int bsc_nat_msc_is_connected(struct msc_config *msc_conf)
{
- struct msc_config *msc_conf;
- llist_for_each_entry(msc_conf, &nat->msc_configs, entry) {
- if (msc_conf->msc_con->is_connected)
- return 1;
- }
+ if (msc_conf->msc_con->is_connected)
+ return 1;
return 0;
}
diff --git a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
index dcf83f397..ca00ed673 100644
--- a/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
+++ b/openbsc/src/osmo-bsc_nat/bsc_nat_vty.c
@@ -322,14 +322,17 @@ DEFUN(show_bsc_cfg, show_bsc_cfg_cmd, "show bsc config",
static void dump_stat_total(struct vty *vty, struct bsc_nat *nat)
{
+ struct msc_config *conf;
vty_out(vty, "NAT statistics%s", VTY_NEWLINE);
vty_out(vty, " SCCP Connections %lu total, %lu calls%s",
osmo_counter_get(nat->stats.sccp.conn),
osmo_counter_get(nat->stats.sccp.calls), VTY_NEWLINE);
vty_out(vty, " MSC Connections %lu%s",
osmo_counter_get(nat->stats.msc.reconn), VTY_NEWLINE);
- vty_out(vty, " MSC Connected: %d%s",
- bsc_nat_msc_is_connected(nat), VTY_NEWLINE);
+ llist_for_each_entry(conf, &_nat->msc_configs, entry) {
+ vty_out(vty, "MSC %i Connected: %d%s", conf->nr,
+ bsc_nat_msc_is_connected(conf), VTY_NEWLINE);
+ }
vty_out(vty, " BSC Connections %lu total, %lu auth failed.%s",
osmo_counter_get(nat->stats.bsc.reconn),
osmo_counter_get(nat->stats.bsc.auth_fail), VTY_NEWLINE);
@@ -404,13 +407,17 @@ DEFUN(show_msc,
SHOW_STR "MSC related information\n"
"Status of the A-link connection\n")
{
- if (!_nat->msc_con) {
+ struct msc_config *conf;
+
+ if (llist_empty(&_nat->msc_configs)) {
vty_out(vty, "The MSC is not yet configured.%s", VTY_NEWLINE);
return CMD_WARNING;
}
- vty_out(vty, "MSC is connected: %d%s",
- bsc_nat_msc_is_connected(_nat), VTY_NEWLINE);
+ llist_for_each_entry(conf, &_nat->msc_configs, entry) {
+ vty_out(vty, "MSC %i is connected: %d%s", conf->nr,
+ bsc_nat_msc_is_connected(conf), VTY_NEWLINE);
+ }
return CMD_SUCCESS;
}