[ovs-dev] [PATCH] netdev-vport: Do not update netdev when there is no config change.

Alex Wang alexw at nicira.com
Fri Mar 27 01:00:32 UTC 2015


When there is any update from ovsdb, ovs will call netdev_set_config()
for every vport.  Even though the change is not related to vport, the
current implementation will always increment the per-netdev sequence
number.  Subsequently this could cause even more unwanted effects,
e.g. the recreation of 'struct tnl_port' in ofproto level.

This commit fixes the issue by only updating the netdev when there
is actual configuration change.

Signed-off-by: Alex Wang <alexw at nicira.com>
---
 lib/netdev-vport.c |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/lib/netdev-vport.c b/lib/netdev-vport.c
index 954ab9b..28db568 100644
--- a/lib/netdev-vport.c
+++ b/lib/netdev-vport.c
@@ -612,9 +612,11 @@ set_tunnel_config(struct netdev *dev_, const struct smap *args)
                                &tnl_cfg.out_key_flow);
 
     ovs_mutex_lock(&dev->mutex);
-    dev->tnl_cfg = tnl_cfg;
-    tunnel_check_status_change__(dev);
-    netdev_change_seq_changed(dev_);
+    if (memcmp(&dev->tnl_cfg, &tnl_cfg, sizeof tnl_cfg)) {
+        dev->tnl_cfg = tnl_cfg;
+        tunnel_check_status_change__(dev);
+        netdev_change_seq_changed(dev_);
+    }
     ovs_mutex_unlock(&dev->mutex);
 
     return 0;
@@ -787,9 +789,11 @@ set_patch_config(struct netdev *dev_, const struct smap *args)
     }
 
     ovs_mutex_lock(&dev->mutex);
-    free(dev->peer);
-    dev->peer = xstrdup(peer);
-    netdev_change_seq_changed(dev_);
+    if (!dev->peer || !peer || strcmp(dev->peer, peer)) {
+        free(dev->peer);
+        dev->peer = xstrdup(peer);
+        netdev_change_seq_changed(dev_);
+    }
     ovs_mutex_unlock(&dev->mutex);
 
     return 0;
-- 
1.7.9.5




More information about the dev mailing list