summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf7
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.c4
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c2
-rw-r--r--accel-pppd/ctrl/pppoe/dpado.c22
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c3
-rw-r--r--accel-pppd/lua/session.c6
-rw-r--r--accel-pppd/ppp/ppp_auth.c4
-rw-r--r--accel-pppd/radius/backup.c7
-rw-r--r--accel-pppd/triton/mempool.c5
-rw-r--r--accel-pppd/triton/triton.c16
10 files changed, 41 insertions, 35 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 607609a..b187010 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -31,8 +31,6 @@ pppd_compat
#ipv6_dhcp
#ipv6pool
-#net-accel-dp
-
[core]
log-error=/var/log/accel-ppp/core.log
thread-count=4
@@ -88,7 +86,7 @@ called-sid=mac
#vlan-mon=eth0,10-200
#vlan-timeout=60
#vlan-name=%I.%N
-#interface=eth1,padi-limit=1000,net=accel-dp
+#interface=eth1,padi-limit=1000
interface=eth0
[l2tp]
@@ -298,6 +296,3 @@ verbose=1
pref-lifetime=604800
valid-lifetime=2592000
route-via-gw=1
-
-[accel-dp]
-socket=/var/run/accel-dp.sock
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c
index dde5060..8a395ea 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.c
@@ -1145,7 +1145,7 @@ void dhcpv4_reserve_ip(struct dhcpv4_serv *serv, uint32_t ip)
struct dhcpv4_packet *dhcpv4_clone_radius(struct rad_packet_t *rad)
{
struct dhcpv4_packet *pkt = dhcpv4_packet_alloc();
- uint8_t *ptr = pkt->data, *endptr = ptr + BUF_SIZE;
+ uint8_t *ptr, *endptr;
struct dhcpv4_option *opt;
struct rad_attr_t *attr;
@@ -1153,6 +1153,8 @@ struct dhcpv4_packet *dhcpv4_clone_radius(struct rad_packet_t *rad)
return NULL;
pkt->refs = 1;
+ ptr = pkt->data;
+ endptr = ptr + BUF_SIZE;
list_for_each_entry(attr, &rad->attrs, entry) {
if (attr->vendor && attr->vendor->id == VENDOR_DHCP && attr->attr->id < 256) {
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 55881b8..cbb9de6 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -3119,7 +3119,7 @@ static int rescode_get_data(const struct l2tp_attr_t *result_attr,
return 2;
*err_msg = _malloc(msglen + 1);
- if (err_msg) {
+ if (*err_msg) {
memcpy(*err_msg, resavp->error_msg, msglen);
(*err_msg)[msglen] = '\0';
}
diff --git a/accel-pppd/ctrl/pppoe/dpado.c b/accel-pppd/ctrl/pppoe/dpado.c
index c7992bc..71faa13 100644
--- a/accel-pppd/ctrl/pppoe/dpado.c
+++ b/accel-pppd/ctrl/pppoe/dpado.c
@@ -125,21 +125,25 @@ int dpado_parse(const char *str)
_free(r);
}
+ list_splice(&range_list, &dpado_range_list);
+
dpado_range_next = NULL;
dpado_range_prev = NULL;
- while (!list_empty(&range_list)) {
- r = list_entry(range_list.next, typeof(*r), entry);
- list_del(&r->entry);
- list_add_tail(&r->entry, &dpado_range_list);
-
- if (!dpado_range_prev || stat_active >= r->conn_cnt)
+ list_for_each_entry(r, &dpado_range_list, entry) {
+ if (!dpado_range_prev || stat_active >= r->conn_cnt) {
dpado_range_prev = r;
- else if (!dpado_range_next)
- dpado_range_next = r;
+ if (r->entry.next != &dpado_range_list)
+ dpado_range_next = list_entry(r->entry.next, typeof(*r), entry);
+ else
+ dpado_range_next = NULL;
+ }
}
- pado_delay = dpado_range_prev->pado_delay;
+ if (dpado_range_prev)
+ pado_delay = dpado_range_prev->pado_delay;
+ else
+ pado_delay = 0;
if (conf_pado_delay)
_free(conf_pado_delay);
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 11a6ea1..7ab20e3 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -1055,7 +1055,8 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
pado->ppp_max_payload = ppp_max_payload;
pado->timer.expire = pado_timer;
- pado->timer.period = pado_delay;
+ pado->timer.expire_tv.tv_sec = pado_delay / 1000;
+ pado->timer.expire_tv.tv_usec = (pado_delay % 1000) * 1000;
triton_timer_add(&serv->ctx, &pado->timer, 0);
diff --git a/accel-pppd/lua/session.c b/accel-pppd/lua/session.c
index d65a67b..277b299 100644
--- a/accel-pppd/lua/session.c
+++ b/accel-pppd/lua/session.c
@@ -217,11 +217,12 @@ static int session_rx_bytes(lua_State *L)
{
struct ap_session *ses = luaL_checkudata(L, 1, LUA_AP_SESSION);
uint64_t gword_sz = (uint64_t)UINT32_MAX + 1;
- uint64_t bytes = gword_sz*ses->acct_input_gigawords + ses->acct_rx_bytes;
+ uint64_t bytes;
if (!ses)
return 0;
+ bytes = gword_sz*ses->acct_input_gigawords + ses->acct_rx_bytes;
lua_pushnumber(L, bytes);
return 1;
@@ -231,11 +232,12 @@ static int session_tx_bytes(lua_State *L)
{
struct ap_session *ses = luaL_checkudata(L, 1, LUA_AP_SESSION);
uint64_t gword_sz = (uint64_t)UINT32_MAX + 1;
- uint64_t bytes = gword_sz*ses->acct_output_gigawords + ses->acct_tx_bytes;
+ uint64_t bytes;
if (!ses)
return 0;
+ bytes = gword_sz*ses->acct_output_gigawords + ses->acct_tx_bytes;
lua_pushnumber(L, bytes);
return 1;
diff --git a/accel-pppd/ppp/ppp_auth.c b/accel-pppd/ppp/ppp_auth.c
index 2713874..0eaac35 100644
--- a/accel-pppd/ppp/ppp_auth.c
+++ b/accel-pppd/ppp/ppp_auth.c
@@ -364,8 +364,8 @@ void __export ppp_auth_failed(struct ppp_t *ppp, char *username)
_free(username);
ppp->ses.terminate_cause = TERM_AUTH_ERROR;
pthread_rwlock_unlock(&ses_lock);
- log_ppp_info1("%s: authentication failed\n", username);
- log_info1("%s: authentication failed\n", username);
+ log_ppp_info1("%s: authentication failed\n", ppp->ses.username);
+ log_info1("%s: authentication failed\n", ppp->ses.username);
triton_event_fire(EV_SES_AUTH_FAILED, ppp);
} else
log_ppp_info1("authentication failed\n");
diff --git a/accel-pppd/radius/backup.c b/accel-pppd/radius/backup.c
index 93ab3eb..46041d7 100644
--- a/accel-pppd/radius/backup.c
+++ b/accel-pppd/radius/backup.c
@@ -30,8 +30,8 @@
static int session_save(struct ap_session *ses, struct backup_mod *m)
{
struct radius_pd_t *rpd = find_pd(ses);
- uint64_t session_timeout = ses->start_time + rpd->session_timeout.expire_tv.tv_sec;
- uint32_t idle_timeout = rpd->idle_timeout.period / 1000;
+ uint64_t session_timeout;
+ uint32_t idle_timeout;
if (!rpd)
return 0;
@@ -39,6 +39,9 @@ static int session_save(struct ap_session *ses, struct backup_mod *m)
if (!rpd->authenticated)
return -2;
+ session_timeout = ses->start_time + rpd->session_timeout.expire_tv.tv_sec;
+ idle_timeout = rpd->idle_timeout.period / 1000;
+
add_tag(RAD_TAG_INTERIM_INTERVAL, &rpd->acct_interim_interval, 4);
if (rpd->session_timeout.tpd)
diff --git a/accel-pppd/triton/mempool.c b/accel-pppd/triton/mempool.c
index ecc91f3..ac444c5 100644
--- a/accel-pppd/triton/mempool.c
+++ b/accel-pppd/triton/mempool.c
@@ -107,9 +107,6 @@ void __export *mempool_alloc(mempool_t *pool)
__sync_sub_and_fetch(&triton_stat.mempool_available, size);
return it->ptr;
-#ifdef VALGRIND
- }
-#endif
}
spin_unlock(&p->lock);
@@ -123,7 +120,7 @@ void __export *mempool_alloc(mempool_t *pool)
mmap_ptr += size;
spin_unlock(&mmap_lock);
__sync_sub_and_fetch(&triton_stat.mempool_available, size);
- } else {
+ } else {
it = _malloc(size);
__sync_add_and_fetch(&triton_stat.mempool_allocated, size);
}
diff --git a/accel-pppd/triton/triton.c b/accel-pppd/triton/triton.c
index a456746..00a93f3 100644
--- a/accel-pppd/triton/triton.c
+++ b/accel-pppd/triton/triton.c
@@ -54,7 +54,6 @@ struct triton_context_t default_ctx;
static __thread struct triton_context_t *this_ctx;
static __thread jmp_buf jmp_env;
static __thread void *thread_frame;
-static volatile void *thread_stack;
#define log_debug2(fmt, ...)
@@ -106,6 +105,7 @@ static void* triton_thread(struct _triton_thread_t *thread)
{
sigset_t set;
int sig, need_free;
+ void *stack;
sigfillset(&set);
sigdelset(&set, SIGKILL);
@@ -134,7 +134,9 @@ static void* triton_thread(struct _triton_thread_t *thread)
if (this_ctx->before_switch)
this_ctx->before_switch(this_ctx, thread->ctx->bf_arg);
- thread_stack = alloca(thread->ctx->uc->uc_stack.ss_size + 64);
+ stack = alloca(thread->ctx->uc->uc_stack.ss_size + 64);
+ asm volatile("" :: "m" (stack));
+
memcpy(thread_frame - thread->ctx->uc->uc_stack.ss_size, thread->ctx->uc->uc_stack.ss_sp, thread->ctx->uc->uc_stack.ss_size);
setcontext(thread->ctx->uc);
abort();
@@ -472,13 +474,13 @@ void triton_context_print(void)
printf("%p\n", ctx);
}
-static ucontext_t *alloc_context()
+static ucontext_t * __attribute__((noinline)) alloc_context()
{
ucontext_t *uc;
void *frame = __builtin_frame_address(0);
size_t stack_size = thread_frame - frame;
- uc = malloc(sizeof(*uc) + stack_size);
+ uc = _malloc(sizeof(*uc) + stack_size);
uc->uc_stack.ss_sp = (void *)(uc + 1);
uc->uc_stack.ss_size = stack_size;
memcpy(uc->uc_stack.ss_sp, frame, stack_size);
@@ -505,7 +507,7 @@ void __export triton_context_schedule()
if (ctx->wakeup) {
ctx->wakeup = 0;
spin_unlock(&threads_lock);
- free(ctx->uc);
+ _free(ctx->uc);
ctx->uc = NULL;
__sync_sub_and_fetch(&triton_stat.context_sleeping, 1);
log_debug2("ctx %p: exit schedule\n", ctx);
@@ -630,7 +632,7 @@ static void ru_update(struct triton_timer_t *t)
void __export triton_register_init(int order, void (*func)(void))
{
- struct _triton_init_t *i1, *i = malloc(sizeof(*i));
+ struct _triton_init_t *i1, *i = _malloc(sizeof(*i));
struct list_head *p = init_list.next;
@@ -690,7 +692,7 @@ int __export triton_load_modules(const char *mod_sect)
i = list_entry(init_list.next, typeof(*i), entry);
i->func();
list_del(&i->entry);
- free(i);
+ _free(i);
}
return 0;