aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bfd/bfd_main.h
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2017-02-16 10:53:53 +0100
committerDamjan Marion <dmarion.lists@gmail.com>2017-02-26 14:20:24 +0000
commit239790fd91b3f62e5eda1042a97f9216fe59856e (patch)
treeee72fc8e39c16f01249c72183f1a26904139fafe /src/vnet/bfd/bfd_main.h
parent263440e789d29e6e6b0038fcfd4e28e1c7160e83 (diff)
BFD: echo function
Change-Id: Ib1e301d62b687d4e42434239e7cd412065c28da0 Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/vnet/bfd/bfd_main.h')
-rw-r--r--src/vnet/bfd/bfd_main.h94
1 files changed, 66 insertions, 28 deletions
diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h
index 14a54d6f3df..d8063f9de33 100644
--- a/src/vnet/bfd/bfd_main.h
+++ b/src/vnet/bfd/bfd_main.h
@@ -24,17 +24,6 @@
#include <vnet/bfd/bfd_protocol.h>
#include <vnet/bfd/bfd_udp.h>
-#define foreach_bfd_transport(F) \
- F (UDP4, "ip4-rewrite") \
- F (UDP6, "ip6-rewrite")
-
-typedef enum
-{
-#define F(t, n) BFD_TRANSPORT_##t,
- foreach_bfd_transport (F)
-#undef F
-} bfd_transport_t;
-
#define foreach_bfd_mode(F) \
F (asynchronous) \
F (demand)
@@ -64,14 +53,15 @@ typedef struct
bfd_auth_type_e auth_type;
} bfd_auth_key_t;
-#define foreach_bfd_poll_state(F)\
- F(NOT_NEEDED)\
-F(NEEDED)\
-F(IN_PROGRESS)
+#define foreach_bfd_poll_state(F) \
+ F (NOT_NEEDED) \
+ F (NEEDED) \
+ F (IN_PROGRESS) \
+ F (IN_PROGRESS_AND_QUEUED)
typedef enum
{
-#define F(x) POLL_##x,
+#define F(x) BFD_POLL_##x,
foreach_bfd_poll_state (F)
#undef F
} bfd_poll_state_e;
@@ -120,21 +110,27 @@ typedef struct bfd_session_s
/* remote min rx interval (clocks) */
u64 remote_min_rx_clocks;
+ /* remote min echo rx interval (microseconds) */
+ u64 remote_min_echo_rx_usec;
+
+ /* remote min echo rx interval (clocks) */
+ u64 remote_min_echo_rx_clocks;
+
/* remote desired min tx interval (clocks) */
u64 remote_desired_min_tx_clocks;
/* configured detect multiplier */
u8 local_detect_mult;
- /* 1 if in demand mode, 0 otherwise */
- u8 local_demand;
-
/* 1 if remote system sets demand mode, 0 otherwise */
u8 remote_demand;
/* remote detect multiplier */
u8 remote_detect_mult;
+ /* 1 is echo function is active, 0 otherwise */
+ u8 echo;
+
/* set to value of timer in timing wheel, 0 if never set */
u64 wheel_time_clocks;
@@ -150,12 +146,33 @@ typedef struct bfd_session_s
/* timestamp of last packet received */
u64 last_rx_clocks;
+ /* transmit interval for echo packets */
+ u64 echo_transmit_interval_clocks;
+
+ /* next time at which to transmit echo packet */
+ u64 echo_tx_timeout_clocks;
+
+ /* timestamp of last echo packet transmitted */
+ u64 echo_last_tx_clocks;
+
+ /* timestamp of last echo packet received */
+ u64 echo_last_rx_clocks;
+
+ /* secret used for calculating/checking checksum of echo packets */
+ u32 echo_secret;
+
/* detection time */
u64 detection_time_clocks;
/* state info regarding poll sequence */
bfd_poll_state_e poll_state;
+ /*
+ * helper for delayed poll sequence - marks either start of running poll
+ * sequence or timeout, after which we can start the next poll sequnce
+ */
+ u64 poll_state_start_or_timeout_clocks;
+
/* authentication information */
struct
{
@@ -191,7 +208,7 @@ typedef struct bfd_session_s
} auth;
/* transport type for this session */
- bfd_transport_t transport;
+ bfd_transport_e transport;
/* union of transport-specific data */
union
@@ -227,6 +244,9 @@ typedef struct
/* default desired min tx in clocks */
u64 default_desired_min_tx_clocks;
+ /* minimum required min rx while echo function is active - clocks */
+ u64 min_required_min_rx_while_echo_clocks;
+
/* for generating random numbers */
u32 random_seed;
@@ -268,36 +288,54 @@ enum
BFD_EVENT_CONFIG_CHANGED,
} bfd_process_event_e;
-u8 *bfd_input_format_trace (u8 * s, va_list * args);
+/* echo packet structure */
+/* *INDENT-OFF* */
+typedef CLIB_PACKED (struct {
+ /* local discriminator */
+ u32 discriminator;
+ /* expire time of this packet - clocks */
+ u64 expire_time_clocks;
+ /* checksum - based on discriminator, local secret and expire time */
+ u64 checksum;
+}) bfd_echo_pkt_t;
+/* *INDENT-ON* */
-bfd_session_t *bfd_get_session (bfd_main_t * bm, bfd_transport_t t);
+u8 *bfd_input_format_trace (u8 * s, va_list * args);
+bfd_session_t *bfd_get_session (bfd_main_t * bm, bfd_transport_e t);
void bfd_put_session (bfd_main_t * bm, bfd_session_t * bs);
bfd_session_t *bfd_find_session_by_idx (bfd_main_t * bm, uword bs_idx);
bfd_session_t *bfd_find_session_by_disc (bfd_main_t * bm, u32 disc);
void bfd_session_start (bfd_main_t * bm, bfd_session_t * bs);
void bfd_consume_pkt (bfd_main_t * bm, const bfd_pkt_t * bfd, u32 bs_idx);
+int bfd_consume_echo_pkt (bfd_main_t * bm, vlib_buffer_t * b);
int bfd_verify_pkt_common (const bfd_pkt_t * pkt);
int bfd_verify_pkt_auth (const bfd_pkt_t * pkt, u16 pkt_size,
bfd_session_t * bs);
void bfd_event (bfd_main_t * bm, bfd_session_t * bs);
void bfd_init_final_control_frame (vlib_main_t * vm, vlib_buffer_t * b,
- bfd_session_t * bs);
+ bfd_main_t * bm, bfd_session_t * bs);
u8 *format_bfd_session (u8 * s, va_list * args);
void bfd_session_set_flags (bfd_session_t * bs, u8 admin_up_down);
unsigned bfd_auth_type_supported (bfd_auth_type_e auth_type);
vnet_api_error_t bfd_auth_activate (bfd_session_t * bs, u32 conf_key_id,
u8 bfd_key_id, u8 is_delayed);
vnet_api_error_t bfd_auth_deactivate (bfd_session_t * bs, u8 is_delayed);
-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);
+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 USEC_PER_MS 1000LL
#define USEC_PER_SECOND (1000 * USEC_PER_MS)
/* default, slow transmission interval for BFD packets, per spec at least 1s */
-#define BFD_DEFAULT_DESIRED_MIN_TX_US USEC_PER_SECOND
+#define BFD_DEFAULT_DESIRED_MIN_TX_USEC USEC_PER_SECOND
+
+/*
+ * minimum required min rx set locally when echo function is used, per spec
+ * should be set to at least 1s
+ */
+#define BFD_REQUIRED_MIN_RX_USEC_WHILE_ECHO USEC_PER_SECOND
#endif /* __included_bfd_main_h__ */