From 9ea88bac7d5bf8fc5cf2d5f7d0a734ec7a9e6df6 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Tue, 18 Apr 2017 16:07:35 +0300 Subject: 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. --- accel-pppd/ctrl/l2tp/l2tp.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'accel-pppd/ctrl/l2tp/l2tp.c') diff --git a/accel-pppd/ctrl/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index bb3df4d4..6399655e 100644 --- a/accel-pppd/ctrl/l2tp/l2tp.c +++ b/accel-pppd/ctrl/l2tp/l2tp.c @@ -2737,6 +2737,9 @@ static int l2tp_recv_SCCRQ(const struct l2tp_serv_t *serv, return 0; } + if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting > conf_max_sessions) + return 0; + if (triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(pack->addr.sin_addr.s_addr))) { log_warn("l2tp: connection limits reached," @@ -3263,6 +3266,9 @@ static int l2tp_recv_ICRQ(struct l2tp_conn_t *conn, return 0; } + if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting > conf_max_sessions) + return 0; + if (triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(conn->peer_addr.sin_addr.s_addr))) { log_tunnel(log_warn, conn, "connection limits reached," @@ -3563,6 +3569,9 @@ static int l2tp_recv_OCRQ(struct l2tp_conn_t *conn, return 0; } + if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting > conf_max_sessions) + return 0; + if (triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(conn->peer_addr.sin_addr.s_addr))) { log_tunnel(log_warn, conn, "connection limits reached," -- cgit v1.2.3