From d9de144385201d66929bf10e1941e30ba43fd746 Mon Sep 17 00:00:00 2001 From: "Antoni S. Puimedon" Date: Fri, 4 Apr 2014 15:39:33 +0200 Subject: [PATCH] QoS: make tc filters match all traffic 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 Signed-off-by: Michal Privoznik --- src/util/virnetdevbandwidth.c | 7 ++++--- tests/virnetdevbandwidthtest.c | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/util/virnetdevbandwidth.c b/src/util/virnetdevbandwidth.c index b06ed4c63c..1e00116c7c 100644 --- a/src/util/virnetdevbandwidth.c +++ b/src/util/virnetdevbandwidth.c @@ -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); diff --git a/tests/virnetdevbandwidthtest.c b/tests/virnetdevbandwidthtest.c index 3f68194b57..384991e1ea 100644 --- a/tests/virnetdevbandwidthtest.c +++ b/tests/virnetdevbandwidthtest.c @@ -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(("" " " @@ -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(("" @@ -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;