From ca0d0010a85300b6959d7b6ccba52ab101915c0b Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Mon, 10 Nov 2014 14:14:26 +0300 Subject: 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. --- accel-pppd/accel-ppp.conf | 1 + accel-pppd/accel-ppp.conf.5 | 3 +++ accel-pppd/shaper/limiter.c | 14 +++++++++++--- accel-pppd/shaper/shaper.c | 15 +++++++++++++-- accel-pppd/shaper/shaper.h | 1 + 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 2987934..197c1a5 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -212,6 +212,7 @@ gw-ip-address=192.168.100.1 #mtu=0 #r2q=10 #quantum=1500 +#moderate-quantum=1 #cburst=1534 #ifb=ifb0 up-limiter=police diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index 27e8f3d..e29d418 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -872,6 +872,9 @@ Specifies r2q parameter of root htb qdisc. .BI "quantum=" n Specifies quantum parameter of htb classes. .TP +.BI "moderate-quantum=" 1|0 +If fixed quantum is not specified and this option is specified then shaper module will check for quantum value is valid (in range 1000-200000). +.TP .BI "up-limiter=" police|htb Specifes upstream rate limiting method. .TP diff --git a/accel-pppd/shaper/limiter.c b/accel-pppd/shaper/limiter.c index 18b11a4..954a116 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)); diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 40677de..14388ed 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -38,6 +38,7 @@ double conf_latency = 0.05; int conf_mpu = 0; int conf_mtu = 0; int conf_quantum = 1500; +int conf_moderate_quantum; int conf_r2q = 10; int conf_cburst = 1534; int conf_ifb_ifindex; @@ -909,12 +910,22 @@ static void load_config(void) conf_mtu = 0; opt = conf_get_opt("shaper", "r2q"); - if (opt && atoi(opt) >= 0) + if (opt) conf_r2q = atoi(opt); + else + conf_r2q = 10; opt = conf_get_opt("shaper", "quantum"); - if (opt && atoi(opt) >= 0) + if (opt) conf_quantum = atoi(opt); + else + conf_quantum = 0; + + opt = conf_get_opt("shaper", "moderate-quantum"); + if (opt) + conf_moderate_quantum = atoi(opt); + else + conf_moderate_quantum = 0; opt = conf_get_opt("shaper", "cburst"); if (opt && atoi(opt) >= 0) diff --git a/accel-pppd/shaper/shaper.h b/accel-pppd/shaper/shaper.h index 946c991..f3ba8d9 100644 --- a/accel-pppd/shaper/shaper.h +++ b/accel-pppd/shaper/shaper.h @@ -33,6 +33,7 @@ extern double conf_latency; extern int conf_mpu; extern int conf_mtu; extern int conf_quantum; +extern int conf_moderate_quantum; extern int conf_r2q; extern int conf_cburst; extern int conf_ifb_ifindex; -- cgit v1.2.3