summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-11-10 14:14:26 +0300
committerDmitry Kozlov <xeb@mail.ru>2014-11-10 14:16:47 +0300
commitca0d0010a85300b6959d7b6ccba52ab101915c0b (patch)
tree7f24aed9ed95ce7ae98b54fa65fd82f5c71caf69
parentb276238f8721849c364cf718f854c7b07a706254 (diff)
downloadaccel-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.
-rw-r--r--accel-pppd/accel-ppp.conf1
-rw-r--r--accel-pppd/accel-ppp.conf.53
-rw-r--r--accel-pppd/shaper/limiter.c14
-rw-r--r--accel-pppd/shaper/shaper.c15
-rw-r--r--accel-pppd/shaper/shaper.h1
5 files changed, 29 insertions, 5 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index 29879348..197c1a57 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 27e8f3d0..e29d418b 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 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));
diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c
index 40677de8..14388eda 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 946c9918..f3ba8d99 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;