summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-10-04 18:52:17 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-10-04 18:52:17 +0400
commit43a444fc65d917bf680831c0b942d682d933dc84 (patch)
treecc7c85b61e86f72795e4c3881199e3a96ddd0ca6 /accel-pppd
parentcc301ec08bf329968cea8fab8a5d7c4b05a1870b (diff)
downloadaccel-ppp-43a444fc65d917bf680831c0b942d682d933dc84.tar.gz
accel-ppp-43a444fc65d917bf680831c0b942d682d933dc84.zip
radius: various bug fixes
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/radius/acct.c19
-rw-r--r--accel-pppd/radius/auth.c3
-rw-r--r--accel-pppd/radius/radius.c15
-rw-r--r--accel-pppd/radius/radius_p.h2
-rw-r--r--accel-pppd/radius/req.c6
-rw-r--r--accel-pppd/radius/serv.c12
-rw-r--r--accel-pppd/triton/triton.c2
7 files changed, 44 insertions, 15 deletions
diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c
index c4b37cd5..7fbf1373 100644
--- a/accel-pppd/radius/acct.c
+++ b/accel-pppd/radius/acct.c
@@ -312,9 +312,10 @@ static void rad_acct_stop_sent(struct rad_req_t *req, int res)
if (req->rpd)
rad_acct_stop_defer(req->rpd);
else {
- if (ap_shutdown)
+ if (ap_shutdown) {
rad_req_free(req);
- else
+ req->rpd->acct_req = NULL;
+ } else
req->try = 0;
}
@@ -353,6 +354,9 @@ static void rad_acct_stop_timeout(struct triton_timer_t *t)
{
struct rad_req_t *req = container_of(t, typeof(*req), timeout);
+ if (!req->rpd)
+ log_switch(triton_context_self(), NULL);
+
if (req->active) {
rad_server_req_exit(req);
rad_server_timeout(req->serv);
@@ -381,6 +385,7 @@ static void rad_acct_stop_timeout(struct triton_timer_t *t)
static void start_deferred(struct rad_req_t *req)
{
+ log_switch(triton_context_self(), NULL);
if (req->hnd.fd != -1) {
triton_md_register_handler(NULL, &req->hnd);
triton_md_enable_handler(&req->hnd, MD_MODE_READ);
@@ -394,7 +399,8 @@ static void start_deferred(struct rad_req_t *req)
void rad_acct_stop_defer(struct radius_pd_t *rpd)
{
struct rad_req_t *req = rpd->acct_req;
- rad_server_req_cancel(req);
+
+ rad_server_req_cancel(req, 1);
if (req->hnd.tpd)
triton_md_unregister_handler(&req->hnd, 0);
rpd->acct_req = NULL;
@@ -411,10 +417,11 @@ int rad_acct_stop(struct radius_pd_t *rpd)
struct rad_req_t *req = rpd->acct_req;
struct timespec ts;
- if (req) {
+ if (rpd->acct_interim_timer.tpd)
triton_timer_del(&rpd->acct_interim_timer);
-
- rad_server_req_cancel(req);
+
+ if (req) {
+ rad_server_req_cancel(req, 1);
clock_gettime(CLOCK_MONOTONIC, &ts);
req->ts = ts.tv_sec;
diff --git a/accel-pppd/radius/auth.c b/accel-pppd/radius/auth.c
index b73f2597..d166192a 100644
--- a/accel-pppd/radius/auth.c
+++ b/accel-pppd/radius/auth.c
@@ -181,6 +181,9 @@ static void rad_auth_recv(struct rad_req_t *req)
.reply = pack,
};
triton_event_fire(EV_RADIUS_ACCESS_ACCEPT, &ev);
+ } else {
+ rad_auth_finalize(req->rpd, PWDB_DENIED);
+ return;
}
if (req->rpd->auth_ctx->recv && req->rpd->auth_ctx->recv(req)) {
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c
index fa2b6a64..6cf5ead0 100644
--- a/accel-pppd/radius/radius.c
+++ b/accel-pppd/radius/radius.c
@@ -355,10 +355,15 @@ static void ses_finishing(struct ap_session *ses)
{
struct radius_pd_t *rpd = find_pd(ses);
- if (!rpd->acct_started)
- return;
+ if (rpd->auth_ctx) {
+ rad_server_req_cancel(rpd->auth_ctx->req, 1);
+ rad_req_free(rpd->auth_ctx->req);
+ mempool_free(rpd->auth_ctx);
+ rpd->auth_ctx = NULL;
+ }
- rad_acct_stop(rpd);
+ if (rpd->acct_started || rpd->acct_req)
+ rad_acct_stop(rpd);
}
static void ses_finished(struct ap_session *ses)
@@ -373,7 +378,7 @@ static void ses_finished(struct ap_session *ses)
pthread_rwlock_unlock(&sessions_lock);
if (rpd->auth_ctx) {
- rad_server_req_cancel(rpd->auth_ctx->req);
+ rad_server_req_cancel(rpd->auth_ctx->req, 1);
rad_req_free(rpd->auth_ctx->req);
mempool_free(rpd->auth_ctx);
rpd->auth_ctx = NULL;
@@ -383,7 +388,7 @@ static void ses_finished(struct ap_session *ses)
if (rpd->acct_started)
rad_acct_stop_defer(rpd);
else {
- rad_server_req_cancel(rpd->acct_req);
+ rad_server_req_cancel(rpd->acct_req, 1);
rad_req_free(rpd->acct_req);
}
}
diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h
index 22124a2b..b76cfcab 100644
--- a/accel-pppd/radius/radius_p.h
+++ b/accel-pppd/radius/radius_p.h
@@ -208,7 +208,7 @@ struct rad_server_t *rad_server_get2(int, in_addr_t, int);
void rad_server_put(struct rad_server_t *, int);
int rad_server_req_enter(struct rad_req_t *);
void rad_server_req_exit(struct rad_req_t *);
-int rad_server_req_cancel(struct rad_req_t *);
+int rad_server_req_cancel(struct rad_req_t *, int full);
int rad_server_realloc(struct rad_req_t *);
void rad_server_fail(struct rad_server_t *);
void rad_server_timeout(struct rad_server_t *);
diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c
index 94754a26..0382e165 100644
--- a/accel-pppd/radius/req.c
+++ b/accel-pppd/radius/req.c
@@ -231,6 +231,7 @@ int rad_req_acct_fill(struct rad_req_t *req)
void rad_req_free(struct rad_req_t *req)
{
assert(!req->active);
+ assert(!req->entry.next);
if (req->serv)
rad_server_put(req->serv, req->type);
@@ -386,6 +387,9 @@ int rad_req_read(struct triton_md_handler_t *h)
struct rad_req_t *req = container_of(h, typeof(*req), hnd);
struct rad_packet_t *pack;
+ if (!req->rpd)
+ log_switch(triton_context_self(), NULL);
+
while (1) {
if (rad_packet_recv(h->fd, &pack, NULL))
return 0;
@@ -400,6 +404,8 @@ int rad_req_read(struct triton_md_handler_t *h)
if (req->active)
rad_server_req_exit(req);
+ else
+ rad_server_req_cancel(req, 0);
if (req->log) {
req->log("recv ");
diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c
index 441936c1..664c11dd 100644
--- a/accel-pppd/radius/serv.c
+++ b/accel-pppd/radius/serv.c
@@ -104,7 +104,10 @@ static void req_wakeup(struct rad_req_t *req)
{
struct timespec ts;
- log_ppp_debug("radius(%i): wakeup %i\n", req->serv->id, req->active);
+ if (!req->rpd)
+ log_switch(triton_context_self(), NULL);
+
+ log_ppp_debug("radius(%i): wakeup %p %i\n", req->serv->id, req, req->active);
if (!req->active)
return;
@@ -128,7 +131,7 @@ static void req_wakeup(struct rad_req_t *req)
req->send(req, 1);
}
-int rad_server_req_cancel(struct rad_req_t *req)
+int rad_server_req_cancel(struct rad_req_t *req, int full)
{
int r = 0;
@@ -140,6 +143,11 @@ int rad_server_req_cancel(struct rad_req_t *req)
}
pthread_mutex_unlock(&req->serv->lock);
+ triton_cancel_call(req->rpd ? req->rpd->ses->ctrl->ctx : NULL, (triton_event_func)req_wakeup);
+
+ if (!full)
+ return r;
+
if (req->active)
rad_server_req_exit(req);
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index f550db26..2807da82 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -517,7 +517,7 @@ int __export triton_context_call(struct triton_context_t *ud, void (*func)(void
void __export triton_cancel_call(struct triton_context_t *ud, void (*func)(void *))
{
- struct _triton_context_t *ctx = (struct _triton_context_t *)ud->tpd;
+ struct _triton_context_t *ctx = ud ? (struct _triton_context_t *)ud->tpd : (struct _triton_context_t *)default_ctx.tpd;
struct list_head *pos, *n;
struct _triton_ctx_call_t *call;