This commit adds a new function "bfd_wake_time()" that returns the next wakeup time associated with the "struct bfd".
Signed-off-by: Alex Wang <al...@nicira.com> --- lib/bfd.c | 23 +++++++++++++++++++++++ lib/bfd.h | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/lib/bfd.c b/lib/bfd.c index 6c9e920..72444fb 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -458,6 +458,29 @@ bfd_wait(const struct bfd *bfd) OVS_EXCLUDED(mutex) ovs_mutex_unlock(&mutex); } +/* Returns the next wake up time. */ +long long int +bfd_wake_time(const struct bfd *bfd) OVS_EXCLUDED(mutex) +{ + long long int retval; + + if (!bfd) { + return LLONG_MAX; + } + + ovs_mutex_lock(&mutex); + if (bfd->flags & FLAG_FINAL) { + retval = 0; + } else { + retval = bfd->next_tx; + if (bfd->state > STATE_DOWN) { + retval = MIN(bfd->detect_time, retval); + } + } + ovs_mutex_unlock(&mutex); + return retval; +} + void bfd_run(struct bfd *bfd) OVS_EXCLUDED(mutex) { diff --git a/lib/bfd.h b/lib/bfd.h index 0e1e33d..f49a3d6 100644 --- a/lib/bfd.h +++ b/lib/bfd.h @@ -49,5 +49,5 @@ void bfd_unref(struct bfd *); bool bfd_forwarding(const struct bfd *); void bfd_get_status(const struct bfd *, struct smap *); void bfd_set_netdev(struct bfd *, const struct netdev *); - +long long int bfd_wake_time(const struct bfd *); #endif /* bfd.h */ -- 1.7.9.5 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev