aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2011-08-10 06:11:39 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2011-08-15 12:01:24 +0000
commita6b5fae8687dabf6f47123a328302d92973b5a5c (patch)
treecaca4a846604e3c87a4f98e693fa8d7d7f8d2452
parent6245aa78f352f0c5e3e8041f883092a1241e5e21 (diff)
m2ua: Print information about number of SCTP connections
It appears that it is possible to have a stale SCTP connection and this added LOGL_NOTICE and the VTY interface might help to identify this situation in the future (the mean time of failure is about five month).
-rw-r--r--include/sctp_m2ua.h2
-rw-r--r--src/main.c4
-rw-r--r--src/sctp_m2ua.c18
-rw-r--r--src/vty_interface_cmds.c11
4 files changed, 34 insertions, 1 deletions
diff --git a/include/sctp_m2ua.h b/include/sctp_m2ua.h
index 2ae1472..ed9b6a4 100644
--- a/include/sctp_m2ua.h
+++ b/include/sctp_m2ua.h
@@ -80,4 +80,6 @@ struct mtp_m2ua_link *mtp_m2ua_link_create(struct sctp_m2ua_transport *transport
struct mtp_m2ua_link *mtp_m2ua_link_init(struct mtp_link *link);
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *tran);
+
#endif
diff --git a/src/main.c b/src/main.c
index fdc5730..a1c7f9e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -134,3 +134,7 @@ int main(int argc, char **argv)
return 0;
}
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *trans)
+{
+ return 0;
+}
diff --git a/src/sctp_m2ua.c b/src/sctp_m2ua.c
index 4b4b487..f899be2 100644
--- a/src/sctp_m2ua.c
+++ b/src/sctp_m2ua.c
@@ -32,6 +32,18 @@
#define SCTP_PPID_M2UA 2
+
+int sctp_m2ua_conn_count(struct sctp_m2ua_transport *trans)
+{
+ int count = 0;
+ struct sctp_m2ua_conn *conn;
+
+ llist_for_each_entry(conn, &trans->conns, entry)
+ count += 1;
+
+ return count;
+}
+
static struct mtp_m2ua_link *find_m2ua_link(struct sctp_m2ua_transport *trans, int link_index)
{
struct mtp_m2ua_link *link;
@@ -650,7 +662,7 @@ static int sctp_trans_accept(struct bsc_fd *fd, unsigned int what)
struct sctp_m2ua_conn *conn;
struct sockaddr_in addr;
socklen_t len;
- int s, ret;
+ int s, ret, count;
len = sizeof(addr);
s = accept(fd->fd, (struct sockaddr *) &addr, &len);
@@ -700,6 +712,10 @@ static int sctp_trans_accept(struct bsc_fd *fd, unsigned int what)
}
llist_add_tail(&conn->entry, &trans->conns);
+
+
+ count = sctp_m2ua_conn_count(trans);
+ LOGP(DINP, LOGL_NOTICE, "Now having %d SCTP connection(s).\n", count);
return 0;
}
diff --git a/src/vty_interface_cmds.c b/src/vty_interface_cmds.c
index 988444b..6e4f17c 100644
--- a/src/vty_interface_cmds.c
+++ b/src/vty_interface_cmds.c
@@ -22,6 +22,7 @@
#include <bsc_data.h>
#include <mtp_pcap.h>
#include <msc_connection.h>
+#include <sctp_m2ua.h>
#include <osmocore/rate_ctr.h>
@@ -251,6 +252,15 @@ DEFUN(allow_inject, allow_inject_cmd,
return CMD_SUCCESS;
}
+DEFUN(show_sctp, show_sctp_cmd,
+ "show sctp-connections",
+ SHOW_STR "Active SCTP connections\n")
+{
+ int count = sctp_m2ua_conn_count(bsc->m2ua_trans);
+ vty_out(vty, "Active SCTP connections are: %d.%s", count, VTY_NEWLINE);
+ return CMD_SUCCESS;
+}
+
void cell_vty_init_cmds(void)
{
/* special commands */
@@ -267,4 +277,5 @@ void cell_vty_init_cmds(void)
install_element_ve(&show_slc_cmd);
install_element_ve(&show_msc_cmd);
+ install_element_ve(&show_sctp_cmd);
}