summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2012-07-30 10:42:15 +0400
committerKozlov Dmitry <xeb@mail.ru>2012-07-30 10:42:15 +0400
commitca6455606c14fec4fd825325a1ae0cc8a9c8fe90 (patch)
tree232c405192ae040a19d619a375bd6cbf44a6b75f
parent918036a3c42cb6dd5b796c52b6aaf278c466c928 (diff)
downloadaccel-ppp-xebd-ca6455606c14fec4fd825325a1ae0cc8a9c8fe90.tar.gz
accel-ppp-xebd-ca6455606c14fec4fd825325a1ae0cc8a9c8fe90.zip
add per-CTRL ip-pool option to specify default ip pool name
-rw-r--r--accel-pppd/accel-ppp.conf6
-rw-r--r--accel-pppd/accel-ppp.conf.59
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c9
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c11
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c9
-rw-r--r--accel-pppd/extra/ippool.c8
-rw-r--r--accel-pppd/ppp/ppp.h1
-rw-r--r--accel-pppd/radius/serv.c13
8 files changed, 63 insertions, 3 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 0fd118e..28e8ed0 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -60,6 +60,8 @@ lcp-echo-timeout=120
[pptp]
#echo-interval=30
+#mppe=allow
+#ip-pool=pool1
verbose=1
[pppoe]
@@ -72,6 +74,8 @@ interface=eth0
#ifname-in-sid=called-sid
#tr101=1
#padi-limit=0
+#mppe=allow
+#ip-pool=pool2
verbose=1
[l2tp]
@@ -83,6 +87,8 @@ verbose=1
#host-name=accel-ppp
#dir300_quirk=0
#secret=
+#mppe=allow
+#ip-pool=pool3
verbose=1
[dns]
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index 046c48e..b3e7265 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -231,6 +231,9 @@ Timeout waiting reply from client in seconds (default 5).
.TP
.BI "mppe=" deny|allow|prefer|require
.TP
+.BI "ip-pool=" name
+Specifies ip pool name for address allocation. Usefull in conjuction with ippool module.
+.TP
.SH [pppoe]
.br
Configuration of PPPoE module.
@@ -275,6 +278,9 @@ Specifies overall limit of PADI packets to reply in 1 second period (default 0 -
.TP
.BI "mppe=" deny|allow|prefer|require
.TP
+.BI "ip-pool=" name
+Specifies ip pool name for address allocation. Usefull in conjuction with ippool module.
+.TP
.SH [l2tp]
.br
Configuration of L2TP module.
@@ -308,6 +314,9 @@ is greater of zero then l2tp module will produce verbose logging.
.BI "secret=" string
Specifies secret to connect to server.
.TP
+.BI "ip-pool=" name
+Specifies ip pool name for address allocation. Usefull in conjuction with ippool module.
+.TP
.SH [radius]
.br
Configuration of RADIUS module.
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index fa76048..162c9cb 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -56,6 +56,7 @@ static int conf_dir300_quirk = 0;
static const char *conf_host_name = "accel-ppp";
static const char *conf_secret = NULL;
static int conf_mppe = MPPE_UNSET;
+static char *conf_ip_pool;
static unsigned int stat_active;
static unsigned int stat_starting;
@@ -336,6 +337,7 @@ static int l2tp_tunnel_alloc(struct l2tp_serv_t *serv, struct l2tp_packet_t *pac
conn->ctrl.finished = l2tp_ppp_finished;
conn->ctrl.max_mtu = 1420;
conn->ctrl.mppe = conf_mppe;
+ conn->ctrl.def_pool = conf_ip_pool;
conn->ctrl.calling_station_id = _malloc(17);
conn->ctrl.called_station_id = _malloc(17);
@@ -1232,6 +1234,13 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ opt = conf_get_opt("l2tp", "ip-pool");
+ if (opt) {
+ if (!conf_ip_pool || strcmp(conf_ip_pool, opt))
+ conf_ip_pool = _strdup(opt);
+ } else
+ conf_ip_pool = NULL;
}
static void l2tp_init(void)
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 079ef51..6aef1a9 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -80,7 +80,8 @@ int conf_ifname_in_sid;
char *conf_pado_delay;
int conf_tr101 = 1;
int conf_padi_limit = 0;
-int conf_mppe = MPPE_UNSET;
+static int conf_mppe = MPPE_UNSET;
+static char *conf_ip_pool;
static mempool_t conn_pool;
static mempool_t pado_pool;
@@ -265,6 +266,7 @@ static struct pppoe_conn_t *allocate_channel(struct pppoe_serv_t *serv, const ui
conn->ctrl.type = CTRL_TYPE_PPPOE;
conn->ctrl.name = "pppoe";
conn->ctrl.mppe = conf_mppe;
+ conn->ctrl.def_pool = conf_ip_pool;
conn->ctrl.calling_station_id = _malloc(IFNAMSIZ + 19);
conn->ctrl.called_station_id = _malloc(IFNAMSIZ + 19);
@@ -1424,6 +1426,13 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ opt = conf_get_opt("pppoe", "ip-pool");
+ if (opt) {
+ if (!conf_ip_pool || strcmp(conf_ip_pool, opt))
+ conf_ip_pool = _strdup(opt);
+ } else
+ conf_ip_pool = NULL;
}
static void pppoe_init(void)
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index 2f0c5ef..f2e9d43 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -59,6 +59,7 @@ static int conf_echo_interval = 0;
static int conf_echo_failure = 3;
static int conf_verbose = 0;
static int conf_mppe = MPPE_UNSET;
+static char *conf_ip_pool;
static mempool_t conn_pool;
@@ -671,6 +672,7 @@ static int pptp_connect(struct triton_md_handler_t *h)
conn->ctrl.type = CTRL_TYPE_PPTP;
conn->ctrl.name = "pptp";
conn->ctrl.mppe = conf_mppe;
+ conn->ctrl.def_pool = conf_ip_pool;
conn->ctrl.calling_station_id = _malloc(17);
conn->ctrl.called_station_id = _malloc(17);
@@ -755,6 +757,13 @@ static void load_config(void)
else if (strcmp(opt, "require") == 0)
conf_mppe = MPPE_REQUIRE;
}
+
+ opt = conf_get_opt("pptp", "ip-pool");
+ if (opt) {
+ if (!conf_ip_pool || strcmp(conf_ip_pool, opt))
+ conf_ip_pool = _strdup(opt);
+ } else
+ conf_ip_pool = NULL;
}
static void pptp_init(void)
diff --git a/accel-pppd/extra/ippool.c b/accel-pppd/extra/ippool.c
index fc4fd18..9b0e7e4 100644
--- a/accel-pppd/extra/ippool.c
+++ b/accel-pppd/extra/ippool.c
@@ -209,9 +209,15 @@ static struct ipv4db_item_t *get_ip(struct ppp_t *ppp)
{
struct ippool_item_t *it;
struct ippool_t *p;
+ const char *pool_name = NULL;
if (ppp->ipv4_pool_name)
- p = find_pool(ppp->ipv4_pool_name, 0);
+ pool_name = ppp->ipv4_pool_name;
+ else if (ppp->ctrl->def_pool)
+ pool_name = ppp->ctrl->def_pool;
+
+ if (pool_name)
+ p = find_pool(pool_name, 0);
else
p = def_pool;
diff --git a/accel-pppd/ppp/ppp.h b/accel-pppd/ppp/ppp.h
index e37c75d..ca97d5a 100644
--- a/accel-pppd/ppp/ppp.h
+++ b/accel-pppd/ppp/ppp.h
@@ -76,6 +76,7 @@ struct ppp_ctrl_t
struct triton_context_t *ctx;
int type;
const char *name;
+ const char *def_pool;
int max_mtu;
int mppe;
char *calling_station_id;
diff --git a/accel-pppd/radius/serv.c b/accel-pppd/radius/serv.c
index 30219f7..b7ee0be 100644
--- a/accel-pppd/radius/serv.c
+++ b/accel-pppd/radius/serv.c
@@ -76,6 +76,7 @@ void rad_server_put(struct rad_server_t *s, int type)
int rad_server_req_enter(struct rad_req_t *req)
{
struct timespec ts;
+ //struct rad_req_t *r = NULL;
if (req->serv->need_free)
return -1;
@@ -103,16 +104,26 @@ int rad_server_req_enter(struct rad_req_t *req)
triton_context_schedule();
pthread_mutex_lock(&req->serv->lock);
+ clock_gettime(CLOCK_MONOTONIC, &ts);
+
req->serv->queue_cnt--;
if (ts.tv_sec < req->serv->fail_time || req->serv->need_free) {
+ /*if (!list_empty(&req->serv->req_queue)) {
+ r = list_entry(req->serv->req_queue.next, typeof(*r), entry);
+ list_del(&r->entry);
+ }*/
pthread_mutex_unlock(&req->serv->lock);
+
+ /*if (r)
+ triton_context_wakeup(r->rpd->ppp->ctrl->ctx);*/
+
return -1;
}
}
req->serv->req_cnt++;
pthread_mutex_unlock(&req->serv->lock);
-
+
return 0;
}