diff --git a/accel-pptpd/ctrl/pppoe/cli.c b/accel-pptpd/ctrl/pppoe/cli.c index 7a62952d534274bff7eb037545cfc2932df04f9c..9929f6695912c2eb107de29e7e5021025339a753 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 3e6b0bf21355b50789cc985ae9175662f2fce1bc..95ae3944d62fe608c58a2d3c81cb10f51002d241 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 b0e665d762bb7dd716c4c198fb505178aedbdc85..2264dd166a33cf765db259ddcf2a33e3f47ea940 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 f2c0ebb4325d2edbdfefeaacb8a6ee8feb70c4aa..ddb3e0867b4bf9adfbecaa48cffea3dcbe7a21ad 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 244cb6e02ad03e88b4d3f3e06e0ece7c804b6cd0..692830ed37a0228a223bec04d4b9c4ec325494af 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 f081cf4f81d60b5c02cd68a313c363c1aef94caf..8976a330ef483d7f3d10885a4f6c50208176fcb1 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 9fd0b74cd8e019c6f7c065023527686cc511c18b..71c1a6373d98ae3b7120683627a123bbf04fd1fb 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);