summaryrefslogtreecommitdiff
path: root/accel-pppd/ctrl
diff options
context:
space:
mode:
authorVladislav Grishenko <themiron@mail.ru>2020-03-07 04:25:00 +0500
committerVladislav Grishenko <themiron@mail.ru>2020-03-07 04:31:11 +0500
commit6b04e5778c1c0c9686066dd44caccfd755917c25 (patch)
treeb6cceaeba9dcdfe649976210329ae3e698b60e58 /accel-pppd/ctrl
parenta76cfa750c2176b3156dcc65968aff8c90496de0 (diff)
downloadaccel-ppp-6b04e5778c1c0c9686066dd44caccfd755917c25.tar.gz
accel-ppp-6b04e5778c1c0c9686066dd44caccfd755917c25.zip
session: add global [common]max-starting option
usually there's no need to have per-proto limitation, since the need of max starting limitation affects the whole server, not particular protocol only.
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c8
-rw-r--r--accel-pppd/ctrl/l2tp/l2tp.c9
-rw-r--r--accel-pppd/ctrl/pppoe/pppoe.c6
-rw-r--r--accel-pppd/ctrl/pptp/pptp.c5
-rw-r--r--accel-pppd/ctrl/sstp/sstp.c5
5 files changed, 32 insertions, 1 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 17e437d5..87261cb3 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -1302,6 +1302,9 @@ static struct ipoe_session *ipoe_session_create_dhcpv4(struct ipoe_serv *serv, s
if (ap_shutdown)
return NULL;
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
+ return NULL;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return NULL;
@@ -2025,12 +2028,15 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc
if (ap_shutdown)
return NULL;
- if (connlimit_loaded && connlimit_check(cl_key_from_ipv4(saddr)))
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
return NULL;
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return NULL;
+ if (connlimit_loaded && connlimit_check(cl_key_from_ipv4(saddr)))
+ return NULL;
+
if (l4_redirect_list_check(saddr))
return NULL;
diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c
index 0d1ca21a..2467189f 100644
--- a/accel-pppd/ctrl/l2tp/l2tp.c
+++ b/accel-pppd/ctrl/l2tp/l2tp.c
@@ -2761,6 +2761,9 @@ static int l2tp_recv_SCCRQ(const struct l2tp_serv_t *serv,
return 0;
}
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
+ return 0;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return 0;
@@ -3300,6 +3303,9 @@ static int l2tp_recv_ICRQ(struct l2tp_conn_t *conn,
return 0;
}
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
+ return 0;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return 0;
@@ -3603,6 +3609,9 @@ static int l2tp_recv_OCRQ(struct l2tp_conn_t *conn,
return 0;
}
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
+ return 0;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return 0;
diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c
index 120e161f..718ebc51 100644
--- a/accel-pppd/ctrl/pppoe/pppoe.c
+++ b/accel-pppd/ctrl/pppoe/pppoe.c
@@ -966,6 +966,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_starting && ap_session_stat.starting >= conf_max_starting)
+ return;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return;
@@ -1093,6 +1096,9 @@ static void pppoe_recv_PADR(struct pppoe_serv_t *serv, uint8_t *pack, int size)
if (ap_shutdown)
return;
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting)
+ return;
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions)
return;
diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c
index fc5e83b8..3b90139f 100644
--- a/accel-pppd/ctrl/pptp/pptp.c
+++ b/accel-pppd/ctrl/pptp/pptp.c
@@ -651,6 +651,11 @@ static int pptp_connect(struct triton_md_handler_t *h)
continue;
}
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting) {
+ close(sock);
+ continue;
+ }
+
if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions) {
close(sock);
continue;
diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c
index 5bf8fd82..29d13820 100644
--- a/accel-pppd/ctrl/sstp/sstp.c
+++ b/accel-pppd/ctrl/sstp/sstp.c
@@ -2196,6 +2196,11 @@ static int sstp_connect(struct triton_md_handler_t *h)
continue;
}
+ if (conf_max_starting && ap_session_stat.starting >= conf_max_starting) {
+ close(sock);
+ continue;
+ }
+
ip = conf_proxyproto ? INADDR_ANY : sockaddr_ipv4(&addr);
if (ip && triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(ip))) {
close(sock);