Extend bfd to save wall clock time of the last flap in bfd_forwarding__, and display it throught bfd/show. This information is also exported out to ovsdb in bfd_get_status.
Signed-off-by: Sabyasachi Sengupta <sabyasachi.sengu...@alcatel-lucent.com> ---- diff --git a/lib/bfd.c b/lib/bfd.c index 92fdbd8..c8122b0 100644 --- a/lib/bfd.c +++ b/lib/bfd.c @@ -223,6 +223,7 @@ struct bfd { long long int decay_detect_time; /* Decay detection time. */ uint64_t flap_count; /* Counts bfd forwarding flaps. */ + long long int flap_time; /* Contains timestamp of last flap */ /* True when the variables returned by bfd_get_status() are changed * since last check. */ @@ -321,6 +322,12 @@ bfd_get_status(const struct bfd *bfd, struct smap *smap) smap_add(smap, "state", bfd_state_str(bfd->state)); smap_add(smap, "diagnostic", bfd_diag_str(bfd->diag)); smap_add_format(smap, "flap_count", "%"PRIu64, bfd->flap_count); + if (bfd->flap_time) { + char *s; + s = xastrftime_msec("%Y-%m-%d %H:%M:%S.###", bfd->flap_time, false); + smap_add(smap, "flap_time", s); + free(s); + } if (bfd->state != STATE_DOWN) { smap_add(smap, "remote_state", bfd_state_str(bfd->rmt_state)); @@ -380,6 +387,7 @@ bfd_configure(struct bfd *bfd, const char *name, const struct smap *cfg, bfd->rx_packets = bfd_rx_packets(bfd); bfd->in_decay = false; bfd->flap_count = 0; + bfd->flap_time = 0; /* RFC 5881 section 4 * The source port MUST be in the range 49152 through 65535. The same @@ -937,6 +945,7 @@ bfd_forwarding__(struct bfd *bfd) OVS_REQUIRES(mutex) && bfd->rmt_diag != DIAG_RCPATH_DOWN; if (bfd->last_forwarding != last_forwarding) { bfd->flap_count++; + bfd->flap_time = time_wall_msec(); bfd_status_changed(bfd); } return bfd->last_forwarding; @@ -1269,6 +1278,12 @@ bfd_put_details(struct ds *ds, const struct bfd *bfd) OVS_REQUIRES(mutex) time_msec() - bfd->next_tx); ds_put_format(ds, "\tLast TX Time: now %+lldms\n", time_msec() - bfd->last_tx); + if (bfd->flap_time) { + char *s; + s = xastrftime_msec("%Y-%m-%d %H:%M:%S.###", bfd->flap_time, false); + ds_put_format(ds, "\tLast Flap Time: %s\n", s); + free(s); + } ds_put_cstr(ds, "\n"); ---- _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev