From: San Mehat Date: Fri, 30 Apr 2010 13:19:07 +0000 (-0700) Subject: netd: Switch throttling to use HTB instead of CBQ X-Git-Tag: android-x86-7.1-r1~553^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=9d8d728596234e1e49cb1f8267b190bcc2d4b685;p=android-x86%2Fsystem-netd.git netd: Switch throttling to use HTB instead of CBQ Change-Id: I5247c9b5264db374442d19d903a250413057f19d Signed-off-by: San Mehat --- diff --git a/ThrottleController.cpp b/ThrottleController.cpp index 9b2202b..846a685 100644 --- a/ThrottleController.cpp +++ b/ThrottleController.cpp @@ -87,7 +87,7 @@ int ThrottleController::setInterfaceThrottle(const char *iface, int rxKbps, int /* * Add root qdisc for the interface */ - sprintf(cmd, "qdisc add dev %s root handle 1: cbq avpkt 1000 bandwidth 10mbit",ifn); + sprintf(cmd, "qdisc add dev %s root handle 1: htb default 1 r2q 1000", ifn); if (runTcCmd(cmd)) { LOGE("Failed to add root qdisc (%s)", strerror(errno)); goto fail; @@ -96,24 +96,13 @@ int ThrottleController::setInterfaceThrottle(const char *iface, int rxKbps, int /* * Add our egress throttling class */ - sprintf(cmd, "class add dev %s parent 1: classid 1:1 cbq rate %dkbit allot 1500 " - "prio 5 bounded isolated", ifn, txKbps); + sprintf(cmd, "class add dev %s parent 1: classid 1:1 htb rate %dkbit", ifn, txKbps); if (runTcCmd(cmd)) { LOGE("Failed to add egress throttling class (%s)", strerror(errno)); goto fail; } /* - * Add filter for egress matching - */ - sprintf(cmd, "filter add dev %s parent 1: protocol ip prio 16 u32 match " - "ip dst 0.0.0.0/0 flowid 1:1", ifn); - if (runTcCmd(cmd)) { - LOGE("Failed to add egress throttling filter (%s)", strerror(errno)); - goto fail; - } - - /* * Bring up the IFD device */ ifc_init(); @@ -123,56 +112,39 @@ int ThrottleController::setInterfaceThrottle(const char *iface, int rxKbps, int } /* - * Add ingress qdisc for pkt redirection - */ - sprintf(cmd, "qdisc add dev %s ingress", ifn); - if (runTcCmd(cmd)) { - LOGE("Failed to add ingress qdisc (%s)", strerror(errno)); - goto fail; - } - - /* - * Add filter to link -> ifb0 + * Add root qdisc for IFD */ - sprintf(cmd, "filter add dev %s parent 1: protocol ip prio 10 u32 match " - "u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0", ifn); + sprintf(cmd, "qdisc add dev ifb0 root handle 1: htb default 1 r2q 1000"); if (runTcCmd(cmd)) { - LOGE("Failed to add ifb filter (%s)", strerror(errno)); + LOGE("Failed to add root ifb qdisc (%s)", strerror(errno)); goto fail; } /* - * - * IFD configuration - * - */ - - /* - * Add root qdisc for the interface + * Add our ingress throttling class */ - sprintf(cmd, "qdisc add dev ifb0 root handle 1: cbq avpkt 1000 bandwidth 10mbit"); + sprintf(cmd, "class add dev ifb0 parent 1: classid 1:1 htb rate %dkbit", rxKbps); if (runTcCmd(cmd)) { - LOGE("Failed to add root ifb qdisc (%s)", strerror(errno)); + LOGE("Failed to add ingress throttling class (%s)", strerror(errno)); goto fail; } /* - * Add our ingress throttling class + * Add ingress qdisc for pkt redirection */ - sprintf(cmd, "class add dev ifb0 parent 1: classid 1:1 cbq rate %dkbit allot 1500 " - "prio 5 bounded isolated", rxKbps); + sprintf(cmd, "qdisc add dev %s ingress", ifn); if (runTcCmd(cmd)) { - LOGE("Failed to add ingress throttling class (%s)", strerror(errno)); + LOGE("Failed to add ingress qdisc (%s)", strerror(errno)); goto fail; } /* - * Add filter for ingress matching + * Add filter to link -> ifb0 */ - sprintf(cmd, "filter add dev ifb0 parent 1: protocol ip prio 16 u32 match " - "ip dst 0.0.0.0/0 flowid 1:1"); + sprintf(cmd, "filter add dev %s parent ffff: protocol ip prio 10 u32 match " + "u32 0 0 flowid 1:1 action mirred egress redirect dev ifb0", ifn); if (runTcCmd(cmd)) { - LOGE("Failed to add ingress throttling filter (%s)", strerror(errno)); + LOGE("Failed to add ifb filter (%s)", strerror(errno)); goto fail; }