aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2010-03-29 08:04:09 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2010-03-29 08:09:29 +0200
commit649496eb57fb109348e75e22fe8fee8ef828e906 (patch)
tree9395b53911729b022664b220a05070e0a1e8d3d2 /openbsc
parent135a45c833d48e7ddcae973ac1d772ad277a56c1 (diff)
nat: Handle MSC disconnect by closing all NAT connections
When we disconnect from the MSC handle it by pushing the problem to our connected clients. We will simply close all connections, reject all new BSC connections and attempt to reconnect to the MSC.
Diffstat (limited to 'openbsc')
-rw-r--r--openbsc/src/nat/bsc_nat.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/openbsc/src/nat/bsc_nat.c b/openbsc/src/nat/bsc_nat.c
index 3bf4b998f..c4f759fd0 100644
--- a/openbsc/src/nat/bsc_nat.c
+++ b/openbsc/src/nat/bsc_nat.c
@@ -59,6 +59,7 @@ static struct bsc_fd bsc_listen;
static struct bsc_nat *nat;
static void bsc_write(struct bsc_connection *bsc, const u_int8_t *data, unsigned int length);
+static void remove_bsc_connection(struct bsc_connection *connection);
static struct bsc_nat *bsc_nat_alloc(void)
{
@@ -422,8 +423,13 @@ exit:
static void msc_connection_was_lost(struct bsc_msc_connection *con)
{
- LOGP(DMSC, LOGL_FATAL, "Lost the connection.\n");
- exit(0);
+ struct bsc_connection *bsc, *tmp;
+
+ LOGP(DMSC, LOGL_ERROR, "Closing all connections downstream.\n");
+ llist_for_each_entry_safe(bsc, tmp, &nat->bsc_connections, list_entry)
+ remove_bsc_connection(bsc);
+
+ bsc_msc_schedule_connect(con);
}
static int ipaccess_msc_read_cb(struct bsc_fd *bfd)
@@ -669,6 +675,14 @@ static int ipaccess_listen_bsc_cb(struct bsc_fd *bfd, unsigned int what)
return ret;
}
+ /*
+ * if we are not connected to a msc... just close the socket
+ */
+ if (!msc_con->is_connected) {
+ LOGP(DNAT, LOGL_NOTICE, "Disconnecting BSC due lack of MSC connection.\n");
+ return 0;
+ }
+
/* todo... do something with the connection */
/* todo... use GNUtls to see if we want to trust this as a BTS */