diff mbox series

[ovs-dev,v2,2/2] netdev-linux: Don't remove ingress when not configured

Message ID 1554649848-34472-2-git-send-email-xiangxia.m.yue@gmail.com
State Not Applicable
Headers show
Series [ovs-dev,v2,1/2] netdev-linux: Add coverage counters for netdev_set_policing when ingress tc-offload | expand

Commit Message

Tonghao Zhang April 7, 2019, 3:10 p.m. UTC
In some case, we may not use the openvswitch tc to limit the ingress
police rate. And before we add the port to openvswitch bridge, we may
set the ingress policer, so don't remove the ingress when we not configured
it in openvswitch.

Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
---
 lib/netdev-linux.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)
diff mbox series

Patch

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index 0fce217..2c5697a 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -2448,6 +2448,7 @@  netdev_linux_set_policing(struct netdev *netdev_,
     const char *netdev_name = netdev_get_name(netdev_);
     int ifindex;
     int error;
+    bool should_cleanup_ingress = false;
 
     kbits_burst = (!kbits_rate ? 0       /* Force to 0 if no rate specified. */
                    : !kbits_burst ? 8000 /* Default to 8000 kbits if 0. */
@@ -2466,14 +2467,10 @@  netdev_linux_set_policing(struct netdev *netdev_,
             /* Assume that settings haven't changed since we last set them. */
             goto out;
         }
+        should_cleanup_ingress = true;
         netdev->cache_valid &= ~VALID_POLICING;
     }
 
-    error = get_ifindex(netdev_, &ifindex);
-    if (error) {
-        goto out;
-    }
-
     COVERAGE_INC(netdev_set_policing);
 
     /* Use matchall for policing when offloadling ovs with tc-flower. */
@@ -2486,14 +2483,20 @@  netdev_linux_set_policing(struct netdev *netdev_,
         return error;
     }
 
-    /* Remove any existing ingress qdisc. */
-    error = tc_add_del_ingress_qdisc(ifindex, false, 0);
+    error = get_ifindex(netdev_, &ifindex);
     if (error) {
-        VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
-                     netdev_name, ovs_strerror(error));
         goto out;
     }
 
+    if (should_cleanup_ingress) {
+        error = tc_add_del_ingress_qdisc(ifindex, false, 0);
+        if (error) {
+            VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
+                         netdev_name, ovs_strerror(error));
+            goto out;
+        }
+    }
+
     if (kbits_rate) {
         error = tc_add_del_ingress_qdisc(ifindex, true, 0);
         if (error) {