diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2014-11-10 14:14:26 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2014-11-10 14:16:47 +0300 |
commit | ca0d0010a85300b6959d7b6ccba52ab101915c0b (patch) | |
tree | 7f24aed9ed95ce7ae98b54fa65fd82f5c71caf69 /accel-pppd/shaper/limiter.c | |
parent | b276238f8721849c364cf718f854c7b07a706254 (diff) | |
download | accel-ppp-ca0d0010a85300b6959d7b6ccba52ab101915c0b.tar.gz accel-ppp-ca0d0010a85300b6959d7b6ccba52ab101915c0b.zip |
shaper: fixed passing quantum parameter to kernel
shaper: introduced moderate-quantum option
If fixed quantum is not specified and moderate-quantum is specified then shaper module
will check for quantum value to be in valid range (1000-200000).
This suppresses annoying kernel messages.
Remark: quantum is rate/r2q, rate is in bytes/sec.
Diffstat (limited to 'accel-pppd/shaper/limiter.c')
-rw-r--r-- | accel-pppd/shaper/limiter.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/accel-pppd/shaper/limiter.c b/accel-pppd/shaper/limiter.c index 18b11a48..954a1169 100644 --- a/accel-pppd/shaper/limiter.c +++ b/accel-pppd/shaper/limiter.c @@ -77,12 +77,12 @@ static int qdisc_htb_class(struct qdisc_opt *qopt, struct nlmsghdr *n) struct rtattr *tail; memset(&opt, 0, sizeof(opt)); - + opt.rate.rate = qopt->rate; opt.rate.mpu = conf_mpu; opt.ceil.rate = qopt->rate; opt.ceil.mpu = conf_mpu; - + if (tc_calc_rtable(&opt.rate, rtab, cell_log, mtu, linklayer) < 0) { log_ppp_error("shaper: failed to calculate rate table.\n"); return -1; @@ -94,7 +94,15 @@ static int qdisc_htb_class(struct qdisc_opt *qopt, struct nlmsghdr *n) return -1; } opt.cbuffer = tc_calc_xmittime(opt.ceil.rate, conf_cburst ? conf_cburst : qopt->buffer); - + + if (qopt->quantum) + opt.quantum = qopt->quantum; + else if (conf_moderate_quantum) { + unsigned int q = qopt->rate / conf_r2q; + if (q < 1500 || q > 200000) + opt.quantum = q < 1500 ? 1500 : 200000; + } + tail = NLMSG_TAIL(n); addattr_l(n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); addattr_l(n, TCA_BUF_MAX, TCA_HTB_PARMS, &opt, sizeof(opt)); |