summaryrefslogtreecommitdiff
path: root/accel-pptpd/radius
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pptpd/radius')
-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
4 files changed, 44 insertions, 2 deletions
diff --git a/accel-pptpd/radius/acct.c b/accel-pptpd/radius/acct.c
index f2c0ebb..ddb3e08 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 244cb6e..692830e 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 f081cf4..8976a33 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 9fd0b74..71c1a63 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);