diff options
author | Guillaume Nault <g.nault@alphalink.fr> | 2014-02-06 17:23:53 +0100 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-02-08 09:31:00 +0400 |
commit | 4654e90f1903756523808afd6a00112060c67dc2 (patch) | |
tree | e8ea009616612b1bfedd3a90fe6941c463b7f9eb /accel-pppd/ctrl/l2tp | |
parent | ea57a3932621e89d7ca206dc8354fbb9f6596f3e (diff) | |
download | accel-ppp-4654e90f1903756523808afd6a00112060c67dc2.tar.gz accel-ppp-4654e90f1903756523808afd6a00112060c67dc2.zip |
l2tp: add session statistics for control channels
Compute control channel statistics for L2TP sessions and report them
in the "show stat" command.
Signed-off-by: Guillaume Nault <g.nault@alphalink.fr>
Diffstat (limited to 'accel-pppd/ctrl/l2tp')
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index dd132a7b..3cb2acbe 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -78,6 +78,10 @@ static unsigned int stat_conn_starting; static unsigned int stat_conn_active; static unsigned int stat_conn_finishing; +static unsigned int stat_sess_starting; +static unsigned int stat_sess_active; +static unsigned int stat_sess_finishing; + static unsigned int stat_active; static unsigned int stat_starting; static unsigned int stat_finishing; @@ -642,6 +646,8 @@ static void __session_destroy(struct l2tp_sess_t *sess) mempool_free(sess); + __sync_sub_and_fetch(&stat_sess_finishing, 1); + /* Now that the session is fully destroyed, * drop the reference to the tunnel. */ @@ -671,11 +677,16 @@ static void l2tp_session_free(struct l2tp_sess_t *sess) case STATE_WAIT_OCRP: case STATE_WAIT_OCCN: log_session(log_info2, sess, "deleting session\n"); + + __sync_sub_and_fetch(&stat_sess_starting, 1); + __sync_add_and_fetch(&stat_sess_finishing, 1); break; case STATE_ESTB: log_session(log_info2, sess, "deleting session\n"); triton_event_fire(EV_CTRL_FINISHED, &sess->ppp.ses); + __sync_sub_and_fetch(&stat_sess_active, 1); + __sync_add_and_fetch(&stat_sess_finishing, 1); pthread_mutex_lock(&sess->apses_lock); if (sess->apses_ctx.tpd) @@ -1116,6 +1127,8 @@ static struct l2tp_sess_t *l2tp_tunnel_alloc_session(struct l2tp_conn_t *conn) tunnel_hold(conn); session_hold(sess); + __sync_add_and_fetch(&stat_sess_starting, 1); + return sess; } @@ -1520,6 +1533,8 @@ static int l2tp_session_connect(struct l2tp_sess_t *sess) } triton_event_fire(EV_CTRL_STARTED, &sess->ppp.ses); + __sync_sub_and_fetch(&stat_sess_starting, 1); + __sync_add_and_fetch(&stat_sess_active, 1); sess->state1 = STATE_ESTB; if (l2tp_session_start_data_channel(sess) < 0) { @@ -3935,6 +3950,11 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, cli_sendv(client, " active: %u\r\n", stat_conn_active); cli_sendv(client, " finishing: %u\r\n", stat_conn_finishing); + cli_send(client, " sessions (control channels):\r\n"); + cli_sendv(client, " starting: %u\r\n", stat_sess_starting); + cli_sendv(client, " active: %u\r\n", stat_sess_active); + cli_sendv(client, " finishing: %u\r\n", stat_sess_finishing); + cli_send(client, " sessions (data channels):\r\n"); cli_sendv(client, " starting: %u\r\n", stat_starting); cli_sendv(client, " active: %u\r\n", stat_active); |