diff options
author | Gavrilenkov A <sasha-dag@yandex.ru> | 2019-09-04 08:42:22 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2019-09-04 08:42:22 +0300 |
commit | 02008c74a19c538ff7d9ce643c8cd4c738886196 (patch) | |
tree | 632352175cf57ff07add3b0a72159f75ccbe16e8 /accel-pppd | |
parent | 7027bbc6fc59734beacd32e18d843beb882a8d0d (diff) | |
download | accel-ppp-02008c74a19c538ff7d9ce643c8cd4c738886196.tar.gz accel-ppp-02008c74a19c538ff7d9ce643c8cd4c738886196.zip |
ipoe,pptp: introduced max-starting option (limit number of starting sessions)
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 2 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 16 | ||||
-rw-r--r-- | accel-pppd/ctrl/pptp/pptp.c | 11 |
3 files changed, 27 insertions, 2 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 1db492f3..2eba8309 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -67,6 +67,7 @@ unit-cache=1 #noauth=0 [pptp] +#max-starting=0 verbose=1 #echo-interval=30 #ifname=pptp%d @@ -128,6 +129,7 @@ verbose=1 #ifname=sstp%d [ipoe] +#max-starting=0 verbose=1 username=ifname #password=username diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 1316b615..f6378265 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -125,6 +125,7 @@ static int conf_username; static const char *conf_password; static int conf_unit_cache; static int conf_noauth; +static int conf_max_starting; #ifdef RADIUS static int conf_vendor; static const char *conf_vendor_str; @@ -1765,7 +1766,10 @@ static void __ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet if (connlimit_loaded && pack->msg_type == DHCPDISCOVER && connlimit_check(serv->opt_shared ? cl_key_from_mac(pack->hdr->chaddr) : serv->ifindex)) return; - + if (conf_max_starting > 0 && pack->msg_type == DHCPDISCOVER && stat_starting > conf_max_starting) { + log_warn("ipoe: Count of starting sessions > conf_max_starting, droping connection...\n"); + return; + } pthread_mutex_lock(&serv->lock); if (pack->msg_type == DHCPDISCOVER) { if (check_notify(serv, pack)) @@ -2019,7 +2023,10 @@ static struct ipoe_session *ipoe_session_create_up(struct ipoe_serv *serv, struc if (connlimit_loaded && connlimit_check(cl_key_from_ipv4(saddr))) return NULL; - + if (conf_max_starting > 0 && stat_starting > conf_max_starting) { + log_warn("ipoe: Count of starting sessions > conf_max_starting, droping connection...\n"); + return NULL; + } if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions) return NULL; @@ -3722,6 +3729,11 @@ static void load_config(void) conf_password = opt; } else conf_password = NULL; + opt = conf_get_opt("ipoe", "max-starting"); + if (opt) + conf_max_starting = atoi(opt); + else + conf_max_starting = 0; opt = conf_get_opt("ipoe", "netmask"); if (opt) { diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index 7ca4b77a..081e9216 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -55,6 +55,7 @@ struct pptp_conn_t struct ppp_t ppp; }; +static int conf_max_starting; static int conf_ppp_max_mtu = PPTP_MAX_MTU; static int conf_timeout = 5; static int conf_echo_interval = 0; @@ -653,6 +654,11 @@ static int pptp_connect(struct triton_md_handler_t *h) close(sock); continue; } + if (conf_max_starting > 0 && stat_starting >= conf_max_starting) { + close(sock); + log_warn("pptp: Count of starting sessions > conf_max_starting, droping connection...\n"); + continue; + } if (triton_module_loaded("connlimit") && connlimit_check(cl_key_from_ipv4(addr.sin_addr.s_addr))) { close(sock); @@ -777,6 +783,11 @@ static void load_config(void) else conf_ppp_max_mtu = PPTP_MAX_MTU; + opt = conf_get_opt("pptp", "max-starting"); + if (opt) + conf_max_starting = atoi(opt); + else + conf_max_starting = 0; conf_mppe = MPPE_UNSET; opt = conf_get_opt("pptp", "mppe"); if (opt) { |