summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-06-25 10:55:27 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-06-25 10:55:27 +0300
commit1833d760f0b797844758f41bf3a238d57b2b0aa4 (patch)
treed134cefdb218840ba6105988630880435af792c0
parent2d10076d240537e1f48bca0bb6e0b99aa4427406 (diff)
downloadaccel-ppp-1833d760f0b797844758f41bf3a238d57b2b0aa4.tar.gz
accel-ppp-1833d760f0b797844758f41bf3a238d57b2b0aa4.zip
ppp: introduced unit-preallocate option
If set to 1 then allocate unit (interface) before authorization, so Nas-Port and Nas-Port-Id would be defined in Access-Request phase
-rw-r--r--accel-pppd/accel-ppp.conf1
-rw-r--r--accel-pppd/accel-ppp.conf.53
-rw-r--r--accel-pppd/ppp/ppp.c18
3 files changed, 20 insertions, 2 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index d2212304..98ca8850 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -60,6 +60,7 @@ lcp-echo-interval=20
#lcp-echo-failure=3
lcp-echo-timeout=120
unit-cache=1
+#unit-preallocate=1
[auth]
#any-login=0
diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5
index eefbe6be..d49b65fb 100644
--- a/accel-pppd/accel-ppp.conf.5
+++ b/accel-pppd/accel-ppp.conf.5
@@ -195,6 +195,9 @@ Specifies timeout in seconds to wait for any peer activity. If this option speci
.BI "unit-cache=" n
Specifies number of interfaces to keep in cache. It means that don't destory interface after corresponding session is destoyed, instead place it to cache and use it later for new sessions repeatedly.
This should reduce kernel-level interface creation/deletion rate lack.
+.TP
+.BI "unit-preallocate=" 0|1
+If set to 1 then allocate ppp unit (interface) before authorization, so Nas-Port and Nas-Port-Id would be defined in Access-Request phase.
.SH [ipoe]
.TP
.BI "verbose=" n
diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c
index f05b47bb..db091487 100644
--- a/accel-pppd/ppp/ppp.c
+++ b/accel-pppd/ppp/ppp.c
@@ -28,7 +28,8 @@
#include "memdebug.h"
int __export conf_ppp_verbose;
-int conf_unit_cache = 0;
+int conf_unit_cache;
+static int conf_unit_preallocate;
#define PPP_BUF_SIZE 8192
static mempool_t buf_pool;
@@ -110,7 +111,11 @@ int __export establish_ppp(struct ppp_t *ppp)
ppp->chan_hnd.fd = ppp->chan_fd;
ppp->chan_hnd.read = ppp_chan_read;
- log_ppp_debug("ppp establishing\n");
+ if (conf_unit_preallocate) {
+ if (connect_ppp_channel(ppp))
+ goto exit_close_chan;
+ } else
+ log_ppp_debug("ppp establishing\n");
if (ap_session_starting(&ppp->ses))
goto exit_close_chan;
@@ -133,6 +138,9 @@ int __export connect_ppp_channel(struct ppp_t *ppp)
struct pppunit_cache *uc = NULL;
struct ifreq ifr;
+ if (ppp->unit_fd != -1)
+ return 0;
+
if (uc_size) {
pthread_mutex_lock(&uc_lock);
if (!list_empty(&uc_list)) {
@@ -693,6 +701,12 @@ static void load_config(void)
conf_unit_cache = atoi(opt);
else
conf_unit_cache = 0;
+
+ opt = conf_get_opt("ppp", "unit-preallocate");
+ if (opt)
+ conf_unit_preallocate = atoi(opt);
+ else
+ conf_unit_preallocate = 0;
}
static void init(void)