From 1833d760f0b797844758f41bf3a238d57b2b0aa4 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Sat, 25 Jun 2016 10:55:27 +0300 Subject: 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 --- accel-pppd/ppp/ppp.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) (limited to 'accel-pppd/ppp') diff --git a/accel-pppd/ppp/ppp.c b/accel-pppd/ppp/ppp.c index f05b47b..db09148 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) -- cgit v1.2.3