[ovs-dev] [PATCH ovs V2 20/21] netdev-linux: always add ingress qdisc

Paul Blakey paulb at mellanox.com
Sun Dec 25 11:39:48 UTC 2016


flow offloading by tc needs ingress qdisc on the device.
Deleting the ingress qdisc was done in order to flush
policing filters, so instead we just flush the filter and
leave the ingress added (and add it if there wasn't any).

Signed-off-by: Paul Blakey <paulb at mellanox.com>
Reviewed-by: Roi Dayan <roid at mellanox.com>
---
 lib/netdev-linux.c | 29 +++++++++++++++++++----------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 6a23a82..90b6a64 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -75,6 +75,7 @@
 #include "openvswitch/vlog.h"
 #include "util.h"
 #include "netdev-tc-offloads.h"
+#include "tc.h"
 
 VLOG_DEFINE_THIS_MODULE(netdev_linux);
 
@@ -2057,6 +2058,7 @@ netdev_linux_set_policing(struct netdev *netdev_,
     struct netdev_linux *netdev = netdev_linux_cast(netdev_);
     const char *netdev_name = netdev_get_name(netdev_);
     int error;
+    int ifindex;
 
     kbits_burst = (!kbits_rate ? 0       /* Force to 0 if no rate specified. */
                    : !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */
@@ -2074,22 +2076,29 @@ netdev_linux_set_policing(struct netdev *netdev_,
     }
 
     COVERAGE_INC(netdev_set_policing);
-    /* Remove any existing ingress qdisc. */
-    error = tc_add_del_ingress_qdisc(netdev_, false);
+    error = tc_add_del_ingress_qdisc(netdev_, true);
+    error = (error == EEXIST) ? 0 : error;
     if (error) {
-        VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
+        VLOG_WARN_RL(&rl, "%s: adding policing qdisc failed: %s",
+                netdev_name, ovs_strerror(error));
+        goto out;
+    }
+
+    /* Remove any existing policing. */
+    error = get_ifindex(&netdev->up, &ifindex);
+    if (error) {
+        VLOG_WARN_RL(&rl, "%s: getting ifindex failed: %s",
+                     netdev_name, ovs_strerror(error));
+        goto out;
+    }
+    error = tc_flush_flower(ifindex);
+    if (error) {
+        VLOG_WARN_RL(&rl, "%s: flushing policing failed: %s",
                      netdev_name, ovs_strerror(error));
         goto out;
     }
 
     if (kbits_rate) {
-        error = tc_add_del_ingress_qdisc(netdev_, true);
-        if (error) {
-            VLOG_WARN_RL(&rl, "%s: adding policing qdisc failed: %s",
-                         netdev_name, ovs_strerror(error));
-            goto out;
-        }
-
         error = tc_add_policer(netdev_, kbits_rate, kbits_burst);
         if (error){
             VLOG_WARN_RL(&rl, "%s: adding policing action failed: %s",
-- 
1.8.3.1



More information about the dev mailing list