summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2011-01-04 00:11:04 +0300
committerDmitry Kozlov <xeb@mail.ru>2011-01-04 00:11:04 +0300
commitcdd91cd6a6a7bd00dcf9a0ba78ea76e01ce33655 (patch)
tree9edc12be71dc10f7112aef9fa654faa2b6897b51
parent709dd1595b4877471cb18397be28352730120067 (diff)
downloadaccel-ppp-cdd91cd6a6a7bd00dcf9a0ba78ea76e01ce33655.tar.gz
accel-ppp-cdd91cd6a6a7bd00dcf9a0ba78ea76e01ce33655.zip
pppoe: additional statistics
radius: additional statistics
-rw-r--r--accel-pptpd/ctrl/pppoe/cli.c4
-rw-r--r--accel-pptpd/ctrl/pppoe/pppoe.c15
-rw-r--r--accel-pptpd/ctrl/pppoe/pppoe.h5
-rw-r--r--accel-pptpd/radius/acct.c13
-rw-r--r--accel-pptpd/radius/auth.c5
-rw-r--r--accel-pptpd/radius/radius.c21
-rw-r--r--accel-pptpd/radius/radius_p.h7
7 files changed, 67 insertions, 3 deletions
diff --git a/accel-pptpd/ctrl/pppoe/cli.c b/accel-pptpd/ctrl/pppoe/cli.c
index 7a62952d..9929f669 100644
--- a/accel-pptpd/ctrl/pppoe/cli.c
+++ b/accel-pptpd/ctrl/pppoe/cli.c
@@ -68,6 +68,10 @@ static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt,
cli_send(client, "pppoe:\r\n");
cli_sendv(client, " active: %u\r\n", stat_active);
cli_sendv(client, " delayed PADO: %u\r\n", stat_delayed_pado);
+ cli_sendv(client, " recv PADI: %lu\r\n", stat_PADI_recv);
+ cli_sendv(client, " sent PADO: %lu\r\n", stat_PADO_sent);
+ cli_sendv(client, " recv PADR(dup): %lu(%lu)\r\n", stat_PADR_recv, stat_PADR_dup_recv);
+ cli_sendv(client, " sent PADS: %lu\r\n", stat_PADS_sent);
return CLI_CMD_OK;
}
diff --git a/accel-pptpd/ctrl/pppoe/pppoe.c b/accel-pptpd/ctrl/pppoe/pppoe.c
index 3e6b0bf2..95ae3944 100644
--- a/accel-pptpd/ctrl/pppoe/pppoe.c
+++ b/accel-pptpd/ctrl/pppoe/pppoe.c
@@ -75,6 +75,11 @@ static mempool_t pado_pool;
unsigned int stat_active;
unsigned int stat_delayed_pado;
+unsigned long stat_PADI_recv;
+unsigned long stat_PADO_sent;
+unsigned long stat_PADR_recv;
+unsigned long stat_PADR_dup_recv;
+unsigned long stat_PADS_sent;
pthread_rwlock_t serv_lock = PTHREAD_RWLOCK_INITIALIZER;
LIST_HEAD(serv_list);
@@ -581,6 +586,7 @@ static void pppoe_send_PADO(struct pppoe_serv_t *serv, const uint8_t *addr, cons
print_packet(pack);
}
+ __sync_add_and_fetch(&stat_PADO_sent, 1);
pppoe_send(serv->hnd.fd, pack);
}
@@ -628,6 +634,7 @@ static void pppoe_send_PADS(struct pppoe_conn_t *conn)
print_packet(pack);
}
+ __sync_add_and_fetch(&stat_PADS_sent, 1);
pppoe_send(conn->disc_sock, pack);
}
@@ -693,6 +700,8 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
int n, service_match = 0;
struct delayed_pado_t *pado;
+ __sync_add_and_fetch(&stat_PADI_recv, 1);
+
if (ppp_shutdown || pado_delay == -1)
return;
@@ -791,6 +800,8 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
struct pppoe_conn_t *conn;
int vendor_id;
+ __sync_add_and_fetch(&stat_PADR_recv, 1);
+
if (ppp_shutdown)
return;
@@ -876,8 +887,10 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
pthread_mutex_lock(&serv->lock);
conn = find_channel(serv, (uint8_t *)ac_cookie_tag->tag_data);
- if (conn && !conn->ppp.username)
+ if (conn && !conn->ppp.username) {
+ __sync_add_and_fetch(&stat_PADR_dup_recv, 1);
pppoe_send_PADS(conn);
+ }
pthread_mutex_unlock(&serv->lock);
if (conn)
diff --git a/accel-pptpd/ctrl/pppoe/pppoe.h b/accel-pptpd/ctrl/pppoe/pppoe.h
index b0e665d7..2264dd16 100644
--- a/accel-pptpd/ctrl/pppoe/pppoe.h
+++ b/accel-pptpd/ctrl/pppoe/pppoe.h
@@ -91,6 +91,11 @@ extern char *conf_pado_delay;
extern unsigned int stat_active;
extern unsigned int stat_delayed_pado;
+extern unsigned long stat_PADI_recv;
+extern unsigned long stat_PADO_sent;
+extern unsigned long stat_PADR_recv;
+extern unsigned long stat_PADR_dup_recv;
+extern unsigned long stat_PADS_sent;
extern pthread_rwlock_t serv_lock;
extern struct list_head serv_list;
diff --git a/accel-pptpd/radius/acct.c b/accel-pptpd/radius/acct.c
index f2c0ebb4..ddb3e086 100644
--- a/accel-pptpd/radius/acct.c
+++ b/accel-pptpd/radius/acct.c
@@ -114,6 +114,8 @@ static void rad_acct_timeout(struct triton_timer_t *t)
struct rad_req_t *req = container_of(t, typeof(*req), timeout);
time_t ts, dt;
+ __sync_add_and_fetch(&stat_interim_lost, 1);
+
time(&ts);
dt = ts - req->rpd->acct_timestamp;
@@ -138,6 +140,7 @@ static void rad_acct_timeout(struct triton_timer_t *t)
rad_packet_change_int(req->pack, NULL, "Acct-Delay-Time", dt);
req_set_RA(req, conf_acct_secret);
rad_req_send(req, conf_interim_verbose);
+ __sync_add_and_fetch(&stat_interim_sent, 1);
}
static void rad_acct_interim_update(struct triton_timer_t *t)
@@ -158,6 +161,7 @@ static void rad_acct_interim_update(struct triton_timer_t *t)
rad_packet_change_int(rpd->acct_req->pack, NULL, "Acct-Delay-Time", 0);
req_set_RA(rpd->acct_req, conf_acct_secret);
rad_req_send(rpd->acct_req, conf_interim_verbose);
+ __sync_add_and_fetch(&stat_interim_sent, 1);
if (conf_acct_timeout) {
rpd->acct_req->timeout.period = conf_timeout * 1000;
triton_timer_add(rpd->ppp->ctrl->ctx, &rpd->acct_req->timeout, 0);
@@ -199,15 +203,18 @@ int rad_acct_start(struct radius_pd_t *rpd)
goto out_err;
if (rad_req_send(rpd->acct_req, conf_verbose))
goto out_err;
+ __sync_add_and_fetch(&stat_acct_sent, 1);
rad_req_wait(rpd->acct_req, conf_timeout);
if (!rpd->acct_req->reply) {
rpd->acct_req->pack->id++;
+ __sync_add_and_fetch(&stat_acct_lost, 1);
continue;
}
if (rpd->acct_req->reply->id != rpd->acct_req->pack->id || rpd->acct_req->reply->code != CODE_ACCOUNTING_RESPONSE) {
rad_packet_free(rpd->acct_req->reply);
rpd->acct_req->reply = NULL;
rpd->acct_req->pack->id++;
+ __sync_add_and_fetch(&stat_acct_lost, 1);
} else
break;
}
@@ -298,12 +305,16 @@ void rad_acct_stop(struct radius_pd_t *rpd)
break;
if (rad_req_send(rpd->acct_req, conf_verbose))
break;
+ __sync_add_and_fetch(&stat_acct_sent, 1);
rad_req_wait(rpd->acct_req, conf_timeout);
- if (!rpd->acct_req->reply)
+ if (!rpd->acct_req->reply) {
+ __sync_add_and_fetch(&stat_acct_lost, 1);
continue;
+ }
if (rpd->acct_req->reply->id != rpd->acct_req->pack->id || rpd->acct_req->reply->code != CODE_ACCOUNTING_RESPONSE) {
rad_packet_free(rpd->acct_req->reply);
rpd->acct_req->reply = NULL;
+ __sync_add_and_fetch(&stat_acct_lost, 1);
} else
break;
}
diff --git a/accel-pptpd/radius/auth.c b/accel-pptpd/radius/auth.c
index 244cb6e0..692830ed 100644
--- a/accel-pptpd/radius/auth.c
+++ b/accel-pptpd/radius/auth.c
@@ -147,6 +147,7 @@ static int rad_auth_send(struct rad_req_t *req)
int i;
for(i = 0; i < conf_max_try; i++) {
+ __sync_add_and_fetch(&stat_auth_sent, 1);
if (rad_req_send(req, conf_verbose))
goto out;
@@ -154,11 +155,13 @@ static int rad_auth_send(struct rad_req_t *req)
if (req->reply) {
if (req->reply->id != req->pack->id) {
+ __sync_add_and_fetch(&stat_auth_lost, 1);
rad_packet_free(req->reply);
req->reply = NULL;
} else
break;
- }
+ } else
+ __sync_add_and_fetch(&stat_auth_lost, 1);
}
if (!req->reply)
diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c
index f081cf4f..8976a330 100644
--- a/accel-pptpd/radius/radius.c
+++ b/accel-pptpd/radius/radius.c
@@ -12,6 +12,7 @@
#include "pwdb.h"
#include "ipdb.h"
#include "ppp_auth.h"
+#include "cli.h"
#include "radius_p.h"
#include "attr_defs.h"
@@ -48,6 +49,13 @@ int conf_sid_in_auth;
int conf_require_nas_ident;
int conf_acct_interim_interval;
+unsigned long stat_auth_sent;
+unsigned long stat_auth_lost;
+unsigned long stat_acct_sent;
+unsigned long stat_acct_lost;
+unsigned long stat_interim_sent;
+unsigned long stat_interim_lost;
+
static LIST_HEAD(sessions);
static pthread_rwlock_t sessions_lock = PTHREAD_RWLOCK_INITIALIZER;
@@ -339,6 +347,18 @@ int rad_check_nas_pack(struct rad_packet_t *pack)
return 0;
}
+static int show_stat_exec(const char *cmd, char * const *fields, int fields_cnt, void *client)
+{
+ cli_send(client, "radius:\r\n");
+ cli_sendv(client, " auth sent: %lu\r\n", stat_auth_sent);
+ cli_sendv(client, " auth lost: %lu\r\n", stat_auth_lost);
+ cli_sendv(client, " acct sent: %lu\r\n", stat_acct_sent);
+ cli_sendv(client, " acct lost: %lu\r\n", stat_acct_lost);
+ cli_sendv(client, " interim sent: %lu\r\n", stat_interim_sent);
+ cli_sendv(client, " interim lost: %lu\r\n", stat_interim_lost);
+ return CLI_CMD_OK;
+}
+
void __export rad_register_plugin(struct ppp_t *ppp, struct rad_plugin_t *plugin)
{
struct radius_pd_t *rpd = find_pd(ppp);
@@ -505,4 +525,5 @@ static void __init radius_init(void)
triton_event_register_handler(EV_PPP_FINISHED, (triton_event_func)ppp_finished);
triton_event_register_handler(EV_CONFIG_RELOAD, (triton_event_func)load_config);
+ cli_register_simple_cmd2(show_stat_exec, NULL, 2, "show", "stat");
}
diff --git a/accel-pptpd/radius/radius_p.h b/accel-pptpd/radius/radius_p.h
index 9fd0b74c..71c1a637 100644
--- a/accel-pptpd/radius/radius_p.h
+++ b/accel-pptpd/radius/radius_p.h
@@ -78,6 +78,13 @@ extern in_addr_t conf_dm_coa_server;
extern int conf_dm_coa_port;
extern int conf_acct_interim_interval;
+extern unsigned long stat_auth_sent;
+extern unsigned long stat_auth_lost;
+extern unsigned long stat_acct_sent;
+extern unsigned long stat_acct_lost;
+extern unsigned long stat_interim_sent;
+extern unsigned long stat_interim_lost;
+
int rad_check_nas_pack(struct rad_packet_t *pack);
struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr, const char *csid);
struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack);