19 #ifndef __included_bfd_main_h__ 20 #define __included_bfd_main_h__ 29 #define foreach_bfd_mode(F) \ 35 #define F(x) BFD_MODE_##x, 58 #define foreach_bfd_poll_state(F) \ 62 F (IN_PROGRESS_AND_QUEUED) 66 #define F(x) BFD_POLL_##x, 74 #define foreach_bfd_hop(F) \ 75 F (SINGLE, "single") \ 80 #define F(sym, str) BFD_HOP_TYPE_##sym, 248 #define foreach_bfd_listen_event(F) \ 249 F (CREATE, "sesion-created") \ 250 F (UPDATE, "session-updated") \ 251 F (DELETE, "session-deleted") 255 #define F(sym, str) BFD_LISTEN_EVENT_##sym, 288 TWT (tw_timer_wheel) wheel;
328 #define foreach_bfd_error(F) \ 329 F (NONE, "good bfd packets (processed)") \ 330 F (BAD, "invalid bfd packets") \ 331 F (DISABLED, "bfd packets received on disabled interfaces") 335 #define F(sym, str) BFD_ERROR_##sym, 361 u64 expire_time_nsec;
370 uword my_thread_index = __os_thread_index;
387 uword my_thread_index = __os_thread_index;
414 const bfd_pkt_t * bfd,
u32 bs_idx);
431 u8 bfd_key_id,
u8 is_delayed);
434 u32 desired_min_tx_usec,
435 u32 required_min_rx_usec,
441 #define USEC_PER_MS (1000LL) 442 #define MSEC_PER_SEC (1000LL) 443 #define NSEC_PER_USEC (1000LL) 444 #define USEC_PER_SEC (MSEC_PER_SEC * USEC_PER_MS) 445 #define NSEC_PER_SEC (NSEC_PER_USEC * USEC_PER_SEC) 446 #define SEC_PER_NSEC ((f64)1/NSEC_PER_SEC) 449 #define BFD_TW_TPS (MSEC_PER_SEC) 452 #define BFD_DEFAULT_DESIRED_MIN_TX_USEC USEC_PER_SEC 458 #define BFD_REQUIRED_MIN_RX_USEC_WHILE_ECHO USEC_PER_SEC
u64 poll_state_start_or_timeout_nsec
helper for delayed poll sequence - marks either start of running poll sequence or timeout...
bfd_notify_fn_t * listeners
vector of callback notification functions
bfd_auth_type_e auth_type
authentication type for this key
u8 curr_bfd_key_id
current key ID sent out in bfd packet
u64 effective_required_min_rx_nsec
effective required min rx interval (nsec)
bfd_session_t * bfd_get_session(bfd_main_t *bm, bfd_transport_e t)
u64 remote_min_rx_nsec
remote min rx interval (nsec)
struct bfd_session_s bfd_session_t
u64 default_desired_min_tx_nsec
default desired min tx in nsec
u32 * auth_key_by_conf_key_id
hashmap - index in pool auth_keys by conf_key_id
u64 remote_min_echo_rx_nsec
remote min echo rx interval (nsec)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
u32 echo_secret
secret used for calculating/checking checksum of echo packets
bfd_session_t * bfd_find_session_by_idx(bfd_main_t *bm, uword bs_idx)
bfd_diag_code_e local_diag
local diagnostics
#define foreach_bfd_hop(F)
hop types
#define foreach_bfd_listen_event(F)
listener events
void bfd_register_listener(bfd_notify_fn_t fn)
Register a callback function to receive session notifications.
u8 remote_seq_number_known
set to 1 if remote sequence number is known
static void bfd_unlock(bfd_main_t *bm)
int bfd_verify_pkt_common(const bfd_pkt_t *pkt)
verify bfd packet - common checks
int bfd_verify_pkt_auth(vlib_main_t *vm, const bfd_pkt_t *pkt, u16 pkt_size, bfd_session_t *bs)
verify bfd packet - authentication
u32 bfd_process_node_index
background process node index
void bfd_put_session(bfd_main_t *bm, bfd_session_t *bs)
#define foreach_bfd_mode(F)
vlib_log_class_t log_class
log class
u8 * bfd_input_format_trace(u8 *s, va_list *args)
u64 last_rx_nsec
timestamp of last packet received
u32 tw_id
timing wheel internal id used to manipulate timer (if set)
u32 remote_seq_number
remote sequence number
unsigned bfd_auth_type_supported(bfd_auth_type_e auth_type)
u64 effective_desired_min_tx_nsec
effective desired min tx interval (nsec)
static void bfd_lock_check(bfd_main_t *bm)
int bfd_consume_echo_pkt(vlib_main_t *vm, bfd_main_t *bm, vlib_buffer_t *b)
u32 random_seed
for generating random numbers
#define foreach_bfd_error(F)
Packet counters.
u64 remote_min_rx_usec
remote min rx interval (microseconds)
UDP transport specific data embedded in bfd_session's union.
u64 bfd_process_wakeup_event_delay_nsec
The time it took the last wakeup event to make it to handling.
void bfd_consume_pkt(vlib_main_t *vm, bfd_main_t *bm, const bfd_pkt_t *bfd, u32 bs_idx)
bfd_auth_key_t * next_key
set to next key to use if delayed switch is enabled - in that case the key is switched when first inc...
void bfd_event(bfd_main_t *bm, bfd_session_t *bs)
u64 echo_last_tx_nsec
timestamp of last echo packet transmitted
void bfd_session_set_flags(vlib_main_t *vm, bfd_session_t *bs, u8 admin_up_down)
u8 remote_demand
1 if remote system sets demand mode, 0 otherwise
bfd_session_t * sessions
pool of bfd sessions context data
bfd_auth_key_t * auth_keys
pool of authentication keys
u64 remote_desired_min_tx_nsec
remote desired min tx interval (nsec)
bfd_transport_e transport
transport type for this session
u32 remote_discr
remote discriminator
bfd_poll_state_e poll_state
state info regarding poll sequence
u8 * format_bfd_session_brief(u8 *s, va_list *args)
u64 echo_transmit_interval_nsec
transmit interval for echo packets
u8 * format_bfd_session(u8 *s, va_list *args)
u8 local_detect_mult
configured detect multiplier
vnet_api_error_t bfd_auth_deactivate(bfd_session_t *bs, u8 is_delayed)
typedef CLIB_PACKED(struct { u32 discriminator;u64 expire_time_nsec;u64 checksum;}) bfd_echo_pkt_t
echo packet structure
u32 bfd_nsec_to_usec(u64 nsec)
bfd_diag_code_e remote_diag
remote diagnostics
vnet_api_error_t bfd_session_set_params(bfd_main_t *bm, bfd_session_t *bs, u32 desired_min_tx_usec, u32 required_min_rx_usec, u8 detect_mult)
#define foreach_bfd_poll_state(F)
u64 event_time_nsec
next event time in nsec for this session (0 if no event)
vnet_api_error_t bfd_auth_activate(bfd_session_t *bs, u32 conf_key_id, u8 bfd_key_id, u8 is_delayed)
BFD protocol declarations.
u32 config_desired_min_tx_usec
configured desired min tx interval (microseconds)
#define clib_warning(format, args...)
u64 config_desired_min_tx_nsec
configured desired min tx interval (nsec)
u64 echo_last_rx_nsec
timestamp of last echo packet received
struct bfd_session_s::@166 auth
authentication information
void bfd_session_start(bfd_main_t *bm, bfd_session_t *bs)
u64 nsec_per_tw_tick
how many nanoseconds is one timing wheel tick
u64 bfd_process_next_wakeup_nsec
When the bfd process is supposed to wake up next.
u8 echo
1 is echo function is active, 0 otherwise
u64 last_tx_nsec
timestamp of last packet transmitted
u64 config_required_min_rx_nsec
configured required min rx interval (nsec)
u8 * format_bfd_auth_key(u8 *s, va_list *args)
u32 local_discr
local discriminator
bfd_hop_type_e hop_type
BFD hop type.
u32 conf_key_id
global configuration key ID
vlib_main_t * vlib_main
convenience variables
bfd_state_e local_state
session state
u32 * session_by_disc
hashmap - bfd session by discriminator
void(* bfd_notify_fn_t)(bfd_listen_event_e, const bfd_session_t *)
session nitification call back function type
u32 local_seq_number
sequence number incremented occasionally or always (if meticulous)
u32 config_required_min_rx_usec
configured required min rx interval (microseconds)
BFD UDP transport layer declarations.
u64 transmit_interval_nsec
transmit interval
void bfd_init_final_control_frame(vlib_main_t *vm, vlib_buffer_t *b, bfd_main_t *bm, bfd_session_t *bs, int is_local)
u32 use_count
keeps track of how many sessions reference this key
VLIB buffer representation.
u8 next_bfd_key_id
key ID to use when switched to next_key
u64 detection_time_nsec
detection time
int bfd_process_wakeup_events_in_flight
Number of event wakeup RPCs in flight.
u64 bfd_process_wakeup_event_start_nsec
The timestamp of last wakeup event being sent.
u32 bs_idx
index in bfd_main.sessions pool
u64 remote_min_echo_rx_usec
remote min echo rx interval (microseconds)
u64 tx_timeout_nsec
next time at which to transmit a packet
bfd_state_e remote_state
remote session state
bfd_session_t * bfd_find_session_by_disc(bfd_main_t *bm, u32 disc)
const char * bfd_poll_state_string(bfd_poll_state_e state)
u64 echo_tx_timeout_nsec
next time at which to transmit echo packet
u64 min_required_min_rx_while_echo_nsec
minimum required min rx while echo function is active - nsec
bfd_auth_key_t * curr_key
current key in use
clib_spinlock_t lock
lock to protect data structures
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
u8 remote_detect_mult
remote detect multiplier
u8 is_delayed
set to 1 if delayed action is pending, which might be activation of authentication, change of key or deactivation
static void bfd_lock(bfd_main_t *bm)