diff options
author | Klement Sekera <ksekera@cisco.com> | 2016-12-19 09:05:21 +0100 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-01-03 18:45:03 +0000 |
commit | 3e0a35613602ff7abf7348f7652b1d29b1352d1f (patch) | |
tree | c1340b25abb2e87ffe290f8e158f218570a25f3a /src | |
parent | 0c3d467df4c5651df03895d06444f6e830e9688c (diff) |
BFD: immediately honor reduced remote_min_rx interval
Change-Id: I7f09b45c926557d2ad0e2706b38fa56ff8194a3d
Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/bfd/bfd_main.c | 42 | ||||
-rw-r--r-- | src/vnet/bfd/bfd_main.h | 10 | ||||
-rw-r--r-- | src/vnet/bfd/bfd_udp.c | 1 |
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; |