netdev-linux: Make htb quantum always no less than mtu.
authorAlex Wang <alexw@nicira.com>
Fri, 27 Mar 2015 18:34:53 +0000 (11:34 -0700)
committerAlex Wang <alexw@nicira.com>
Fri, 27 Mar 2015 20:53:54 +0000 (13:53 -0700)
Currently, ovs uses hardcoded rate2quantum = 10 for each htb qdisc.
When qdisc class's rate is small, the resulting quantum (calculated
by min_rate / rate2quantum) will be smaller than MTU.  This is not
recommended and tc will keep complaining the following in syslog.

localhost kernel: HTB: quantum of class 10003 is small. Consider r2q change.
localhost kernel: HTB: quantum of class 10004 is small. Consider r2q change.
localhost kernel: HTB: quantum of class 10005 is small. Consider r2q change.
localhost kernel: HTB: quantum of class 10006 is small. Consider r2q change.

To fix the issue, this commit makes ovs always use htb quantum no less
than the MTU.

Signed-off-by: Alex Wang <alexw@nicira.com>
Acked-by: Ben Pfaff <blp@nicira.com>
lib/netdev-linux.c

index e05ba60..a1664cd 100644 (file)
@@ -2814,6 +2814,7 @@ const struct netdev_class netdev_internal_class =
 /* HTB traffic control class. */
 
 #define HTB_N_QUEUES 0xf000
+#define HTB_RATE2QUANTUM 10
 
 struct htb {
     struct tc tc;
@@ -2872,7 +2873,7 @@ htb_setup_qdisc__(struct netdev *netdev)
     nl_msg_put_string(&request, TCA_KIND, "htb");
 
     memset(&opt, 0, sizeof opt);
-    opt.rate2quantum = 10;
+    opt.rate2quantum = HTB_RATE2QUANTUM;
     opt.version = 3;
     opt.defcls = 1;
 
@@ -2906,6 +2907,11 @@ htb_setup_class__(struct netdev *netdev, unsigned int handle,
     memset(&opt, 0, sizeof opt);
     tc_fill_rate(&opt.rate, class->min_rate, mtu);
     tc_fill_rate(&opt.ceil, class->max_rate, mtu);
+    /* Makes sure the quantum is at least MTU.  Setting quantum will
+     * make htb ignore the r2q for this class. */
+    if ((class->min_rate / HTB_RATE2QUANTUM) < mtu) {
+        opt.quantum = mtu;
+    }
     opt.buffer = tc_calc_buffer(opt.rate.rate, mtu, class->burst);
     opt.cbuffer = tc_calc_buffer(opt.ceil.rate, mtu, class->burst);
     opt.prio = class->priority;