summaryrefslogtreecommitdiffstats
path: root/src/vnet/bfd
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/bfd')
-rw-r--r--src/vnet/bfd/bfd_main.c42
-rw-r--r--src/vnet/bfd/bfd_main.h10
-rw-r--r--src/vnet/bfd/bfd_udp.c1
3 files changed, 31 insertions, 22 deletions
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index e25eadfc510..62be1842723 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -126,38 +126,36 @@ bfd_calc_next_tx (bfd_main_t * bm, bfd_session_t * bs, u64 now)
if (bs->local_detect_mult > 1)
{
/* common case - 75-100% of transmit interval */
- bs->tx_timeout_clocks = now +
+ bs->tx_timeout_clocks = bs->last_tx_clocks +
(1 - .25 * (random_f64 (&bm->random_seed))) *
bs->transmit_interval_clocks;
if (bs->tx_timeout_clocks < now)
{
- /* huh, we've missed it already, skip the missed events */
- const u64 missed =
- (now - bs->tx_timeout_clocks) / bs->transmit_interval_clocks;
- BFD_ERR ("Missed %lu transmit events (now is %lu, calc "
- "tx_timeout is %lu)!",
- missed, now, bs->tx_timeout_clocks);
- bs->tx_timeout_clocks +=
- (missed + 1) * bs->transmit_interval_clocks;
+ /* huh, we've missed it already, transmit now */
+ BFD_DBG ("Missed %lu transmit events (now is %lu, calc "
+ "tx_timeout is %lu)",
+ (now - bs->tx_timeout_clocks) /
+ bs->transmit_interval_clocks,
+ now, bs->tx_timeout_clocks);
+ bs->tx_timeout_clocks = now;
}
}
else
{
/* special case - 75-90% of transmit interval */
bs->tx_timeout_clocks =
- now +
+ bs->last_tx_clocks +
(.9 - .15 * (random_f64 (&bm->random_seed))) *
bs->transmit_interval_clocks;
if (bs->tx_timeout_clocks < now)
{
- /* huh, we've missed it already, skip the missed events */
- const u64 missed =
- (now - bs->tx_timeout_clocks) / bs->transmit_interval_clocks;
- BFD_ERR ("Missed %lu transmit events (now is %lu, calc "
- "tx_timeout is %lu)!",
- missed, now, bs->tx_timeout_clocks);
- bs->tx_timeout_clocks +=
- (missed + 1) * bs->transmit_interval_clocks;
+ /* huh, we've missed it already, transmit now */
+ BFD_DBG ("Missed %lu transmit events (now is %lu, calc "
+ "tx_timeout is %lu)",
+ (now - bs->tx_timeout_clocks) /
+ bs->transmit_interval_clocks,
+ now, bs->tx_timeout_clocks);
+ bs->tx_timeout_clocks = now;
}
}
}
@@ -485,7 +483,7 @@ bfd_init_control_frame (vlib_buffer_t * b, bfd_session_t * bs)
pkt->your_disc = bs->remote_discr;
pkt->des_min_tx = clib_host_to_net_u32 (bs->desired_min_tx_us);
pkt->req_min_rx = clib_host_to_net_u32 (bs->required_min_rx_us);
- pkt->req_min_echo_rx = clib_host_to_net_u32 (0); /* FIXME */
+ pkt->req_min_echo_rx = clib_host_to_net_u32 (bs->required_min_echo_rx_us);
b->current_length = bfd_length;
}
@@ -519,6 +517,7 @@ bfd_send_periodic (vlib_main_t * vm, vlib_node_runtime_t * rt,
}
bfd_init_control_frame (b, bs);
bfd_add_transport_layer (vm, b, bs);
+ bs->last_tx_clocks = now;
bfd_calc_next_tx (bm, bs, now);
}
else
@@ -537,6 +536,7 @@ bfd_send_final (vlib_main_t * vm, vlib_buffer_t * b, bfd_session_t * bs)
bfd_init_control_frame (b, bs);
bfd_pkt_set_final (vlib_buffer_get_current (b));
bfd_add_transport_layer (vm, b, bs);
+ bs->last_tx_clocks = clib_cpu_time_now ();
}
static void
@@ -946,6 +946,7 @@ format_bfd_session (u8 * s, va_list * args)
"bfd.LocalDiag=%s, "
"bfd.DesiredMinTxInterval=%u, "
"bfd.RequiredMinRxInterval=%u, "
+ "bfd.RequiredMinEchoRxInterval=%u, "
"bfd.RemoteMinRxInterval=%u, "
"bfd.DemandMode=%s, "
"bfd.RemoteDemandMode=%s, "
@@ -954,7 +955,8 @@ format_bfd_session (u8 * s, va_list * args)
bfd_state_string (bs->remote_state), bs->local_discr,
bs->remote_discr, bfd_diag_code_string (bs->local_diag),
bs->desired_min_tx_us, bs->required_min_rx_us,
- bs->remote_min_rx_us, (bs->local_demand ? "yes" : "no"),
+ bs->required_min_echo_rx_us, bs->remote_min_rx_us,
+ (bs->local_demand ? "yes" : "no"),
(bs->remote_demand ? "yes" : "no"), bs->local_detect_mult);
}
diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h
index c72ea92a70f..cc82c839ce9 100644
--- a/src/vnet/bfd/bfd_main.h
+++ b/src/vnet/bfd/bfd_main.h
@@ -75,16 +75,19 @@ typedef struct
/* desired min tx interval (clocks) */
u64 desired_min_tx_clocks;
- /* required min rx interval */
+ /* required min rx interval (microseconds) */
u32 required_min_rx_us;
+ /* required min echo rx interval (microseconds) */
+ u32 required_min_echo_rx_us;
+
/* remote min rx interval (microseconds) */
u32 remote_min_rx_us;
/* remote min rx interval (clocks) */
u64 remote_min_rx_clocks;
- /* remote desired min tx interval */
+ /* remote desired min tx interval (microseconds) */
u32 remote_desired_min_tx_us;
/* 1 if in demand mode, 0 otherwise */
@@ -108,6 +111,9 @@ typedef struct
/* next time at which to transmit a packet */
u64 tx_timeout_clocks;
+ /* timestamp of last packet transmitted */
+ u64 last_tx_clocks;
+
/* timestamp of last packet received */
u64 last_rx_clocks;
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index 3c747d86a10..677f1e22ef7 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -146,6 +146,7 @@ bfd_udp_add_session_internal (bfd_udp_main_t *bum, u32 sw_if_index,
}
bs->config_desired_min_tx_us = desired_min_tx_us;
bs->required_min_rx_us = required_min_rx_us;
+ bs->required_min_echo_rx_us = required_min_rx_us; /* FIXME */
bs->local_detect_mult = detect_mult;
bfd_session_start (bum->bfd_main, bs);
return 0;