From ad9e3da777812623292ef53112a088a42e739d2a Mon Sep 17 00:00:00 2001 From: Nikos Mavrogiannopoulos Date: Sat, 9 May 2015 21:34:09 +0200 Subject: [PATCH] radius: notify of disconnect timeout reason --- src/acct/radius.c | 2 ++ src/vpn.h | 1 + src/worker-vpn.c | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/acct/radius.c b/src/acct/radius.c index d91e81cd..ca977829 100644 --- a/src/acct/radius.c +++ b/src/acct/radius.c @@ -257,6 +257,8 @@ VALUE_PAIR *send = NULL, *recvd = NULL; ret = PW_USER_REQUEST; else if (discon_reason == REASON_SERVER_DISCONNECT) ret = PW_ADMIN_RESET; + else if (discon_reason == REASON_TIMEOUT) + ret = PW_ACCT_IDLE_TIMEOUT; else ret = PW_LOST_CARRIER; if (rc_avpair_add(rh, &send, PW_ACCT_TERMINATE_CAUSE, &ret, -1, 0) == NULL) { diff --git a/src/vpn.h b/src/vpn.h index 66876b42..1104b42a 100644 --- a/src/vpn.h +++ b/src/vpn.h @@ -108,6 +108,7 @@ extern int syslog_open; #define REASON_ANY 1 #define REASON_USER_DISCONNECT 2 #define REASON_SERVER_DISCONNECT 3 +#define REASON_TIMEOUT 4 #define ERR_SUCCESS 0 #define ERR_BAD_COMMAND -2 diff --git a/src/worker-vpn.c b/src/worker-vpn.c index 29af81cf..a9a71b9c 100644 --- a/src/worker-vpn.c +++ b/src/worker-vpn.c @@ -774,7 +774,7 @@ int periodic_check(worker_st * ws, unsigned mtu_overhead, time_t now, if (now - ws->last_msg_tcp > DPD_MAX_TRIES * dpd) { oclog(ws, LOG_ERR, "have not received TCP DPD for very long; tearing down connection"); - return -1; + exit_worker_reason(ws, REASON_TIMEOUT); } }