diff options
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 24 | ||||
-rw-r--r-- | accel-pppd/ctrl/l2tp/l2tp.c | 9 | ||||
-rw-r--r-- | accel-pppd/ctrl/pppoe/pppoe.c | 20 | ||||
-rw-r--r-- | accel-pppd/ctrl/pptp/pptp.c | 12 | ||||
-rw-r--r-- | accel-pppd/ctrl/sstp/sstp.c | 12 |
5 files changed, 38 insertions, 39 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index b1504a2..87261cb 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -127,7 +127,6 @@ 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; @@ -1303,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; @@ -1772,10 +1774,7 @@ 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)) @@ -2029,15 +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))) - 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"); + 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; @@ -3745,11 +3744,6 @@ 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/l2tp/l2tp.c b/accel-pppd/ctrl/l2tp/l2tp.c index 0d1ca21..2467189 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 32dee77..718ebc5 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -87,7 +87,6 @@ struct iplink_arg { long *arg1; }; -static int conf_max_starting; int conf_verbose; char *conf_service_name[255]; int conf_accept_any_service; @@ -967,15 +966,11 @@ 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 (conf_max_starting > 0 && stat_starting >= conf_max_starting) { - log_warn("pppoe: Count of starting sessions > conf_max_starting, droping connection...\n"); + 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; if (check_padi_limit(serv, ethhdr->h_source)) { __sync_add_and_fetch(&stat_PADI_drop, 1); @@ -1101,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; @@ -1936,12 +1934,6 @@ static void load_config(void) char *opt; struct conf_sect_t *s = conf_get_section("pppoe"); - opt = conf_get_opt("pppoe", "max-starting"); - if (opt) - conf_max_starting = atoi(opt); - else - conf_max_starting = 0; - opt = conf_get_opt("pppoe", "verbose"); if (opt) conf_verbose = atoi(opt); diff --git a/accel-pppd/ctrl/pptp/pptp.c b/accel-pppd/ctrl/pptp/pptp.c index 1161da5..3b90139 100644 --- a/accel-pppd/ctrl/pptp/pptp.c +++ b/accel-pppd/ctrl/pptp/pptp.c @@ -55,7 +55,6 @@ 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; @@ -652,13 +651,13 @@ static int pptp_connect(struct triton_md_handler_t *h) continue; } - if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions) { + if (conf_max_starting && ap_session_stat.starting >= conf_max_starting) { close(sock); continue; } - if (conf_max_starting > 0 && stat_starting >= conf_max_starting) { + + if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions) { close(sock); - log_warn("pptp: Count of starting sessions > conf_max_starting, droping connection...\n"); continue; } @@ -789,11 +788,6 @@ 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) { diff --git a/accel-pppd/ctrl/sstp/sstp.c b/accel-pppd/ctrl/sstp/sstp.c index 5bf8fd8..7574a78 100644 --- a/accel-pppd/ctrl/sstp/sstp.c +++ b/accel-pppd/ctrl/sstp/sstp.c @@ -2196,10 +2196,20 @@ 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; + } + + if (conf_max_sessions && ap_session_stat.active + ap_session_stat.starting >= conf_max_sessions) { + 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); - return 0; + continue; } sockaddr_ntop(&addr, addr_buf, sizeof(addr_buf), 0); |