diff options
| author | xebd <xeb@mail.ru> | 2020-03-10 13:35:47 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-10 13:35:47 +0300 |
| commit | 7afe0f075676219ab4b9e8dbfed294992e9f360b (patch) | |
| tree | 4a7349449ac2072e52b441c813df42be4fec0ae1 /accel-pppd/ctrl/ipoe | |
| parent | 5db4429c75352b636cb8bb441216c4816ee8421f (diff) | |
| parent | 58b41703427284ca849bed7d11087b76ef16a46f (diff) | |
| download | accel-ppp-7afe0f075676219ab4b9e8dbfed294992e9f360b.tar.gz accel-ppp-7afe0f075676219ab4b9e8dbfed294992e9f360b.zip | |
Merge pull request #121 from themiron/max-starting-cleanup
Add global [common]max-starting option
Diffstat (limited to 'accel-pppd/ctrl/ipoe')
| -rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 24 |
1 files changed, 9 insertions, 15 deletions
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index b1504a2f..87261cb3 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) { |
