summaryrefslogtreecommitdiff
path: root/accel-pppd/shaper
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2016-12-09 21:23:33 +0300
committerDmitry Kozlov <xeb@mail.ru>2016-12-09 21:23:33 +0300
commitac3d0db11524533db1904b315447fefd1296065d (patch)
tree9c89e453d2838bd62238a8f7f40238ff1c94493d /accel-pppd/shaper
parent58ed82d19ab229f203e03c3eb10f78863cb5177a (diff)
downloadaccel-ppp-ac3d0db11524533db1904b315447fefd1296065d.tar.gz
accel-ppp-ac3d0db11524533db1904b315447fefd1296065d.zip
shaper: fixed conditions to install limiter (may install only up or only down limiter)
Diffstat (limited to 'accel-pppd/shaper')
-rw-r--r--accel-pppd/shaper/limiter.c39
-rw-r--r--accel-pppd/shaper/shaper.c4
2 files changed, 24 insertions, 19 deletions
diff --git a/accel-pppd/shaper/limiter.c b/accel-pppd/shaper/limiter.c
index 0945e98..0e75401 100644
--- a/accel-pppd/shaper/limiter.c
+++ b/accel-pppd/shaper/limiter.c
@@ -463,25 +463,30 @@ int install_limiter(struct ap_session *ses, int down_speed, int down_burst, int
return -1;
}
- down_speed = down_speed * 1000 / 8;
- down_burst = down_burst ? down_burst : conf_down_burst_factor * down_speed;
- up_speed = up_speed * 1000 / 8;
- up_burst = up_burst ? up_burst : conf_up_burst_factor * up_speed;
-
- if (conf_down_limiter == LIM_TBF)
- r = install_tbf(rth, ses->ifindex, down_speed, down_burst);
- else {
- r = install_htb(rth, ses->ifindex, down_speed, down_burst);
- if (r == 0)
- r = install_leaf_qdisc(rth, ses->ifindex, 0x00010001, 0x00020000);
+ if (down_speed) {
+ down_speed = down_speed * 1000 / 8;
+ down_burst = down_burst ? down_burst : conf_down_burst_factor * down_speed;
+
+ if (conf_down_limiter == LIM_TBF)
+ r = install_tbf(rth, ses->ifindex, down_speed, down_burst);
+ else {
+ r = install_htb(rth, ses->ifindex, down_speed, down_burst);
+ if (r == 0)
+ r = install_leaf_qdisc(rth, ses->ifindex, 0x00010001, 0x00020000);
+ }
}
- if (conf_up_limiter == LIM_POLICE)
- r = install_police(rth, ses->ifindex, up_speed, up_burst);
- else {
- r = install_htb_ifb(rth, ses->ifindex, idx, up_speed, up_burst);
- if (r == 0)
- r = install_leaf_qdisc(rth, conf_ifb_ifindex, 0x00010000 + idx, idx << 16);
+ if (up_speed) {
+ up_speed = up_speed * 1000 / 8;
+ up_burst = up_burst ? up_burst : conf_up_burst_factor * up_speed;
+
+ if (conf_up_limiter == LIM_POLICE)
+ r = install_police(rth, ses->ifindex, up_speed, up_burst);
+ else {
+ r = install_htb_ifb(rth, ses->ifindex, idx, up_speed, up_burst);
+ if (r == 0)
+ r = install_leaf_qdisc(rth, conf_ifb_ifindex, 0x00010000 + idx, idx << 16);
+ }
}
if (conf_fwmark)
diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c
index f13290d..03adfe2 100644
--- a/accel-pppd/shaper/shaper.c
+++ b/accel-pppd/shaper/shaper.c
@@ -443,7 +443,7 @@ static void ev_shaper(struct ev_shaper_t *ev)
if (!pd->idx)
pd->idx = alloc_idx(pd->ses->ifindex);
- if (pd->down_speed > 0 && pd->up_speed > 0) {
+ if (pd->down_speed > 0 || pd->up_speed > 0) {
if (!install_limiter(ev->ses, down_speed, down_burst, up_speed, up_burst, pd->idx)) {
if (conf_verbose)
log_ppp_info2("shaper: installed shaper %i/%i (Kbit)\n", down_speed, up_speed);
@@ -483,7 +483,7 @@ static void ev_ppp_pre_up(struct ap_session *ses)
if (!pd->idx)
pd->idx = alloc_idx(ses->ifindex);
- if (down_speed > 0 && up_speed > 0) {
+ if (down_speed > 0 || up_speed > 0) {
if (!install_limiter(ses, down_speed, down_burst, up_speed, up_burst, pd->idx)) {
if (conf_verbose)
log_ppp_info2("shaper: installed shaper %i/%i (Kbit)\n", down_speed, up_speed);