bfd: Increase configuration efficiency.
authorAlex Wang <alexw@nicira.com>
Tue, 13 Aug 2013 23:51:08 +0000 (16:51 -0700)
committerBen Pfaff <blp@nicira.com>
Wed, 14 Aug 2013 22:37:19 +0000 (15:37 -0700)
Currently, when there are multiple bfd configuration changes,
the bfd_poll() will only update one change at a time with the
other side. This commit moves the call to bfd_poll() at the
end of configuration processing function, so that bfd_poll()
will update all configuration changes together.

Signed-off-by: Alex Wang <alexw@nicira.com>
Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/bfd.c

index b924e3c..74b27c4 100644 (file)
--- a/lib/bfd.c
+++ b/lib/bfd.c
@@ -261,6 +261,7 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg)
     static atomic_uint16_t udp_src = ATOMIC_VAR_INIT(0);
 
     long long int min_tx, min_rx;
+    bool need_poll = false;
     bool cpath_down;
     const char *hwaddr;
     uint8_t ea[ETH_ADDR_LEN];
@@ -315,7 +316,7 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg)
             || (!bfd_in_poll(bfd) && bfd->cfg_min_tx < bfd->min_tx)) {
             bfd->min_tx = bfd->cfg_min_tx;
         }
-        bfd_poll(bfd);
+        need_poll = true;
     }
 
     min_rx = smap_get_int(cfg, "min_rx", 1000);
@@ -326,7 +327,7 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg)
             || (!bfd_in_poll(bfd) && bfd->cfg_min_rx > bfd->min_rx)) {
             bfd->min_rx = bfd->cfg_min_rx;
         }
-        bfd_poll(bfd);
+        need_poll = true;
     }
 
     cpath_down = smap_get_bool(cfg, "cpath_down", false);
@@ -335,7 +336,7 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg)
         if (bfd->diag == DIAG_NONE || bfd->diag == DIAG_CPATH_DOWN) {
             bfd_set_state(bfd, bfd->state, DIAG_NONE);
         }
-        bfd_poll(bfd);
+        need_poll = true;
     }
 
     hwaddr = smap_get(cfg, "bfd_dst_mac");
@@ -347,6 +348,9 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg)
         bfd->eth_dst_set = false;
     }
 
+    if (need_poll) {
+        bfd_poll(bfd);
+    }
     ovs_mutex_unlock(&mutex);
     return bfd;
 }