From da7bb06e70252ba11751f4e3a9f8b97144500d9e Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Thu, 7 Nov 2013 23:33:11 +0400 Subject: shaper: add mtu option Signed-off-by: Dmitry Kozlov --- accel-pppd/accel-ppp.conf | 1 + accel-pppd/shaper/limiter.c | 7 +++---- accel-pppd/shaper/shaper.c | 7 +++++++ accel-pppd/shaper/shaper.h | 1 + 4 files changed, 12 insertions(+), 4 deletions(-) (limited to 'accel-pppd') diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index ed98b9e..0282125 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -167,6 +167,7 @@ gw-ip-address=192.168.100.1 #up-burst-factor=1.0 #latency=50 #mpu=0 +#mtu=0 #r2q=10 #quantum=1500 #cburst=1534 diff --git a/accel-pppd/shaper/limiter.c b/accel-pppd/shaper/limiter.c index 43637f8..82e29df 100644 --- a/accel-pppd/shaper/limiter.c +++ b/accel-pppd/shaper/limiter.c @@ -25,7 +25,6 @@ static int qdisc_tbf(struct qdisc_opt *qopt, struct nlmsghdr *n) { struct tc_tbf_qopt opt; __u32 rtab[256]; - int mtu = 0; int Rcell_log = -1; unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */ struct rtattr *tail; @@ -35,7 +34,7 @@ static int qdisc_tbf(struct qdisc_opt *qopt, struct nlmsghdr *n) opt.rate.rate = qopt->rate; opt.limit = (double)qopt->rate * qopt->latency + qopt->buffer; opt.rate.mpu = conf_mpu; - if (tc_calc_rtable(&opt.rate, rtab, Rcell_log, mtu, linklayer) < 0) { + if (tc_calc_rtable(&opt.rate, rtab, Rcell_log, conf_mtu, linklayer) < 0) { log_ppp_error("shaper: failed to calculate rate table.\n"); return -1; } @@ -73,7 +72,7 @@ static int qdisc_htb_class(struct qdisc_opt *qopt, struct nlmsghdr *n) struct tc_htb_opt opt; __u32 rtab[256],ctab[256]; int cell_log=-1,ccell_log = -1; - unsigned mtu = 1600; + unsigned mtu = conf_mtu ? conf_mtu : 1600; unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */ struct rtattr *tail; @@ -190,7 +189,7 @@ static int install_police(struct rtnl_handle *rth, int ifindex, int rate, int bu __u32 rtab[256]; struct rtattr *tail, *tail1, *tail2, *tail3; int Rcell_log = -1; - int mtu = 0, flowid = 1; + int mtu = conf_mtu, flowid = 1; unsigned int linklayer = LINKLAYER_ETHERNET; /* Assume ethernet */ struct { diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index d6482cf..d5da0a6 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -36,6 +36,7 @@ double conf_down_burst_factor = 0.1; double conf_up_burst_factor = 1; double conf_latency = 0.05; int conf_mpu = 0; +int conf_mtu = 0; int conf_quantum = 1500; int conf_r2q = 10; int conf_cburst = 1534; @@ -905,6 +906,12 @@ static void load_config(void) if (opt && atoi(opt) >= 0) conf_mpu = atoi(opt); + opt = conf_get_opt("shaper", "mtu"); + if (opt) + conf_mtu = atoi(opt); + else + conf_mtu = 0; + opt = conf_get_opt("shaper", "r2q"); if (opt && atoi(opt) >= 0) conf_r2q = atoi(opt); diff --git a/accel-pppd/shaper/shaper.h b/accel-pppd/shaper/shaper.h index 41e6e43..1de41ec 100644 --- a/accel-pppd/shaper/shaper.h +++ b/accel-pppd/shaper/shaper.h @@ -30,6 +30,7 @@ extern double conf_down_burst_factor; extern double conf_up_burst_factor; extern double conf_latency; extern int conf_mpu; +extern int conf_mtu; extern int conf_quantum; extern int conf_r2q; extern int conf_cburst; -- cgit v1.2.3