Skip to content

Commit c7dfbe9

Browse files
bfd: store actual timeout information in bfd
The actual BFD timeout value is not stored in the BFD session. This change adds support to track and record that information. Signed-off-by: Sougata <sougatahitcs@gmail.com>
1 parent 1ab7631 commit c7dfbe9

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

bfdd/bfd.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,9 @@ struct bfd_session {
357357
struct event *echo_recvtimer_ev;
358358
struct event *recvtimer_ev;
359359
uint64_t xmt_TO;
360+
uint64_t xmt_TO_actual; /* Actual transmit timeout with jitter applied */
360361
uint64_t echo_xmt_TO;
362+
uint64_t echo_xmt_TO_actual; /* Actual echo transmit timeout with jitter applied */
361363
struct event *xmttimer_ev;
362364
struct event *echo_xmttimer_ev;
363365
uint64_t echo_detect_TO;

bfdd/bfdd_vty.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,15 +216,21 @@ static void _display_peer(struct vty *vty, struct bfd_session *bs)
216216
bs->timers.required_min_rx / 1000);
217217
vty_out(vty, "\t\t\tTransmission interval: %ums\n",
218218
bs->timers.desired_min_tx / 1000);
219+
if (bs->xmt_TO_actual > 0)
220+
vty_out(vty, "\t\t\tTransmission interval (actual with jitter): %" PRIu64 "ms\n",
221+
bs->xmt_TO_actual / 1000);
219222
if (bs->timers.required_min_echo_rx != 0)
220223
vty_out(vty, "\t\t\tEcho receive interval: %ums\n",
221224
bs->timers.required_min_echo_rx / 1000);
222225
else
223226
vty_out(vty, "\t\t\tEcho receive interval: disabled\n");
224-
if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO) || bs->bfd_mode == BFD_MODE_TYPE_SBFD_ECHO)
227+
if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_ECHO) || bs->bfd_mode == BFD_MODE_TYPE_SBFD_ECHO) {
225228
vty_out(vty, "\t\t\tEcho transmission interval: %ums\n",
226229
bs->timers.desired_min_echo_tx / 1000);
227-
else
230+
if (bs->echo_xmt_TO_actual > 0)
231+
vty_out(vty, "\t\t\tEcho transmission interval (actual with jitter): %" PRIu64 "ms\n",
232+
bs->echo_xmt_TO_actual / 1000);
233+
} else
228234
vty_out(vty, "\t\t\tEcho transmission interval: disabled\n");
229235

230236

bfdd/event.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,13 +131,18 @@ void bfd_xmttimer_update(struct bfd_session *bs, uint64_t jitter)
131131
{
132132
struct timeval tv = {.tv_sec = 0, .tv_usec = jitter};
133133

134+
/* Store the actual transmit timeout with jitter applied */
135+
bs->xmt_TO_actual = jitter;
136+
134137
/* Remove previous schedule if any. */
135138
bfd_xmttimer_delete(bs);
136139

137140
/* Don't add event if peer is deactivated. */
138141
if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN) ||
139-
bs->sock == -1)
142+
bs->sock == -1) {
143+
bs->xmt_TO_actual = 0; /* Timer not scheduled */
140144
return;
145+
}
141146

142147
tv_normalize(&tv);
143148

@@ -149,13 +154,18 @@ void bfd_echo_xmttimer_update(struct bfd_session *bs, uint64_t jitter)
149154
{
150155
struct timeval tv = {.tv_sec = 0, .tv_usec = jitter};
151156

157+
/* Store the actual echo transmit timeout with jitter applied */
158+
bs->echo_xmt_TO_actual = jitter;
159+
152160
/* Remove previous schedule if any. */
153161
bfd_echo_xmttimer_delete(bs);
154162

155163
/* Don't add event if peer is deactivated. */
156164
if (CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN) ||
157-
bs->sock == -1)
165+
bs->sock == -1) {
166+
bs->echo_xmt_TO_actual = 0; /* Timer not scheduled */
158167
return;
168+
}
159169

160170
tv_normalize(&tv);
161171

0 commit comments

Comments
 (0)