summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl/pppoe
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-04-18 20:42:32 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-04-18 20:42:32 +0300
commit88a908974b0b2e9c7eee8ad9a8b0b4432e95d167 (patch)
treec347a8a2aca1d4ef069862fac4c131c31a501ceb /accel-pppd/ctrl/pppoe
parentc94c49114ca6c6dd342dad0db525050a154f7a0e (diff)
downloadaccel-ppp-88a908974b0b2e9c7eee8ad9a8b0b4432e95d167.tar.gz
accel-ppp-88a908974b0b2e9c7eee8ad9a8b0b4432e95d167.zip
implemented session count limiting
new config option: [common] max-sessions=N If set then accel-pppd stops reply to new connection requests if total number of sessions (active and starting) is reached specified limit.
Diffstat (limited to 'accel-pppd/ctrl/pppoe')
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index ff6b76f..520c4f1 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -950,6 +950,9 @@ static void pppoe_recv_PADI(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (ap_shutdown || pado_delay == -1)
return;
+ if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting > conf_max_sessions)
+ return;
+
if (check_padi_limit(serv, ethhdr->h_source)) {
__sync_add_and_fetch(&stat_PADI_drop, 1);
if (conf_verbose) {
@@ -1069,6 +1072,9 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (ap_shutdown)
return;
+ if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting > conf_max_sessions)
+ return;
+
if (!memcmp(ethhdr->h_dest, bc_addr, ETH_ALEN)) {
if (conf_verbose)
log_warn("pppoe: discard PADR (destination address is broadcast)\n");