diff options
-rw-r--r-- | accel-pppd/accel-ppp.conf | 1 | ||||
-rw-r--r-- | accel-pppd/accel-ppp.conf.5 | 3 | ||||
-rw-r--r-- | accel-pppd/shaper/limiter.c | 41 | ||||
-rw-r--r-- | accel-pppd/shaper/shaper.c | 11 | ||||
-rw-r--r-- | accel-pppd/shaper/shaper.h | 4 |
5 files changed, 54 insertions, 6 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf index 197c1a57..dee42f76 100644 --- a/accel-pppd/accel-ppp.conf +++ b/accel-pppd/accel-ppp.conf @@ -220,6 +220,7 @@ down-limiter=tbf #leaf-qdisc=sfq perturb 10 #leaf-qdisc=fq_codel [limit PACKETS] [flows NUMBER] [target TIME] [interval TIME] [quantum BYTES] [[no]ecn] #rate-multiplier=1 +#fwmark=1 verbose=1 [cli] diff --git a/accel-pppd/accel-ppp.conf.5 b/accel-pppd/accel-ppp.conf.5 index e29d418b..8bb18862 100644 --- a/accel-pppd/accel-ppp.conf.5 +++ b/accel-pppd/accel-ppp.conf.5 @@ -875,6 +875,9 @@ Specifies quantum parameter of htb classes. .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 "fwmark=" n +Spicifies the fwmark for traffic that won't be passed through shaper. +.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 954a1169..2398bfea 100644 --- a/accel-pppd/shaper/limiter.c +++ b/accel-pppd/shaper/limiter.c @@ -246,7 +246,8 @@ static int install_police(struct rtnl_handle *rth, int ifindex, int rate, int bu req.t.tcm_ifindex = ifindex; req.t.tcm_handle = 1; req.t.tcm_parent = 0xffff0000; - req.t.tcm_info = TC_H_MAKE(1 << 16, ntohs(ETH_P_IP)); + + req.t.tcm_info = TC_H_MAKE(100 << 16, ntohs(ETH_P_IP)); addattr_l(&req.n, sizeof(req), TCA_KIND, "u32", 4); @@ -340,7 +341,9 @@ static int install_htb_ifb(struct rtnl_handle *rth, int ifindex, __u32 priority, req.t.tcm_ifindex = ifindex; req.t.tcm_handle = 1; req.t.tcm_parent = 0xffff0000; - req.t.tcm_info = TC_H_MAKE(1 << 16, ntohs(ETH_P_IP)); + + req.t.tcm_info = TC_H_MAKE(100 << 16, ntohs(ETH_P_IP)); + addattr_l(&req.n, sizeof(req), TCA_KIND, "u32", 4); @@ -390,6 +393,35 @@ static int install_htb_ifb(struct rtnl_handle *rth, int ifindex, __u32 priority, return 0; } +static int install_fwmark(struct rtnl_handle *rth, int ifindex, int parent) +{ + struct rtattr *tail; + + struct { + struct nlmsghdr n; + struct tcmsg t; + char buf[1024]; + } req; + + memset(&req, 0, sizeof(req) - 1024); + + req.n.nlmsg_len = NLMSG_LENGTH(sizeof(struct tcmsg)); + req.n.nlmsg_flags = NLM_F_REQUEST|NLM_F_EXCL|NLM_F_CREATE; + req.n.nlmsg_type = RTM_NEWTFILTER; + req.t.tcm_family = AF_UNSPEC; + req.t.tcm_ifindex = ifindex; + req.t.tcm_handle = 1; + req.t.tcm_parent = parent; + req.t.tcm_info = TC_H_MAKE(90 << 16, ntohs(ETH_P_IP)); + + addattr_l(&req.n, sizeof(req), TCA_KIND, "fw", 3); + tail = NLMSG_TAIL(&req.n); + addattr_l(&req.n, TCA_BUF_MAX, TCA_OPTIONS, NULL, 0); + addattr32(&req.n, TCA_BUF_MAX, TCA_FW_CLASSID, TC_H_MAKE(conf_fwmark << 16, 0)); + tail->rta_len = (void *)NLMSG_TAIL(&req.n) - (void *)tail; + return rtnl_talk(rth, &req.n, 0, 0, NULL, NULL, NULL, 0); +} + static int remove_root(struct rtnl_handle *rth, int ifindex) { struct qdisc_opt opt = { @@ -450,6 +482,11 @@ int install_limiter(struct ap_session *ses, int down_speed, int down_burst, int if (r == 0) r = install_leaf_qdisc(&rth, conf_ifb_ifindex, 0x00010001 + ses->unit_idx + 1, (1 + ses->unit_idx + 1) << 16); } + + if (conf_fwmark) { + install_fwmark(&rth, ses->ifindex, 0x00010000); + install_fwmark(&rth, ses->ifindex, TC_H_INGRESS); + } rtnl_close(&rth); diff --git a/accel-pppd/shaper/shaper.c b/accel-pppd/shaper/shaper.c index 14388eda..85b0edd7 100644 --- a/accel-pppd/shaper/shaper.c +++ b/accel-pppd/shaper/shaper.c @@ -43,6 +43,7 @@ int conf_r2q = 10; int conf_cburst = 1534; int conf_ifb_ifindex; static double conf_multiplier = 1; +int conf_fwmark; int conf_up_limiter = LIM_POLICE; int conf_down_limiter = LIM_TBF; @@ -972,7 +973,13 @@ static void load_config(void) conf_multiplier = atof(opt); else conf_multiplier = 1; - + + opt = conf_get_opt("shaper", "fwmark"); + if (opt) + conf_fwmark = atof(opt); + else + conf_fwmark = 0; + triton_context_call(&shaper_ctx, (triton_event_func)load_time_ranges, NULL); } @@ -981,7 +988,7 @@ static void init(void) const char *opt; tc_core_init(); - + opt = conf_get_opt("shaper", "ifb"); if (opt && init_ifb(opt)) _exit(0); diff --git a/accel-pppd/shaper/shaper.h b/accel-pppd/shaper/shaper.h index f3ba8d99..4864b86f 100644 --- a/accel-pppd/shaper/shaper.h +++ b/accel-pppd/shaper/shaper.h @@ -11,8 +11,7 @@ struct rtnl_handle; struct nlmsghdr; -struct qdisc_opt -{ +struct qdisc_opt { char *kind; int handle; int parent; @@ -37,6 +36,7 @@ extern int conf_moderate_quantum; extern int conf_r2q; extern int conf_cburst; extern int conf_ifb_ifindex; +extern int conf_fwmark; extern int conf_leaf_qdisc; extern int conf_lq_arg1; extern int conf_lq_arg2; |