[ovs-dev] [PATCH v2 4/6] netdev-linux: Cache error code from set-policy api.

Pravin B Shelar pshelar at nicira.com
Thu Mar 8 15:26:36 UTC 2012


Fixed according to comments from Ben.
v1-v2:
     - Changed name from netdev_policy_error to netdev_policing_error.

--8<--------------------------cut here-------------------------->8--

Signed-off-by: Pravin B Shelar <pshelar at nicira.com>
---
 lib/netdev-linux.c |   28 ++++++++++++++++++----------
 1 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c
index b338466..d74f350 100644
--- a/lib/netdev-linux.c
+++ b/lib/netdev-linux.c
@@ -378,6 +378,7 @@ struct netdev_dev_linux {
                                    0 or an errno value. */
     int netdev_mtu_error;       /* Cached error code from SIOCGIFMTU or SIOCSIFMTU. */
     int ether_addr_error;       /* Cached error code from set/get etheraddr. */
+    int netdev_policing_error;  /* Cached error code from set policing. */
 
     struct ethtool_drvinfo drvinfo;  /* Cached from ETHTOOL_GDRVINFO. */
     struct tc *tc;
@@ -1685,11 +1686,16 @@ netdev_linux_set_policing(struct netdev *netdev,
                    : !kbits_burst ? 1000 /* Default to 1000 kbits if 0. */
                    : kbits_burst);       /* Stick with user-specified value. */
 
-    if (netdev_dev->cache_valid & VALID_POLICING
-        && netdev_dev->kbits_rate == kbits_rate
-        && netdev_dev->kbits_burst == kbits_burst) {
-        /* Assume that settings haven't changed since we last set them. */
-        return 0;
+    if (netdev_dev->cache_valid & VALID_POLICING) {
+        if (netdev_dev->netdev_policing_error) {
+            return netdev_dev->netdev_policing_error;
+        }
+
+        if (netdev_dev->kbits_rate == kbits_rate &&
+            netdev_dev->kbits_burst == kbits_burst) {
+            /* Assume that settings haven't changed since we last set them. */
+            return 0;
+        }
     }
 
     COVERAGE_INC(netdev_set_policing);
@@ -1698,7 +1704,7 @@ netdev_linux_set_policing(struct netdev *netdev,
     if (error) {
         VLOG_WARN_RL(&rl, "%s: removing policing failed: %s",
                      netdev_name, strerror(error));
-        return error;
+        goto out;
     }
 
     if (kbits_rate) {
@@ -1706,22 +1712,24 @@ netdev_linux_set_policing(struct netdev *netdev,
         if (error) {
             VLOG_WARN_RL(&rl, "%s: adding policing qdisc failed: %s",
                          netdev_name, strerror(error));
-            return error;
+            goto out;
         }
 
         error = tc_add_policer(netdev, kbits_rate, kbits_burst);
         if (error){
             VLOG_WARN_RL(&rl, "%s: adding policing action failed: %s",
                     netdev_name, strerror(error));
-            return error;
+            goto out;
         }
     }
 
     netdev_dev->kbits_rate = kbits_rate;
     netdev_dev->kbits_burst = kbits_burst;
-    netdev_dev->cache_valid |= VALID_POLICING;
 
-    return 0;
+out:
+    netdev_dev->netdev_policing_error = error;
+    netdev_dev->cache_valid |= VALID_POLICING;
+    return error;
 }
 
 static int
-- 
1.7.1




More information about the dev mailing list