summaryrefslogtreecommitdiff
path: root/accel-pppd/ppp
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2011-08-25 13:28:42 +0400
committerKozlov Dmitry <dima@server>2011-08-25 13:28:42 +0400
commit946bc48f3c060161353aceb96166820be80dd846 (patch)
tree7edd15a93b6a5899a293216fc12f86acb17f5344 /accel-pppd/ppp
parentada863c1778f30f3c423c0b3666eaddfebc1991c (diff)
downloadaccel-ppp-946bc48f3c060161353aceb96166820be80dd846.tar.gz
accel-ppp-946bc48f3c060161353aceb96166820be80dd846.zip
ppp: ipcp/ipv6cp: add layer start timeout to prevent session hangup
Diffstat (limited to 'accel-pppd/ppp')
-rw-r--r--accel-pppd/ppp/ppp_ipcp.c29
-rw-r--r--accel-pppd/ppp/ppp_ipcp.h2
-rw-r--r--accel-pppd/ppp/ppp_ipv6cp.c31
-rw-r--r--accel-pppd/ppp/ppp_ipv6cp.h2
4 files changed, 55 insertions, 9 deletions
diff --git a/accel-pppd/ppp/ppp_ipcp.c b/accel-pppd/ppp/ppp_ipcp.c
index 6e349899..7a424911 100644
--- a/accel-pppd/ppp/ppp_ipcp.c
+++ b/accel-pppd/ppp/ppp_ipcp.c
@@ -28,6 +28,8 @@ struct recv_opt_t
#define IPV4_PREFERE 2
#define IPV4_REQUIRE 3
+#define START_TIMEOUT 60
+
static int conf_ipv4 = IPV4_ALLOW;
static LIST_HEAD(option_handlers);
@@ -110,6 +112,15 @@ static struct ppp_layer_data_t *ipcp_layer_init(struct ppp_t *ppp)
return &ipcp->ld;
}
+static void ipcp_start_timeout(struct triton_timer_t *t)
+{
+ struct ppp_ipcp_t *ipcp = container_of(t, typeof(*ipcp), timeout);
+
+ triton_timer_del(t);
+
+ ppp_terminate(ipcp->ppp, TERM_USER_ERROR, 0);
+}
+
int ipcp_layer_start(struct ppp_layer_data_t *ld)
{
struct ppp_ipcp_t *ipcp = container_of(ld, typeof(*ipcp), ld);
@@ -120,10 +131,16 @@ int ipcp_layer_start(struct ppp_layer_data_t *ld)
ipcp->starting = 1;
- if (!ipcp->ld.passive && conf_ipv4 != IPV4_DENY) {
- ppp_fsm_lower_up(&ipcp->fsm);
- if (ppp_fsm_open(&ipcp->fsm))
- return -1;
+ if (conf_ipv4 != IPV4_DENY) {
+ if (ipcp->ld.passive) {
+ ipcp->timeout.expire = ipcp_start_timeout;
+ ipcp->timeout.expire_tv.tv_sec = START_TIMEOUT;
+ triton_timer_add(ipcp->ppp->ctrl->ctx, &ipcp->timeout, 0);
+ } else {
+ ppp_fsm_lower_up(&ipcp->fsm);
+ if (ppp_fsm_open(&ipcp->fsm))
+ return -1;
+ }
}
return 0;
@@ -151,6 +168,9 @@ void ipcp_layer_free(struct ppp_layer_data_t *ld)
ipcp_options_free(ipcp);
ppp_fsm_free(&ipcp->fsm);
+ if (ipcp->timeout.tpd)
+ triton_timer_del(&ipcp->timeout);
+
_free(ipcp);
}
@@ -659,6 +679,7 @@ static void ipcp_recv(struct ppp_handler_t*h)
ipcp->ld.passive = 0;
ppp_fsm_lower_up(&ipcp->fsm);
ppp_fsm_open(&ipcp->fsm);
+ triton_timer_del(&ipcp->timeout);
}
if (delay_ack && !ipcp->delay_ack)
__ipcp_layer_up(ipcp);
diff --git a/accel-pppd/ppp/ppp_ipcp.h b/accel-pppd/ppp/ppp_ipcp.h
index 0ce20e9f..301bdcec 100644
--- a/accel-pppd/ppp/ppp_ipcp.h
+++ b/accel-pppd/ppp/ppp_ipcp.h
@@ -85,6 +85,8 @@ struct ppp_ipcp_t
struct ppp_t *ppp;
struct list_head options;
+ struct triton_timer_t timeout;
+
struct list_head ropt_list; // last received ConfReq
int ropt_len;
diff --git a/accel-pppd/ppp/ppp_ipv6cp.c b/accel-pppd/ppp/ppp_ipv6cp.c
index 371efcbd..554eacb2 100644
--- a/accel-pppd/ppp/ppp_ipv6cp.c
+++ b/accel-pppd/ppp/ppp_ipv6cp.c
@@ -28,6 +28,8 @@ struct recv_opt_t
#define IPV6_PREFERE 2
#define IPV6_REQUIRE 3
+#define START_TIMEOUT 60
+
static int conf_ipv6 = IPV6_ALLOW;
static LIST_HEAD(option_handlers);
@@ -110,6 +112,15 @@ static struct ppp_layer_data_t *ipv6cp_layer_init(struct ppp_t *ppp)
return &ipv6cp->ld;
}
+static void ipv6cp_start_timeout(struct triton_timer_t *t)
+{
+ struct ppp_ipv6cp_t *ipv6cp = container_of(t, typeof(*ipv6cp), timeout);
+
+ triton_timer_del(t);
+
+ ppp_terminate(ipv6cp->ppp, TERM_USER_ERROR, 0);
+}
+
int ipv6cp_layer_start(struct ppp_layer_data_t *ld)
{
struct ppp_ipv6cp_t *ipv6cp = container_of(ld, typeof(*ipv6cp), ld);
@@ -120,10 +131,16 @@ int ipv6cp_layer_start(struct ppp_layer_data_t *ld)
ipv6cp->starting = 1;
- if (!ipv6cp->ld.passive && conf_ipv6 != IPV6_DENY) {
- ppp_fsm_lower_up(&ipv6cp->fsm);
- if (ppp_fsm_open(&ipv6cp->fsm))
- return -1;
+ if (conf_ipv6 != IPV6_DENY) {
+ if (ipv6cp->ld.passive) {
+ ipv6cp->timeout.expire = ipv6cp_start_timeout;
+ ipv6cp->timeout.expire_tv.tv_sec = START_TIMEOUT;
+ triton_timer_add(ipv6cp->ppp->ctrl->ctx, &ipv6cp->timeout, 0);
+ } else {
+ ppp_fsm_lower_up(&ipv6cp->fsm);
+ if (ppp_fsm_open(&ipv6cp->fsm))
+ return -1;
+ }
}
return 0;
@@ -151,6 +168,9 @@ void ipv6cp_layer_free(struct ppp_layer_data_t *ld)
ipv6cp_options_free(ipv6cp);
ppp_fsm_free(&ipv6cp->fsm);
+ if (ipv6cp->timeout.tpd)
+ triton_timer_del(&ipv6cp->timeout);
+
_free(ipv6cp);
}
@@ -659,6 +679,7 @@ static void ipv6cp_recv(struct ppp_handler_t*h)
ipv6cp->ld.passive = 0;
ppp_fsm_lower_up(&ipv6cp->fsm);
ppp_fsm_open(&ipv6cp->fsm);
+ triton_timer_del(&ipv6cp->timeout);
}
if (delay_ack && !ipv6cp->delay_ack)
__ipv6cp_layer_up(ipv6cp);
@@ -796,4 +817,4 @@ static void ipv6cp_init(void)
ppp_register_layer("ipv6cp", &ipv6cp_layer);
}
-DEFINE_INIT(4, ipv6cp_init);
+DEFINE_INIT(5, ipv6cp_init);
diff --git a/accel-pppd/ppp/ppp_ipv6cp.h b/accel-pppd/ppp/ppp_ipv6cp.h
index 2e5c201f..6f676053 100644
--- a/accel-pppd/ppp/ppp_ipv6cp.h
+++ b/accel-pppd/ppp/ppp_ipv6cp.h
@@ -93,6 +93,8 @@ struct ppp_ipv6cp_t
struct ppp_t *ppp;
struct list_head options;
+ struct triton_timer_t timeout;
+
struct list_head ropt_list; // last received ConfReq
int ropt_len;