Merge "netd: Switch throttling to use HTB instead of CBQ" into froyo
diff --git a/ThrottleController.cpp b/ThrottleController.cpp
index 9b2202b..846a685 100644
--- a/ThrottleController.cpp
+++ b/ThrottleController.cpp
@@ -87,7 +87,7 @@
     /*
      * 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 @@
     /*
      * 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,6 +112,24 @@
     }
 
     /*
+     * Add root qdisc for IFD
+     */
+    sprintf(cmd, "qdisc add dev ifb0 root handle 1: htb default 1 r2q 1000");
+    if (runTcCmd(cmd)) {
+        LOGE("Failed to add root ifb qdisc (%s)", strerror(errno));
+        goto fail;
+    }
+
+    /*
+     * Add our ingress throttling class
+     */
+    sprintf(cmd, "class add dev ifb0 parent 1: classid 1:1 htb rate %dkbit", rxKbps);
+    if (runTcCmd(cmd)) {
+        LOGE("Failed to add ingress throttling class (%s)", strerror(errno));
+        goto fail;
+    }
+
+    /*
      * Add ingress qdisc for pkt redirection
      */
     sprintf(cmd, "qdisc add dev %s ingress", ifn);
@@ -134,48 +141,13 @@
     /*
      * Add filter to link <ifn> -> ifb0
      */
-    sprintf(cmd, "filter add dev %s parent 1: protocol ip prio 10 u32 match "
+    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 ifb filter (%s)", strerror(errno));
         goto fail;
     }
 
-    /*
-     *
-     * IFD configuration
-     *
-     */
-
-    /*
-     * Add root qdisc for the interface
-     */
-    sprintf(cmd, "qdisc add dev ifb0 root handle 1: cbq avpkt 1000 bandwidth 10mbit");
-    if (runTcCmd(cmd)) {
-        LOGE("Failed to add root ifb qdisc (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add our ingress throttling class
-     */
-    sprintf(cmd, "class add dev ifb0 parent 1: classid 1:1 cbq rate %dkbit allot 1500 "
-            "prio 5 bounded isolated", rxKbps);
-    if (runTcCmd(cmd)) {
-        LOGE("Failed to add ingress throttling class (%s)", strerror(errno));
-        goto fail;
-    }
-
-    /*
-     * Add filter for ingress matching
-     */
-    sprintf(cmd, "filter add dev ifb0 parent 1: protocol ip prio 16 u32 match "
-            "ip dst 0.0.0.0/0 flowid 1:1");
-    if (runTcCmd(cmd)) {
-        LOGE("Failed to add ingress throttling filter (%s)", strerror(errno));
-        goto fail;
-    }
-
     return 0;
 fail:
     reset(ifn);