diff options
Diffstat (limited to 'accel-pppd')
-rw-r--r-- | accel-pppd/accel-ppp.conf | 3 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 9 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 28 | ||||
-rw-r--r-- | accel-pppd/main.c | 6 | ||||
-rw-r--r-- | accel-pppd/ppp/ipcp_opt_ipaddr.c | 11 | ||||
-rw-r--r-- | accel-pppd/radius/acct.c | 2 | ||||
-rw-r--r-- | accel-pppd/shaper/shaper.c | 36 |
7 files changed, 83 insertions, 12 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 86739125..1db492f3 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -40,6 +40,7 @@ thread-count=4 #sid-case=upper #sid-source=seq #max-sessions=1000 +#check-ip=0 [ppp] verbose=1 @@ -49,7 +50,6 @@ mru=1400 #accomp=deny #pcomp=deny #ccp=0 -#check-ip=0 #mppe=require ipv4=require ipv6=deny @@ -265,6 +265,7 @@ down-limiter=tbf #leaf-qdisc=fq_codel [limit PACKETS] [flows NUMBER] [target TIME] [interval TIME] [quantum BYTES] [[no]ecn] #rate-multiplier=1 #fwmark=1 +#rate-limit=2048/1024 verbose=1 [cli] diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index ed1738ed..6533ef59 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -122,6 +122,9 @@ Path to file for sessions sequence number. Start sequence number may be set ther .TP .BI "max-sessions=" n Specifies maximum sessions which server may processed (default 0, disabled) +.TP +.BI "check-ip=" 0|1 +Specifies whether accel-ppp should check if IP already assigned to other ppp interface (default 0). .SH [ppp] .br PPP module configuration. @@ -159,9 +162,6 @@ Protocol field compression negotiation. .BI "ccp=" n Disable CCP negotiation if this parameter is zero. .TP -.BI "check-ip=" 0|1 -Specifies whether accel-ppp should check if IP already assigned to other ppp interface (default 0). -.TP .BI "mppe=" require|prefer|deny Specifies mppe negotiation preference. .br @@ -1105,6 +1105,9 @@ fq_codel [ limit PACKETS ] [flows NUMBER ] [ target TIME ] [ interval TIME ] [qu .TP .BI "rate-multiplier=" n Due to accel-ppp operates with rates in kilobit basis if you send rates in different basis then you can use this option to bring your values to kilobits. +.TP +.BI "rate-limit=" download_speed/upload_speed +Specifies, should accel-ppp set default rate-limit for clients. Clients rate-limit will be overwritten by RADIUS filter attributes or chap-secrets rate-limit params. .SH [cli] .br Configuration of the command line interface. diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 5438b613..9880162c 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -107,6 +107,7 @@ struct local_net { enum {SID_MAC, SID_IP}; +static int conf_check_exists; static int conf_dhcpv4 = 1; static int conf_up; static int conf_auto; @@ -577,6 +578,24 @@ static int ipoe_create_interface(struct ipoe_session *ses) return 0; } +static int check_exists(struct ipoe_session *self_ipoe, in_addr_t addr) +{ + struct ap_session *ses; + int r = 0; + + pthread_rwlock_rdlock(&ses_lock); + list_for_each_entry(ses, &ses_list, entry) { + if (!ses->terminating && ses->ipv4 && ses->ipv4->peer_addr == addr && ses != &self_ipoe->ses) { + log_ppp_warn("ipoe: IPv4 address already assigned to %s\n", ses->ifname); + r = 1; + break; + } + } + pthread_rwlock_unlock(&ses_lock); + + return r; +} + static void auth_result(struct ipoe_session *ses, int r) { char *username = ses->username; @@ -617,6 +636,11 @@ static void auth_result(struct ipoe_session *ses, int r) ap_session_set_username(&ses->ses, username); log_ppp_info1("%s: authentication succeeded\n", ses->ses.username); + if (conf_check_exists && check_exists(ses, ses->yiaddr)){ + ap_session_terminate(&ses->ses, TERM_NAS_REQUEST, 1); + return; + } + cont: triton_event_fire(EV_SES_AUTHORIZED, &ses->ses); @@ -3930,6 +3954,10 @@ static void load_config(void) else conf_weight = 0; + opt = conf_get_opt("common", "check-ip"); + if (opt && atoi(opt) >= 0) + conf_check_exists = atoi(opt) > 0; + #ifdef RADIUS if (triton_module_loaded("radius")) load_radius_attrs(); diff --git a/accel-pppd/main.c b/accel-pppd/main.c index e31a81cd..cb7e1cda 100644 --- a/accel-pppd/main.c +++ b/accel-pppd/main.c @@ -146,6 +146,7 @@ static void close_all_fd(void) static void __core_restart(int soft) { char exe[PATH_MAX]; + char exe_buf[PATH_MAX]; pthread_sigmask(SIG_SETMASK, &orig_set, NULL); @@ -157,7 +158,7 @@ static void __core_restart(int soft) close_all_fd(); sprintf(exe, "/proc/%u/exe", getpid()); - readlink(exe, exe, PATH_MAX); + readlink(exe, exe_buf, PATH_MAX); while (1) { execv(exe, argv); @@ -180,6 +181,7 @@ static void sigsegv(int num) char cmd[128]; char dump[128]; char exec_file[PATH_MAX]; + char exec_file_buf[PATH_MAX]; pid_t pid; FILE *f; int fd; @@ -213,7 +215,7 @@ static void sigsegv(int num) fclose(f); sprintf(exec_file, "/proc/%s/exe", pid_str); - readlink(exec_file, exec_file, PATH_MAX); + readlink(exec_file, exec_file_buf, PATH_MAX); execlp("gdb", "gdb", "-x", cmd, exec_file, pid_str, NULL); perror("exec"); diff --git a/accel-pppd/ppp/ipcp_opt_ipaddr.c b/accel-pppd/ppp/ipcp_opt_ipaddr.c index 7bac55bf..03eb418f 100644 --- a/accel-pppd/ppp/ipcp_opt_ipaddr.c +++ b/accel-pppd/ppp/ipcp_opt_ipaddr.c @@ -171,9 +171,14 @@ static void load_config(void) { const char *opt; - opt = conf_get_opt("ppp", "check-ip"); - if (opt && atoi(opt) >= 0) - conf_check_exists = atoi(opt) > 0; + opt = conf_get_opt("common", "check-ip"); + if (opt && atoi(opt) > 0) + conf_check_exists = atoi(opt); + else { + opt = conf_get_opt("ppp", "check-ip"); + if (opt && atoi(opt) >= 0) + conf_check_exists = atoi(opt) > 0; + } } static void ipaddr_opt_init() diff --git a/accel-pppd/radius/acct.c b/accel-pppd/radius/acct.c index b17016d5..c0b01900 100644 --- a/accel-pppd/radius/acct.c +++ b/accel-pppd/radius/acct.c @@ -487,6 +487,8 @@ int rad_acct_stop(struct radius_pd_t *rpd) break; } + req->pack->id++; + rad_packet_change_val(req->pack, NULL, "Acct-Status-Type", "Stop"); req_set_stat(req, rpd->ses); req_set_RA(req, req->serv->secret); diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 304a129e..13f75c0f 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -64,6 +64,9 @@ int conf_lq_arg6; static int temp_down_speed; static int temp_up_speed; +static int dflt_down_speed; +static int dflt_up_speed; + static pthread_rwlock_t shaper_lock = PTHREAD_RWLOCK_INITIALIZER; static LIST_HEAD(shaper_list); @@ -515,9 +518,7 @@ static void ev_ppp_pre_up(struct ap_session *ses) up_speed = temp_up_speed; down_burst = 0; up_burst = 0; - } else { - if (!pd->cur_tr) - return; + } else if (pd->cur_tr){ pd->down_speed = pd->cur_tr->down_speed; pd->up_speed = pd->cur_tr->up_speed; down_speed = pd->cur_tr->down_speed; @@ -525,6 +526,15 @@ static void ev_ppp_pre_up(struct ap_session *ses) down_burst = pd->cur_tr->down_burst; up_burst = pd->cur_tr->up_burst; } + else if (dflt_down_speed || dflt_up_speed){ + pd->down_speed = dflt_down_speed; + pd->up_speed = dflt_up_speed; + down_speed = dflt_down_speed; + up_speed = dflt_up_speed; + down_burst = 0; + up_burst = 0; + } + else return; if (!pd->idx) pd->idx = alloc_idx(ses->ifindex); @@ -873,6 +883,22 @@ static struct time_range_t *parse_range(time_t t, const char *val) return r; } +static int parse_dflt_shaper(const char *opt, int *down_speed, int *up_speed) +{ + char *endptr; + + *down_speed = strtol(opt, &endptr, 10); + + if (*endptr != '/'){ + *up_speed = *down_speed; + return 0; + } + + opt = endptr + 1; + *up_speed = strtol(opt, &endptr, 10); + return 0; +} + static void load_time_ranges(void) { struct conf_sect_t *s = conf_get_section("shaper"); @@ -1101,6 +1127,10 @@ static void load_config(void) else conf_fwmark = 0; + opt = conf_get_opt("shaper", "rate-limit"); + if (opt) + parse_dflt_shaper(opt, &dflt_down_speed, &dflt_up_speed); + triton_context_call(&shaper_ctx, (triton_event_func)load_time_ranges, NULL); } |