]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
QoS: make tc filters match all traffic
authorAntoni S. Puimedon <asegurap@redhat.com>
Fri, 4 Apr 2014 13:39:33 +0000 (15:39 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Mon, 7 Apr 2014 09:35:29 +0000 (11:35 +0200)
Up until now the traffic control filters for the vNIC QoS were
matching only ip traffic. For egress traffic that was unnoticed
because the unmatched traffic would just go to the default htb class
and be shaped anyway. For ingress, though, since the policing of the
rate is done by the filter itself.

The problem is solved by changing protocol to all and making anything
match the filter.

Bug-Url: https://bugzilla.redhat.com/1084444
Signed-off-by: Antoni S. Puimedon <asegurap@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
src/util/virnetdevbandwidth.c
tests/virnetdevbandwidthtest.c

index b06ed4c63c1e64736718b880b1821d745d7f31c2..1e00116c7c7376eaf94c1e9f9e4dd5c848db3abc 100644 (file)
@@ -193,7 +193,7 @@ virNetDevBandwidthSet(const char *ifname,
         virCommandFree(cmd);
         cmd = virCommandNew(TC);
         virCommandAddArgList(cmd, "filter", "add", "dev", ifname, "parent",
-                             "1:0", "protocol", "ip", "handle", "1", "fw",
+                             "1:0", "protocol", "all", "handle", "1", "fw",
                              "flowid", "1", NULL);
 
         if (virCommandRun(cmd, NULL) < 0)
@@ -221,9 +221,10 @@ virNetDevBandwidthSet(const char *ifname,
 
         virCommandFree(cmd);
         cmd = virCommandNew(TC);
+        /* Set filter to match all ingress traffic */
         virCommandAddArgList(cmd, "filter", "add", "dev", ifname, "parent",
-                             "ffff:", "protocol", "ip", "u32", "match", "ip",
-                             "src", "0.0.0.0/0", "police", "rate", average,
+                             "ffff:", "protocol", "all", "u32", "match", "u32",
+                             "0", "0", "police", "rate", average,
                              "burst", burst, "mtu", "64kb", "drop", "flowid",
                              ":1", NULL);
 
index 3f68194b57d08c1be38436e9d0ac80564cd59aa7..384991e1ead722515dbb319f64b45f64ee29bfc4 100644 (file)
@@ -139,7 +139,7 @@ mymain(void)
                  TC " qdisc add dev eth0 root handle 1: htb default 1\n"
                  TC " class add dev eth0 parent 1: classid 1:1 htb rate 1024kbps\n"
                  TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
-                 TC " filter add dev eth0 parent 1:0 protocol ip handle 1 fw flowid 1\n"));
+                 TC " filter add dev eth0 parent 1:0 protocol all handle 1 fw flowid 1\n"));
 
     DO_TEST_SET(("<bandwidth>"
                  "  <outbound average='1024'/>"
@@ -147,7 +147,7 @@ mymain(void)
                 (TC " qdisc del dev eth0 root\n"
                  TC " qdisc del dev eth0 ingress\n"
                  TC " qdisc add dev eth0 ingress\n"
-                 TC " filter add dev eth0 parent ffff: protocol ip u32 match ip src 0.0.0.0/0 "
+                 TC " filter add dev eth0 parent ffff: protocol all u32 match u32 0 0 "
                  "police rate 1024kbps burst 1024kb mtu 64kb drop flowid :1\n"));
 
     DO_TEST_SET(("<bandwidth>"
@@ -159,9 +159,9 @@ mymain(void)
                  TC " qdisc add dev eth0 root handle 1: htb default 1\n"
                  TC " class add dev eth0 parent 1: classid 1:1 htb rate 1kbps ceil 2kbps burst 4kb\n"
                  TC " qdisc add dev eth0 parent 1:1 handle 2: sfq perturb 10\n"
-                 TC " filter add dev eth0 parent 1:0 protocol ip handle 1 fw flowid 1\n"
+                 TC " filter add dev eth0 parent 1:0 protocol all handle 1 fw flowid 1\n"
                  TC " qdisc add dev eth0 ingress\n"
-                 TC " filter add dev eth0 parent ffff: protocol ip u32 match ip src 0.0.0.0/0 "
+                 TC " filter add dev eth0 parent ffff: protocol all u32 match u32 0 0 "
                  "police rate 5kbps burst 7kb mtu 64kb drop flowid :1\n"));
 
     return ret;