aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/bfd
diff options
context:
space:
mode:
authorAbdel Baig <abdbaig@cisco.com>2024-09-03 11:52:20 -0400
committerMirza Baig <abdbaig@cisco.com>2024-10-15 15:46:01 -0400
commit17a918133ba056851c848cbd95dcd241b900cd3d (patch)
tree12ca4e9ce461e8fc8a4f945ea3830629e5a93a2f /src/vnet/bfd
parent514098ee82737732c4491700254625d30b0e6bbb (diff)
bfd: add support for multihop
Type: feature Change-Id: If23f9cc9317e7528f3c8d66303457206843a12c5 Signed-off-by: Abdel Baig <abdbaig@cisco.com>
Diffstat (limited to 'src/vnet/bfd')
-rw-r--r--src/vnet/bfd/bfd.api10
-rw-r--r--src/vnet/bfd/bfd_api.c61
-rw-r--r--src/vnet/bfd/bfd_api.h63
-rw-r--r--src/vnet/bfd/bfd_cli.c150
-rw-r--r--src/vnet/bfd/bfd_main.c62
-rw-r--r--src/vnet/bfd/bfd_main.h17
-rw-r--r--src/vnet/bfd/bfd_udp.c520
-rw-r--r--src/vnet/bfd/bfd_udp.h10
8 files changed, 599 insertions, 294 deletions
diff --git a/src/vnet/bfd/bfd.api b/src/vnet/bfd/bfd.api
index d3b3ed21a26..cf14455f391 100644
--- a/src/vnet/bfd/bfd.api
+++ b/src/vnet/bfd/bfd.api
@@ -359,6 +359,16 @@ autoreply define bfd_udp_auth_deactivate
bool is_delayed;
};
+/** \brief BFD UDP - enable multihop support
+ @param client_index - opaque cookie to identify the sender
+ @param context - sender context, to match reply w/ request
+*/
+autoreply define bfd_udp_enable_multihop
+{
+ u32 client_index;
+ u32 context;
+};
+
/* must be compatible with bfd_error_t */
counters bfd_udp {
none {
diff --git a/src/vnet/bfd/bfd_api.c b/src/vnet/bfd/bfd_api.c
index 816e71081ff..bccf58ba4bb 100644
--- a/src/vnet/bfd/bfd_api.c
+++ b/src/vnet/bfd/bfd_api.c
@@ -46,8 +46,24 @@ pub_sub_handler (bfd_events, BFD_EVENTS);
ip_address_decode(&mp->local_addr, &local_addr); \
ip_address_decode(&mp->peer_addr, &peer_addr);
-#define BFD_UDP_API_PARAM_FROM_MP(mp) \
- clib_net_to_host_u32 (mp->sw_if_index), &local_addr, &peer_addr
+#define BFD_UDP_API_PARAM_IS_MH(mp) \
+ bfd_main.multihop_enabled && (mp->sw_if_index == ~0)
+
+#define BFD_UDP_API_PARAM_FROM_MP(mp) \
+ BFD_UDP_API_PARAM_IS_MH (mp) ? true : false, \
+ BFD_UDP_API_PARAM_IS_MH (mp) ? ~0 : \
+ clib_net_to_host_u32 (mp->sw_if_index), \
+ &local_addr, &peer_addr
+
+#define COND_VALIDATE_SW_IF_INDEX(mp) \
+ do \
+ { \
+ if (!(bfd_main.multihop_enabled && mp->sw_if_index == ~0)) \
+ { \
+ VALIDATE_SW_IF_INDEX (mp) \
+ } \
+ } \
+ while (0);
static void
vl_api_bfd_udp_add_t_handler (vl_api_bfd_udp_add_t * mp)
@@ -55,7 +71,7 @@ vl_api_bfd_udp_add_t_handler (vl_api_bfd_udp_add_t * mp)
vl_api_bfd_udp_add_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -76,7 +92,7 @@ vl_api_bfd_udp_upd_t_handler (vl_api_bfd_udp_add_t *mp)
vl_api_bfd_udp_upd_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -97,7 +113,7 @@ vl_api_bfd_udp_mod_t_handler (vl_api_bfd_udp_mod_t * mp)
vl_api_bfd_udp_mod_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -116,7 +132,7 @@ vl_api_bfd_udp_del_t_handler (vl_api_bfd_udp_del_t * mp)
vl_api_bfd_udp_del_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -143,7 +159,14 @@ send_bfd_udp_session_details (vl_api_registration_t * reg, u32 context,
mp->state = clib_host_to_net_u32 (bs->local_state);
bfd_udp_session_t *bus = &bs->udp;
bfd_udp_key_t *key = &bus->key;
- mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ mp->sw_if_index = ~0;
+ }
+ else
+ {
+ mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
+ }
if ((!bs->auth.is_delayed && bs->auth.curr_key) ||
(bs->auth.is_delayed && bs->auth.next_key))
{
@@ -186,7 +209,14 @@ send_bfd_udp_session_event (vl_api_registration_t *reg, u32 pid,
mp->state = clib_host_to_net_u32 (bs->local_state);
bfd_udp_session_t *bus = &bs->udp;
bfd_udp_key_t *key = &bus->key;
- mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ mp->sw_if_index = ~0;
+ }
+ else
+ {
+ mp->sw_if_index = clib_host_to_net_u32 (key->sw_if_index);
+ }
if ((!bs->auth.is_delayed && bs->auth.curr_key) ||
(bs->auth.is_delayed && bs->auth.next_key))
{
@@ -315,7 +345,7 @@ vl_api_bfd_udp_auth_activate_t_handler (vl_api_bfd_udp_auth_activate_t * mp)
vl_api_bfd_udp_auth_activate_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -334,7 +364,7 @@ vl_api_bfd_udp_auth_deactivate_t_handler (vl_api_bfd_udp_auth_deactivate_t *
vl_api_bfd_udp_auth_deactivate_reply_t *rmp;
int rv;
- VALIDATE_SW_IF_INDEX (mp);
+ COND_VALIDATE_SW_IF_INDEX (mp);
BFD_UDP_API_PARAM_COMMON_CODE;
@@ -423,6 +453,17 @@ vl_api_bfd_udp_get_echo_source_t_handler (vl_api_bfd_udp_get_echo_source_t *
}))
}
+static void
+vl_api_bfd_udp_enable_multihop_t_handler (vl_api_bfd_udp_enable_multihop_t *mp)
+{
+ vl_api_bfd_udp_enable_multihop_reply_t *rmp;
+ int rv = 0;
+
+ bfd_main.multihop_enabled = true;
+
+ REPLY_MACRO (VL_API_BFD_UDP_ENABLE_MULTIHOP_REPLY);
+}
+
#include <vnet/bfd/bfd.api.c>
static clib_error_t *
bfd_api_hookup (vlib_main_t * vm)
diff --git a/src/vnet/bfd/bfd_api.h b/src/vnet/bfd/bfd_api.h
index f051e6b679c..16501fcd272 100644
--- a/src/vnet/bfd/bfd_api.h
+++ b/src/vnet/bfd/bfd_api.h
@@ -37,44 +37,49 @@ typedef enum
/**
* @brief create a new bfd session
*/
-vnet_api_error_t
-bfd_udp_add_session (u32 sw_if_index, const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- u32 desired_min_tx_usec, u32 required_min_rx_usec,
- u8 detect_mult, u8 is_authenticated, u32 conf_key_id,
- u8 bfd_key_id);
+vnet_api_error_t bfd_udp_add_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
+ u32 desired_min_tx_usec,
+ u32 required_min_rx_usec, u8 detect_mult,
+ u8 is_authenticated, u32 conf_key_id,
+ u8 bfd_key_id);
/**
- * @brief create a new or modify and existing bfd session
+ * @brief create a new or modify an existing bfd session
*/
-vnet_api_error_t
-bfd_udp_upd_session (u32 sw_if_index, const ip46_address_t *local_addr,
- const ip46_address_t *peer_addr, u32 desired_min_tx_usec,
- u32 required_min_rx_usec, u8 detect_mult,
- u8 is_authenticated, u32 conf_key_id, u8 bfd_key_id);
+vnet_api_error_t bfd_udp_upd_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
+ u32 desired_min_tx_usec,
+ u32 required_min_rx_usec, u8 detect_mult,
+ u8 is_authenticated, u32 conf_key_id,
+ u8 bfd_key_id);
/**
* @brief modify existing session
*/
-vnet_api_error_t
-bfd_udp_mod_session (u32 sw_if_index, const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- u32 desired_min_tx_usec, u32 required_min_rx_usec,
- u8 detect_mult);
+vnet_api_error_t bfd_udp_mod_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
+ u32 desired_min_tx_usec,
+ u32 required_min_rx_usec,
+ u8 detect_mult);
/**
* @brief delete existing session
*/
-vnet_api_error_t bfd_udp_del_session (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr);
+vnet_api_error_t bfd_udp_del_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr);
/**
* @brief set session admin down/up
*/
-vnet_api_error_t bfd_udp_session_set_flags (vlib_main_t * vm, u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
+vnet_api_error_t bfd_udp_session_set_flags (vlib_main_t *vm, bool multihop,
+ u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
u8 admin_up_down);
/**
@@ -91,18 +96,18 @@ vnet_api_error_t bfd_auth_del_key (u32 conf_key_id);
/**
* @brief activate authentication for existing session
*/
-vnet_api_error_t bfd_udp_auth_activate (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
+vnet_api_error_t bfd_udp_auth_activate (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
u32 conf_key_id, u8 bfd_key_id,
u8 is_delayed);
/**
* @brief deactivate authentication for existing session
*/
-vnet_api_error_t bfd_udp_auth_deactivate (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
+vnet_api_error_t bfd_udp_auth_deactivate (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
u8 is_delayed);
/**
diff --git a/src/vnet/bfd/bfd_cli.c b/src/vnet/bfd/bfd_cli.c
index 33942bb89e6..194c62b507c 100644
--- a/src/vnet/bfd/bfd_cli.c
+++ b/src/vnet/bfd/bfd_cli.c
@@ -26,11 +26,39 @@
#include <vnet/bfd/bfd_api.h>
#include <vnet/bfd/bfd_main.h>
+#define BFD_MULTIHOP_CLI_CHECK \
+ do \
+ { \
+ multihop = have_multihop; \
+ if (multihop) \
+ { \
+ sw_if_index = ~0; \
+ } \
+ if (multihop && have_sw_if_index) \
+ { \
+ ret = clib_error_return ( \
+ 0, "Incompatible parameter combination, " \
+ "interface cannot be specified when multihop is enabled"); \
+ goto out; \
+ } \
+ if (!multihop && !have_sw_if_index) \
+ { \
+ ret = \
+ clib_error_return (0, "Incompatible parameter combination, " \
+ "interface must be set if not multihop"); \
+ goto out; \
+ } \
+ } \
+ while (0);
+
static u8 *
format_bfd_session_cli (u8 * s, va_list * args)
{
vlib_main_t *vm = va_arg (*args, vlib_main_t *);
bfd_session_t *bs = va_arg (*args, bfd_session_t *);
+ s = format (s, "%10s %-32s %20s\n", "", "Hop Type",
+ bfd_hop_type_string (bs->hop_type));
+
switch (bs->transport)
{
case BFD_TRANSPORT_UDP4:
@@ -52,6 +80,8 @@ format_bfd_session_cli (u8 * s, va_list * args)
bfd_diag_code_string (bs->remote_diag));
s = format (s, "%10s %-32s %20u %20u\n", "", "Detect multiplier",
bs->local_detect_mult, bs->remote_detect_mult);
+ s = format (s, "%10s %-32s %20llu\n", "", "Detection Time (usec)",
+ bfd_nsec_to_usec (bs->detection_time_nsec));
s = format (s, "%10s %-32s %20u %20llu\n", "",
"Required Min Rx Interval (usec)",
bs->config_required_min_rx_usec, bs->remote_min_rx_usec);
@@ -363,6 +393,7 @@ VLIB_CLI_COMMAND (bfd_cli_key_del_command, static) = {
#define DETECT_MULT_STR "detect-mult"
#define ADMIN_STR "admin"
#define DELAYED_STR "delayed"
+#define MULTIHOP_STR "multihop"
static const unsigned mandatory = 1;
static const unsigned optional = 0;
@@ -401,7 +432,8 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_add_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -433,6 +465,7 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input,
}
foreach_bfd_cli_udp_session_add_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
if (1 == have_conf_key_id + have_bfd_key_id)
{
@@ -456,11 +489,9 @@ bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input,
goto out;
}
- vnet_api_error_t rv =
- bfd_udp_add_session (sw_if_index, &local_addr, &peer_addr, desired_min_tx,
- required_min_rx,
- detect_mult, have_conf_key_id, conf_key_id,
- bfd_key_id);
+ vnet_api_error_t rv = bfd_udp_add_session (
+ multihop, sw_if_index, &local_addr, &peer_addr, desired_min_tx,
+ required_min_rx, detect_mult, have_conf_key_id, conf_key_id, bfd_key_id);
if (rv)
{
ret =
@@ -477,16 +508,16 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_add_command, static) = {
.path = "bfd udp session add",
.short_help = "bfd udp session add"
- " interface <interface>"
- " local-addr <local-address>"
- " peer-addr <peer-address>"
- " desired-min-tx <desired min tx interval>"
- " required-min-rx <required min rx interval>"
- " detect-mult <detect multiplier> "
- "["
- " conf-key-id <config key ID>"
- " bfd-key-id <BFD key ID>"
- "]",
+ " <multihop | interface <interface>>"
+ " local-addr <local-address>"
+ " peer-addr <peer-address>"
+ " desired-min-tx <desired min tx interval>"
+ " required-min-rx <required min rx interval>"
+ " detect-mult <detect multiplier> "
+ "["
+ " conf-key-id <config key ID>"
+ " bfd-key-id <BFD key ID>"
+ "]",
.function = bfd_cli_udp_session_add,
};
@@ -497,7 +528,8 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_mod_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -527,6 +559,7 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input,
}
foreach_bfd_cli_udp_session_mod_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
if (detect_mult > 255)
{
@@ -536,7 +569,7 @@ bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input,
}
vnet_api_error_t rv =
- bfd_udp_mod_session (sw_if_index, &local_addr, &peer_addr,
+ bfd_udp_mod_session (multihop, sw_if_index, &local_addr, &peer_addr,
desired_min_tx, required_min_rx, detect_mult);
if (rv)
{
@@ -553,13 +586,13 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_mod_command, static) = {
.path = "bfd udp session mod",
- .short_help = "bfd udp session mod interface"
- " <interface> local-addr"
- " <local-address> peer-addr"
- " <peer-address> desired-min-tx"
- " <desired min tx interval> required-min-rx"
- " <required min rx interval> detect-mult"
- " <detect multiplier> ",
+ .short_help = "bfd udp session mod "
+ " <multihop | interface <interface>>"
+ " <local-address> peer-addr"
+ " <peer-address> desired-min-tx"
+ " <desired min tx interval> required-min-rx"
+ " <required min rx interval> detect-mult"
+ " <detect multiplier> ",
.function = bfd_cli_udp_session_mod,
};
@@ -570,7 +603,8 @@ bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_del_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -597,9 +631,10 @@ bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input,
}
foreach_bfd_cli_udp_session_del_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
vnet_api_error_t rv =
- bfd_udp_del_session (sw_if_index, &local_addr, &peer_addr);
+ bfd_udp_del_session (multihop, sw_if_index, &local_addr, &peer_addr);
if (rv)
{
ret =
@@ -615,10 +650,10 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_del_command, static) = {
.path = "bfd udp session del",
- .short_help = "bfd udp session del interface"
- " <interface> local-addr"
- " <local-address> peer-addr"
- "<peer-address> ",
+ .short_help = "bfd udp session del <multihop |"
+ " interface <interface>> local-addr"
+ " <local-address> peer-addr"
+ "<peer-address> ",
.function = bfd_cli_udp_session_del,
};
@@ -629,7 +664,8 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_set_flags_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -658,6 +694,7 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input,
}
foreach_bfd_cli_udp_session_set_flags_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
u8 admin_up_down;
static const char up[] = "up";
@@ -677,9 +714,8 @@ bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input,
ADMIN_STR, admin_up_down_token);
goto out;
}
- vnet_api_error_t rv =
- bfd_udp_session_set_flags (vm, sw_if_index, &local_addr,
- &peer_addr, admin_up_down);
+ vnet_api_error_t rv = bfd_udp_session_set_flags (
+ vm, multihop, sw_if_index, &local_addr, &peer_addr, admin_up_down);
if (rv)
{
ret =
@@ -696,10 +732,10 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_set_flags_command, static) = {
.path = "bfd udp session set-flags",
.short_help = "bfd udp session set-flags"
- " interface <interface>"
- " local-addr <local-address>"
- " peer-addr <peer-address>"
- " admin <up|down>",
+ " <multihop | interface <interface>>"
+ " local-addr <local-address>"
+ " peer-addr <peer-address>"
+ " admin <up|down>",
.function = bfd_cli_udp_session_set_flags,
};
@@ -711,7 +747,8 @@ bfd_cli_udp_session_auth_activate (vlib_main_t * vm,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_auth_activate_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -741,6 +778,7 @@ bfd_cli_udp_session_auth_activate (vlib_main_t * vm,
}
foreach_bfd_cli_udp_session_auth_activate_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
u8 is_delayed = 0;
if (have_delayed_token)
@@ -773,8 +811,8 @@ bfd_cli_udp_session_auth_activate (vlib_main_t * vm,
}
vnet_api_error_t rv =
- bfd_udp_auth_activate (sw_if_index, &local_addr, &peer_addr, conf_key_id,
- bfd_key_id, is_delayed);
+ bfd_udp_auth_activate (multihop, sw_if_index, &local_addr, &peer_addr,
+ conf_key_id, bfd_key_id, is_delayed);
if (rv)
{
ret =
@@ -791,12 +829,12 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_activate_command, static) = {
.path = "bfd udp session auth activate",
.short_help = "bfd udp session auth activate"
- " interface <interface>"
- " local-addr <local-address>"
- " peer-addr <peer-address>"
- " conf-key-id <config key ID>"
- " bfd-key-id <BFD key ID>"
- " [ delayed <yes|no> ]",
+ " <multihop | interface <interface>>"
+ " local-addr <local-address>"
+ " peer-addr <peer-address>"
+ " conf-key-id <config key ID>"
+ " bfd-key-id <BFD key ID>"
+ " [ delayed <yes|no> ]",
.function = bfd_cli_udp_session_auth_activate,
};
@@ -807,7 +845,8 @@ bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input,
clib_error_t *ret = NULL;
unformat_input_t _line_input, *line_input = &_line_input;
#define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F) \
- F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
+ F (bool, multihop, MULTIHOP_STR, optional, "%_") \
+ F (u32, sw_if_index, INTERFACE_STR, optional, "%U", \
unformat_vnet_sw_interface, &vnet_main) \
F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
bfd_cli_unformat_ip46_address) \
@@ -835,6 +874,7 @@ bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input,
}
foreach_bfd_cli_udp_session_auth_deactivate_cli_param (CHECK_MANDATORY);
+ BFD_MULTIHOP_CLI_CHECK
u8 is_delayed = 0;
if (have_delayed_token)
@@ -858,8 +898,8 @@ bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input,
}
}
- vnet_api_error_t rv = bfd_udp_auth_deactivate (sw_if_index, &local_addr,
- &peer_addr, is_delayed);
+ vnet_api_error_t rv = bfd_udp_auth_deactivate (
+ multihop, sw_if_index, &local_addr, &peer_addr, is_delayed);
if (rv)
{
ret = clib_error_return (
@@ -875,10 +915,10 @@ out:
VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_deactivate_command, static) = {
.path = "bfd udp session auth deactivate",
.short_help = "bfd udp session auth deactivate"
- " interface <interface>"
- " local-addr <local-address>"
- " peer-addr <peer-address>"
- "[ delayed <yes|no> ]",
+ " <multihop | interface <interface>>"
+ " local-addr <local-address>"
+ " peer-addr <peer-address>"
+ "[ delayed <yes|no> ]",
.function = bfd_cli_udp_session_auth_deactivate,
};
diff --git a/src/vnet/bfd/bfd_main.c b/src/vnet/bfd/bfd_main.c
index 1423da91158..4ad0a16830f 100644
--- a/src/vnet/bfd/bfd_main.c
+++ b/src/vnet/bfd/bfd_main.c
@@ -30,6 +30,20 @@
#include <vlib/log.h>
#include <vnet/crypto/crypto.h>
+const char *
+bfd_hop_type_string (bfd_hop_type_e hoptype)
+{
+ switch (hoptype)
+ {
+#define F(x) \
+ case BFD_HOP_TYPE_##x: \
+ return "BFD_HOP_TYPE_" #x;
+ foreach_bfd_hop (F)
+#undef F
+ }
+ return "UNKNOWN";
+}
+
static void
bfd_validate_counters (bfd_main_t *bm)
{
@@ -1353,6 +1367,8 @@ VLIB_REGISTER_NODE (bfd_process_node, static) =
[BFD_TX_IP6_REWRITE] = "ip6-rewrite",
[BFD_TX_IP4_MIDCHAIN] = "ip4-midchain",
[BFD_TX_IP6_MIDCHAIN] = "ip6-midchain",
+ [BFD_TX_IP4_LOOKUP] = "ip4-lookup",
+ [BFD_TX_IP6_LOOKUP] = "ip6-lookup",
}
};
// clang-format on
@@ -2049,29 +2065,29 @@ u8 *
format_bfd_session (u8 * s, va_list * args)
{
const bfd_session_t *bs = va_arg (*args, bfd_session_t *);
- s = format (s, "bs_idx=%u local-state=%s remote-state=%s\n"
- "local-discriminator=%u remote-discriminator=%u\n"
- "local-diag=%s echo-active=%s\n"
- "desired-min-tx=%u required-min-rx=%u\n"
- "required-min-echo-rx=%u detect-mult=%u\n"
- "remote-min-rx=%u remote-min-echo-rx=%u\n"
- "remote-demand=%s poll-state=%s\n"
- "auth: local-seq-num=%u remote-seq-num=%u\n"
- " is-delayed=%s\n"
- " curr-key=%U\n"
- " next-key=%U",
- bs->bs_idx, bfd_state_string (bs->local_state),
- bfd_state_string (bs->remote_state), bs->local_discr,
- bs->remote_discr, bfd_diag_code_string (bs->local_diag),
- (bs->echo ? "yes" : "no"), bs->config_desired_min_tx_usec,
- bs->config_required_min_rx_usec, 1, bs->local_detect_mult,
- bs->remote_min_rx_usec, bs->remote_min_echo_rx_usec,
- (bs->remote_demand ? "yes" : "no"),
- bfd_poll_state_string (bs->poll_state),
- bs->auth.local_seq_number, bs->auth.remote_seq_number,
- (bs->auth.is_delayed ? "yes" : "no"),
- format_bfd_auth_key, bs->auth.curr_key, format_bfd_auth_key,
- bs->auth.next_key);
+ s = format (
+ s,
+ "bs_idx=%u hop-type=%s local-state=%s remote-state=%s\n"
+ "local-discriminator=%u remote-discriminator=%u\n"
+ "local-diag=%s echo-active=%s\n"
+ "desired-min-tx=%u required-min-rx=%u\n"
+ "required-min-echo-rx=%u detect-mult=%u\n"
+ "remote-min-rx=%u remote-min-echo-rx=%u\n"
+ "remote-demand=%s poll-state=%s\n"
+ "auth: local-seq-num=%u remote-seq-num=%u\n"
+ " is-delayed=%s\n"
+ " curr-key=%U\n"
+ " next-key=%U",
+ bs->bs_idx, bfd_hop_type_string (bs->hop_type),
+ bfd_state_string (bs->local_state), bfd_state_string (bs->remote_state),
+ bs->local_discr, bs->remote_discr, bfd_diag_code_string (bs->local_diag),
+ (bs->echo ? "yes" : "no"), bs->config_desired_min_tx_usec,
+ bs->config_required_min_rx_usec, 1, bs->local_detect_mult,
+ bs->remote_min_rx_usec, bs->remote_min_echo_rx_usec,
+ (bs->remote_demand ? "yes" : "no"), bfd_poll_state_string (bs->poll_state),
+ bs->auth.local_seq_number, bs->auth.remote_seq_number,
+ (bs->auth.is_delayed ? "yes" : "no"), format_bfd_auth_key,
+ bs->auth.curr_key, format_bfd_auth_key, bs->auth.next_key);
return s;
}
diff --git a/src/vnet/bfd/bfd_main.h b/src/vnet/bfd/bfd_main.h
index 1d4617e1d7c..7d9253983ce 100644
--- a/src/vnet/bfd/bfd_main.h
+++ b/src/vnet/bfd/bfd_main.h
@@ -71,13 +71,13 @@ typedef enum
/**
* hop types
*/
-#define foreach_bfd_hop(F) \
- F (SINGLE, "single") \
- F (MULTI, "multi") \
+#define foreach_bfd_hop(F) \
+ F (SINGLE) \
+ F (MULTI)
typedef enum
{
-#define F(sym, str) BFD_HOP_TYPE_##sym,
+#define F(sym) BFD_HOP_TYPE_##sym,
foreach_bfd_hop (F)
#undef F
} bfd_hop_type_e;
@@ -318,6 +318,12 @@ typedef struct
/** vector of callback notification functions */
bfd_notify_fn_t *listeners;
+ /**
+ * true if multihop support is enabled so sw_if_index of ~0
+ * represents a multihop session
+ */
+ bool multihop_enabled;
+
/** log class */
vlib_log_class_t log_class;
@@ -449,6 +455,7 @@ vnet_api_error_t bfd_session_set_params (bfd_main_t * bm, bfd_session_t * bs,
u32 bfd_nsec_to_usec (u64 nsec);
const char *bfd_poll_state_string (bfd_poll_state_e state);
+const char *bfd_hop_type_string (bfd_hop_type_e state);
#define USEC_PER_MS (1000LL)
#define MSEC_PER_SEC (1000LL)
@@ -482,6 +489,8 @@ typedef enum
BFD_TX_IP6_REWRITE,
BFD_TX_IP4_MIDCHAIN,
BFD_TX_IP6_MIDCHAIN,
+ BFD_TX_IP4_LOOKUP,
+ BFD_TX_IP6_LOOKUP,
BFD_TX_N_NEXT,
} bfd_tx_next_t;
diff --git a/src/vnet/bfd/bfd_udp.c b/src/vnet/bfd/bfd_udp.c
index ec42cda1bc4..6d3202cc55c 100644
--- a/src/vnet/bfd/bfd_udp.c
+++ b/src/vnet/bfd/bfd_udp.c
@@ -64,12 +64,18 @@ typedef struct
u32 echo_source_sw_if_index;
/* log class */
vlib_log_class_t log_class;
- /* number of active udp4 sessions */
- u32 udp4_sessions_count;
- u32 udp4_sessions_count_stat_seg_entry;
- /* number of active udp6 sessions */
- u32 udp6_sessions_count;
- u32 udp6_sessions_count_stat_seg_entry;
+ /* number of active udp4 single-hop sessions */
+ u32 udp4_sh_sessions_count;
+ u32 udp4_sh_sessions_count_stat_seg_entry;
+ /* number of active udp6 single-hop sessions */
+ u32 udp6_sh_sessions_count;
+ u32 udp6_sh_sessions_count_stat_seg_entry;
+ /* number of active udp4 multi-hop sessions */
+ u32 udp4_mh_sessions_count;
+ u32 udp4_mh_sessions_count_stat_seg_entry;
+ /* number of active udp6 multi-hop sessions */
+ u32 udp6_mh_sessions_count;
+ u32 udp6_mh_sessions_count_stat_seg_entry;
} bfd_udp_main_t;
static vlib_node_registration_t bfd_udp4_input_node;
@@ -258,8 +264,11 @@ bfd_add_udp4_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
- vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
- vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
+ if (bs->hop_type == BFD_HOP_TYPE_SINGLE)
+ {
+ vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
+ vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
+ }
vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
vnet_buffer (b)->sw_if_index[VLIB_TX] = ~0;
typedef struct
@@ -290,7 +299,14 @@ bfd_add_udp4_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
{
headers->ip4.src_address.as_u32 = key->local_addr.ip4.as_u32;
headers->ip4.dst_address.as_u32 = key->peer_addr.ip4.as_u32;
- headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4);
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4_mh);
+ }
+ else
+ {
+ headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd4);
+ }
}
/* fix ip length, checksum and udp length */
@@ -313,8 +329,11 @@ bfd_add_udp6_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
vlib_buffer_t *b = vlib_get_buffer (vm, bi);
b->flags |= VNET_BUFFER_F_LOCALLY_ORIGINATED;
- vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
- vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
+ if (bs->hop_type == BFD_HOP_TYPE_SINGLE)
+ {
+ vnet_buffer (b)->ip.adj_index[VLIB_RX] = bus->adj_index;
+ vnet_buffer (b)->ip.adj_index[VLIB_TX] = bus->adj_index;
+ }
vnet_buffer (b)->sw_if_index[VLIB_RX] = 0;
vnet_buffer (b)->sw_if_index[VLIB_TX] = 0;
typedef struct
@@ -350,7 +369,14 @@ bfd_add_udp6_transport (vlib_main_t * vm, u32 bi, const bfd_session_t * bs,
sizeof (headers->ip6.src_address));
clib_memcpy_fast (&headers->ip6.dst_address, &key->peer_addr.ip6,
sizeof (headers->ip6.dst_address));
- headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd6);
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd6_mh);
+ }
+ else
+ {
+ headers->udp.dst_port = clib_host_to_net_u16 (UDP_DST_PORT_bfd6);
+ }
}
/* fix ip payload length and udp length */
@@ -398,9 +424,25 @@ bfd_udp_calc_next_node (const struct bfd_session_s *bs, u32 * next_node)
{
vnet_main_t *vnm = vnet_get_main ();
const bfd_udp_session_t *bus = &bs->udp;
- ip_adjacency_t *adj = adj_get (bus->adj_index);
- /* don't try to send the buffer if the interface is not up */
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ switch (bs->transport)
+ {
+ case BFD_TRANSPORT_UDP4:
+ *next_node = BFD_TX_IP4_LOOKUP;
+ return 1;
+ case BFD_TRANSPORT_UDP6:
+ *next_node = BFD_TX_IP6_LOOKUP;
+ return 1;
+ default:
+ /* drop */
+ return 0;
+ }
+ }
+
+ ip_adjacency_t *adj = adj_get (bus->adj_index);
+ /* For single-hop, don't try to send the buffer if the interface is not up */
if (!vnet_sw_interface_is_up (vnm, bus->key.sw_if_index))
return 0;
@@ -495,7 +537,7 @@ bfd_udp_key_init (bfd_udp_key_t * key, u32 sw_if_index,
const ip46_address_t * peer_addr)
{
clib_memset (key, 0, sizeof (*key));
- key->sw_if_index = sw_if_index;
+ key->sw_if_index = sw_if_index & 0xFFFF;
key->local_addr.as_u64[0] = local_addr->as_u64[0];
key->local_addr.as_u64[1] = local_addr->as_u64[1];
key->peer_addr.as_u64[0] = peer_addr->as_u64[0];
@@ -503,12 +545,13 @@ bfd_udp_key_init (bfd_udp_key_t * key, u32 sw_if_index,
}
static vnet_api_error_t
-bfd_udp_add_session_internal (vlib_main_t * vm, bfd_udp_main_t * bum,
- u32 sw_if_index, u32 desired_min_tx_usec,
+bfd_udp_add_session_internal (vlib_main_t *vm, bfd_udp_main_t *bum,
+ bool multihop, u32 sw_if_index,
+ u32 desired_min_tx_usec,
u32 required_min_rx_usec, u8 detect_mult,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- bfd_session_t ** bs_out)
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
+ bfd_session_t **bs_out)
{
/* get a pool entry and if we end up not needing it, give it back */
bfd_transport_e t = BFD_TRANSPORT_UDP4;
@@ -536,8 +579,9 @@ bfd_udp_add_session_internal (vlib_main_t * vm, bfd_udp_main_t * bum,
return VNET_API_ERROR_BFD_EEXIST;
}
mhash_set (&bum->bfd_session_idx_by_bfd_key, key, bs->bs_idx, NULL);
- BFD_DBG ("session created, bs_idx=%u, sw_if_index=%d, local=%U, peer=%U",
- bs->bs_idx, key->sw_if_index, format_ip46_address,
+ BFD_DBG ("session created, bs_idx=%u, multihop=%u, sw_if_index=%d, "
+ "local=%U, peer=%U",
+ bs->bs_idx, multihop, key->sw_if_index, format_ip46_address,
&key->local_addr, IP46_TYPE_ANY, format_ip46_address,
&key->peer_addr, IP46_TYPE_ANY);
vlib_log_info (bum->log_class, "create BFD session: %U",
@@ -548,41 +592,82 @@ bfd_udp_add_session_internal (vlib_main_t * vm, bfd_udp_main_t * bum,
&key->peer_addr);
if (BFD_TRANSPORT_UDP4 == t)
{
- bus->adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP4, VNET_LINK_IP4,
- peer, key->sw_if_index);
- BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP4, VNET_LINK_IP4, %U, %d) "
- "returns %d",
- format_ip46_address, peer, IP46_TYPE_ANY, key->sw_if_index,
- bus->adj_index);
- ++bum->udp4_sessions_count;
- bfd_udp_update_stat_segment_entry (
- bum->udp4_sessions_count_stat_seg_entry, bum->udp4_sessions_count);
- if (1 == bum->udp4_sessions_count)
+ if (multihop)
{
- udp_register_dst_port (vm, UDP_DST_PORT_bfd4,
- bfd_udp4_input_node.index, 1);
- udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo4,
- bfd_udp_echo4_input_node.index, 1);
+ ++bum->udp4_mh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp4_mh_sessions_count_stat_seg_entry,
+ bum->udp4_mh_sessions_count);
+ if (1 == bum->udp4_mh_sessions_count)
+ {
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd4_mh,
+ bfd_udp4_input_node.index, 1);
+ }
+ }
+ else
+ {
+ bus->adj_index = adj_nbr_add_or_lock (
+ FIB_PROTOCOL_IP4, VNET_LINK_IP4, peer, key->sw_if_index);
+ BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP4, VNET_LINK_IP4, "
+ " %U, %d) returns %d",
+ format_ip46_address, peer, IP46_TYPE_ANY, key->sw_if_index,
+ bus->adj_index);
+ ++bum->udp4_sh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp4_sh_sessions_count_stat_seg_entry,
+ bum->udp4_sh_sessions_count);
+ if (1 == bum->udp4_sh_sessions_count)
+ {
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd4,
+ bfd_udp4_input_node.index, 1);
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo4,
+ bfd_udp_echo4_input_node.index, 1);
+ }
}
}
else
{
- bus->adj_index = adj_nbr_add_or_lock (FIB_PROTOCOL_IP6, VNET_LINK_IP6,
- peer, key->sw_if_index);
- BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP6, VNET_LINK_IP6, %U, %d) "
- "returns %d",
- format_ip46_address, peer, IP46_TYPE_ANY, key->sw_if_index,
- bus->adj_index);
- ++bum->udp6_sessions_count;
- bfd_udp_update_stat_segment_entry (
- bum->udp6_sessions_count_stat_seg_entry, bum->udp6_sessions_count);
- if (1 == bum->udp6_sessions_count)
+ if (multihop)
{
- udp_register_dst_port (vm, UDP_DST_PORT_bfd6,
- bfd_udp6_input_node.index, 0);
- udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo6,
- bfd_udp_echo6_input_node.index, 0);
+ ++bum->udp6_mh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp6_mh_sessions_count_stat_seg_entry,
+ bum->udp6_mh_sessions_count);
+ if (1 == bum->udp6_mh_sessions_count)
+ {
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd6_mh,
+ bfd_udp6_input_node.index, 0);
+ }
}
+ else
+ {
+ bus->adj_index = adj_nbr_add_or_lock (
+ FIB_PROTOCOL_IP6, VNET_LINK_IP6, peer, key->sw_if_index);
+ BFD_DBG ("adj_nbr_add_or_lock(FIB_PROTOCOL_IP6, VNET_LINK_IP6, "
+ "%U, %d) returns %d",
+ format_ip46_address, peer, IP46_TYPE_ANY, key->sw_if_index,
+ bus->adj_index);
+ ++bum->udp6_sh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp6_sh_sessions_count_stat_seg_entry,
+ bum->udp6_sh_sessions_count);
+ if (1 == bum->udp6_sh_sessions_count)
+ {
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd6,
+ bfd_udp6_input_node.index, 0);
+ udp_register_dst_port (vm, UDP_DST_PORT_bfd_echo6,
+ bfd_udp_echo6_input_node.index, 0);
+ }
+ }
+ }
+
+ if (multihop)
+ {
+ bs->hop_type = BFD_HOP_TYPE_MULTI;
+ }
+ else
+ {
+ bs->hop_type = BFD_HOP_TYPE_SINGLE;
}
*bs_out = bs;
return bfd_session_set_params (bum->bfd_main, bs, desired_min_tx_usec,
@@ -590,20 +675,24 @@ bfd_udp_add_session_internal (vlib_main_t * vm, bfd_udp_main_t * bum,
}
static vnet_api_error_t
-bfd_udp_validate_api_input (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr)
+bfd_udp_validate_api_input (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr)
{
bfd_udp_main_t *bum = &bfd_udp_main;
- vnet_sw_interface_t *sw_if =
- vnet_get_sw_interface_or_null (bfd_udp_main.vnet_main, sw_if_index);
- if (!sw_if)
+ if (!multihop)
{
- vlib_log_err (bum->log_class,
- "got NULL sw_if when getting interface by index %u",
- sw_if_index);
- return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ vnet_sw_interface_t *sw_if =
+ vnet_get_sw_interface_or_null (bfd_udp_main.vnet_main, sw_if_index);
+ if (!sw_if)
+ {
+ vlib_log_err (bum->log_class,
+ "got NULL sw_if when getting interface by index %u",
+ sw_if_index);
+ return VNET_API_ERROR_INVALID_SW_IF_INDEX;
+ }
}
+
if (ip46_address_is_ip4 (local_addr))
{
if (!ip46_address_is_ip4 (peer_addr))
@@ -627,13 +716,13 @@ bfd_udp_validate_api_input (u32 sw_if_index,
}
static vnet_api_error_t
-bfd_udp_find_session_by_api_input (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- bfd_session_t ** bs_out)
+bfd_udp_find_session_by_api_input (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr,
+ bfd_session_t **bs_out)
{
vnet_api_error_t rv =
- bfd_udp_validate_api_input (sw_if_index, local_addr, peer_addr);
+ bfd_udp_validate_api_input (multihop, sw_if_index, local_addr, peer_addr);
if (!rv)
{
bfd_udp_main_t *bum = &bfd_udp_main;
@@ -647,8 +736,9 @@ bfd_udp_find_session_by_api_input (u32 sw_if_index,
else
{
vlib_log_err (bum->log_class,
- "BFD session not found, sw_if_index=%u, local=%U, peer=%U",
- sw_if_index, format_ip46_address, local_addr,
+ "BFD session not found, multihop=%d, sw_if_index=%u, "
+ "local=%U, peer=%U",
+ multihop, sw_if_index, format_ip46_address, local_addr,
IP46_TYPE_ANY, format_ip46_address, peer_addr,
IP46_TYPE_ANY);
return VNET_API_ERROR_BFD_ENOENT;
@@ -658,13 +748,13 @@ bfd_udp_find_session_by_api_input (u32 sw_if_index,
}
static vnet_api_error_t
-bfd_api_verify_common (u32 sw_if_index, u32 desired_min_tx_usec,
+bfd_api_verify_common (bool multihop, u32 sw_if_index, u32 desired_min_tx_usec,
u8 detect_mult, const ip46_address_t *local_addr,
const ip46_address_t *peer_addr)
{
bfd_udp_main_t *bum = &bfd_udp_main;
vnet_api_error_t rv =
- bfd_udp_validate_api_input (sw_if_index, local_addr, peer_addr);
+ bfd_udp_validate_api_input (multihop, sw_if_index, local_addr, peer_addr);
if (rv)
{
return rv;
@@ -693,31 +783,62 @@ bfd_udp_del_session_internal (vlib_main_t * vm, bfd_session_t * bs)
switch (bs->transport)
{
case BFD_TRANSPORT_UDP4:
- --bum->udp4_sessions_count;
- bfd_udp_update_stat_segment_entry (
- bum->udp4_sessions_count_stat_seg_entry, bum->udp4_sessions_count);
- if (!bum->udp4_sessions_count)
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
{
- udp_unregister_dst_port (vm, UDP_DST_PORT_bfd4, 1);
- udp_unregister_dst_port (vm, UDP_DST_PORT_bfd_echo4, 1);
+ --bum->udp4_mh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp4_mh_sessions_count_stat_seg_entry,
+ bum->udp4_mh_sessions_count);
+ if (!bum->udp4_mh_sessions_count)
+ {
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd4_mh, 1);
+ }
+ }
+ else
+ {
+ --bum->udp4_sh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp4_sh_sessions_count_stat_seg_entry,
+ bum->udp4_sh_sessions_count);
+ if (!bum->udp4_sh_sessions_count)
+ {
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd4, 1);
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd_echo4, 1);
+ }
}
break;
case BFD_TRANSPORT_UDP6:
- --bum->udp6_sessions_count;
- bfd_udp_update_stat_segment_entry (
- bum->udp6_sessions_count_stat_seg_entry, bum->udp6_sessions_count);
- if (!bum->udp6_sessions_count)
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ --bum->udp6_mh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp6_mh_sessions_count_stat_seg_entry,
+ bum->udp6_mh_sessions_count);
+ if (!bum->udp6_mh_sessions_count)
+ {
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd6_mh, 0);
+ }
+ }
+ else
{
- udp_unregister_dst_port (vm, UDP_DST_PORT_bfd6, 0);
- udp_unregister_dst_port (vm, UDP_DST_PORT_bfd_echo6, 0);
+ --bum->udp6_sh_sessions_count;
+ bfd_udp_update_stat_segment_entry (
+ bum->udp6_sh_sessions_count_stat_seg_entry,
+ bum->udp6_sh_sessions_count);
+ if (!bum->udp6_sh_sessions_count)
+ {
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd6, 0);
+ udp_unregister_dst_port (vm, UDP_DST_PORT_bfd_echo6, 0);
+ }
}
+
break;
}
bfd_put_session (bum->bfd_main, bs);
}
static vnet_api_error_t
-bfd_udp_add_and_start_session (u32 sw_if_index,
+bfd_udp_add_and_start_session (bool multihop, u32 sw_if_index,
const ip46_address_t *local_addr,
const ip46_address_t *peer_addr,
u32 desired_min_tx_usec,
@@ -728,9 +849,10 @@ bfd_udp_add_and_start_session (u32 sw_if_index,
bfd_session_t *bs = NULL;
vnet_api_error_t rv;
- rv = bfd_udp_add_session_internal (
- vlib_get_main (), &bfd_udp_main, sw_if_index, desired_min_tx_usec,
- required_min_rx_usec, detect_mult, local_addr, peer_addr, &bs);
+ rv = bfd_udp_add_session_internal (vlib_get_main (), &bfd_udp_main, multihop,
+ sw_if_index, desired_min_tx_usec,
+ required_min_rx_usec, detect_mult,
+ local_addr, peer_addr, &bs);
if (!rv && is_authenticated)
{
@@ -750,21 +872,22 @@ bfd_udp_add_and_start_session (u32 sw_if_index,
}
vnet_api_error_t
-bfd_udp_add_session (u32 sw_if_index, const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- u32 desired_min_tx_usec, u32 required_min_rx_usec,
- u8 detect_mult, u8 is_authenticated, u32 conf_key_id,
- u8 bfd_key_id)
+bfd_udp_add_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr, u32 desired_min_tx_usec,
+ u32 required_min_rx_usec, u8 detect_mult,
+ u8 is_authenticated, u32 conf_key_id, u8 bfd_key_id)
{
bfd_main_t *bm = &bfd_main;
bfd_lock (bm);
- vnet_api_error_t rv = bfd_api_verify_common (
- sw_if_index, desired_min_tx_usec, detect_mult, local_addr, peer_addr);
+ vnet_api_error_t rv =
+ bfd_api_verify_common (multihop, sw_if_index, desired_min_tx_usec,
+ detect_mult, local_addr, peer_addr);
if (!rv)
rv = bfd_udp_add_and_start_session (
- sw_if_index, local_addr, peer_addr, desired_min_tx_usec,
+ multihop, sw_if_index, local_addr, peer_addr, desired_min_tx_usec,
required_min_rx_usec, detect_mult, is_authenticated, conf_key_id,
bfd_key_id);
@@ -773,7 +896,8 @@ bfd_udp_add_session (u32 sw_if_index, const ip46_address_t * local_addr,
}
vnet_api_error_t
-bfd_udp_upd_session (u32 sw_if_index, const ip46_address_t *local_addr,
+bfd_udp_upd_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
const ip46_address_t *peer_addr, u32 desired_min_tx_usec,
u32 required_min_rx_usec, u8 detect_mult,
u8 is_authenticated, u32 conf_key_id, u8 bfd_key_id)
@@ -781,17 +905,18 @@ bfd_udp_upd_session (u32 sw_if_index, const ip46_address_t *local_addr,
bfd_main_t *bm = &bfd_main;
bfd_lock (bm);
- vnet_api_error_t rv = bfd_api_verify_common (
- sw_if_index, desired_min_tx_usec, detect_mult, local_addr, peer_addr);
+ vnet_api_error_t rv =
+ bfd_api_verify_common (multihop, sw_if_index, desired_min_tx_usec,
+ detect_mult, local_addr, peer_addr);
if (!rv)
{
bfd_session_t *bs = NULL;
- rv = bfd_udp_find_session_by_api_input (sw_if_index, local_addr,
- peer_addr, &bs);
+ rv = bfd_udp_find_session_by_api_input (multihop, sw_if_index,
+ local_addr, peer_addr, &bs);
if (VNET_API_ERROR_BFD_ENOENT == rv)
rv = bfd_udp_add_and_start_session (
- sw_if_index, local_addr, peer_addr, desired_min_tx_usec,
+ multihop, sw_if_index, local_addr, peer_addr, desired_min_tx_usec,
required_min_rx_usec, detect_mult, is_authenticated, conf_key_id,
bfd_key_id);
else
@@ -805,7 +930,8 @@ bfd_udp_upd_session (u32 sw_if_index, const ip46_address_t *local_addr,
}
vnet_api_error_t
-bfd_udp_mod_session (u32 sw_if_index, const ip46_address_t *local_addr,
+bfd_udp_mod_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
const ip46_address_t *peer_addr, u32 desired_min_tx_usec,
u32 required_min_rx_usec, u8 detect_mult)
{
@@ -813,9 +939,8 @@ bfd_udp_mod_session (u32 sw_if_index, const ip46_address_t *local_addr,
bfd_main_t *bm = &bfd_main;
vnet_api_error_t error;
bfd_lock (bm);
- vnet_api_error_t rv =
- bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
- &bs);
+ vnet_api_error_t rv = bfd_udp_find_session_by_api_input (
+ multihop, sw_if_index, local_addr, peer_addr, &bs);
if (rv)
{
bfd_unlock (bm);
@@ -830,16 +955,15 @@ bfd_udp_mod_session (u32 sw_if_index, const ip46_address_t *local_addr,
}
vnet_api_error_t
-bfd_udp_del_session (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr)
+bfd_udp_del_session (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr)
{
bfd_session_t *bs = NULL;
bfd_main_t *bm = &bfd_main;
bfd_lock (bm);
- vnet_api_error_t rv =
- bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
- &bs);
+ vnet_api_error_t rv = bfd_udp_find_session_by_api_input (
+ multihop, sw_if_index, local_addr, peer_addr, &bs);
if (rv)
{
bfd_unlock (bm);
@@ -851,16 +975,15 @@ bfd_udp_del_session (u32 sw_if_index,
}
vnet_api_error_t
-bfd_udp_session_set_flags (vlib_main_t * vm, u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr, u8 admin_up_down)
+bfd_udp_session_set_flags (vlib_main_t *vm, bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr, u8 admin_up_down)
{
bfd_session_t *bs = NULL;
bfd_main_t *bm = &bfd_main;
bfd_lock (bm);
- vnet_api_error_t rv =
- bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
- &bs);
+ vnet_api_error_t rv = bfd_udp_find_session_by_api_input (
+ multihop, sw_if_index, local_addr, peer_addr, &bs);
if (rv)
{
bfd_unlock (bm);
@@ -872,19 +995,18 @@ bfd_udp_session_set_flags (vlib_main_t * vm, u32 sw_if_index,
}
vnet_api_error_t
-bfd_udp_auth_activate (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr,
- u32 conf_key_id, u8 key_id, u8 is_delayed)
+bfd_udp_auth_activate (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr, u32 conf_key_id,
+ u8 key_id, u8 is_delayed)
{
bfd_main_t *bm = &bfd_main;
bfd_lock (bm);
vnet_api_error_t error;
bfd_session_t *bs = NULL;
- vnet_api_error_t rv =
- bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
- &bs);
+ vnet_api_error_t rv = bfd_udp_find_session_by_api_input (
+ multihop, sw_if_index, local_addr, peer_addr, &bs);
if (rv)
{
bfd_unlock (bm);
@@ -896,17 +1018,16 @@ bfd_udp_auth_activate (u32 sw_if_index,
}
vnet_api_error_t
-bfd_udp_auth_deactivate (u32 sw_if_index,
- const ip46_address_t * local_addr,
- const ip46_address_t * peer_addr, u8 is_delayed)
+bfd_udp_auth_deactivate (bool multihop, u32 sw_if_index,
+ const ip46_address_t *local_addr,
+ const ip46_address_t *peer_addr, u8 is_delayed)
{
bfd_main_t *bm = &bfd_main;
vnet_api_error_t error;
bfd_lock (bm);
bfd_session_t *bs = NULL;
- vnet_api_error_t rv =
- bfd_udp_find_session_by_api_input (sw_if_index, local_addr, peer_addr,
- &bs);
+ vnet_api_error_t rv = bfd_udp_find_session_by_api_input (
+ multihop, sw_if_index, local_addr, peer_addr, &bs);
if (rv)
{
bfd_unlock (bm);
@@ -985,13 +1106,19 @@ bfd_udp4_verify_transport (const ip4_header_t *ip4, const udp_header_t *udp,
key->local_addr.ip4.as_u8);
return BFD_UDP_ERROR_DST_MISMATCH;
}
- const u8 expected_ttl = 255;
- if (ip4->ttl != expected_ttl)
+
+ // For single-hop, TTL must be 255
+ if (bs->hop_type == BFD_HOP_TYPE_SINGLE)
{
- BFD_ERR ("IPv4 unexpected TTL value %u, expected %u", ip4->ttl,
- expected_ttl);
- return BFD_UDP_ERROR_TTL;
+ const u8 expected_ttl = 255;
+ if (ip4->ttl != expected_ttl)
+ {
+ BFD_ERR ("IPv4 unexpected TTL value %u, expected %u", ip4->ttl,
+ expected_ttl);
+ return BFD_UDP_ERROR_TTL;
+ }
}
+
if (clib_net_to_host_u16 (udp->src_port) < 49152)
{
BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
@@ -1062,7 +1189,14 @@ bfd_udp4_scan (vlib_main_t *vm, vlib_buffer_t *b, bfd_session_t **bs_out)
{
bfd_udp_key_t key;
clib_memset (&key, 0, sizeof (key));
- key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
+ if (udp->dst_port == clib_host_to_net_u16 (UDP_DST_PORT_bfd4_mh))
+ {
+ key.sw_if_index = ~0;
+ }
+ else
+ {
+ key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
+ }
key.local_addr.ip4.as_u32 = ip4->dst_address.as_u32;
key.peer_addr.ip4.as_u32 = ip4->src_address.as_u32;
BFD_DBG ("Looking up BFD session using key (sw_if_index=%u, local=%U, "
@@ -1145,13 +1279,19 @@ bfd_udp6_verify_transport (const ip6_header_t *ip6, const udp_header_t *udp,
&key->local_addr.ip6);
return BFD_UDP_ERROR_DST_MISMATCH;
}
- const u8 expected_hop_limit = 255;
- if (ip6->hop_limit != expected_hop_limit)
+
+ // For single-hop, hop-limit must be 255
+ if (bs->hop_type == BFD_HOP_TYPE_SINGLE)
{
- BFD_ERR ("IPv6 unexpected hop-limit value %u, expected %u",
- ip6->hop_limit, expected_hop_limit);
- return BFD_UDP_ERROR_TTL;
+ const u8 expected_hop_limit = 255;
+ if (ip6->hop_limit != expected_hop_limit)
+ {
+ BFD_ERR ("IPv6 unexpected hop-limit value %u, expected %u",
+ ip6->hop_limit, expected_hop_limit);
+ return BFD_UDP_ERROR_TTL;
+ }
}
+
if (clib_net_to_host_u16 (udp->src_port) < 49152)
{
BFD_ERR ("Invalid UDP src port %u, out of range <49152,65535>",
@@ -1204,15 +1344,22 @@ bfd_udp6_scan (vlib_main_t *vm, vlib_buffer_t *b, bfd_session_t **bs_out)
{
bfd_udp_key_t key;
clib_memset (&key, 0, sizeof (key));
- key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
+ if (udp->dst_port == clib_host_to_net_u16 (UDP_DST_PORT_bfd6_mh))
+ {
+ key.sw_if_index = ~0;
+ }
+ else
+ {
+ key.sw_if_index = vnet_buffer (b)->sw_if_index[VLIB_RX];
+ }
key.local_addr.ip6.as_u64[0] = ip6->dst_address.as_u64[0];
key.local_addr.ip6.as_u64[1] = ip6->dst_address.as_u64[1];
key.peer_addr.ip6.as_u64[0] = ip6->src_address.as_u64[0];
key.peer_addr.ip6.as_u64[1] = ip6->src_address.as_u64[1];
- BFD_DBG ("Looking up BFD session using key (sw_if_index=%u, local=%U, "
- "peer=%U)",
- key.sw_if_index, format_ip6_address, &key.local_addr,
- format_ip6_address, &key.peer_addr);
+ BFD_DBG ("Looking up BFD session using discriminator %u",
+ pkt->your_disc);
+ bs = bfd_find_session_by_disc (bfd_udp_main.bfd_main, pkt->your_disc);
+
bs = bfd_lookup_session (&bfd_udp_main, &key);
}
if (!bs)
@@ -1266,8 +1413,8 @@ bfd_udp_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
{
u64 len;
t0 = vlib_add_trace (vm, rt, b0, sizeof (*t0));
- len = (b0->current_length < sizeof (t0->data)) ? b0->current_length
- : sizeof (t0->data);
+ len = (b0->current_length < sizeof (t0->data)) ? b0->current_length :
+ sizeof (t0->data);
t0->len = len;
clib_memcpy_fast (t0->data, vlib_buffer_get_current (b0), len);
}
@@ -1311,25 +1458,35 @@ bfd_udp_input (vlib_main_t * vm, vlib_node_runtime_t * rt,
vlib_node_increment_counter (vm, bfd_udp4_input_node.index,
error0, 1);
}
+
const bfd_udp_session_t *bus = &bs->udp;
- ip_adjacency_t *adj = adj_get (bus->adj_index);
- switch (adj->lookup_next_index)
+
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
{
- case IP_LOOKUP_NEXT_ARP:
- next0 = BFD_UDP_INPUT_NEXT_REPLY_ARP;
- break;
- case IP_LOOKUP_NEXT_REWRITE:
next0 = BFD_UDP_INPUT_NEXT_REPLY_REWRITE;
- break;
- case IP_LOOKUP_NEXT_MIDCHAIN:
- next0 = BFD_UDP_INPUT_NEXT_REPLY_MIDCHAIN;
- break;
- default:
- /* drop */
- break;
+ }
+ else
+ {
+ ip_adjacency_t *adj = adj_get (bus->adj_index);
+ switch (adj->lookup_next_index)
+ {
+ case IP_LOOKUP_NEXT_ARP:
+ next0 = BFD_UDP_INPUT_NEXT_REPLY_ARP;
+ break;
+ case IP_LOOKUP_NEXT_REWRITE:
+ next0 = BFD_UDP_INPUT_NEXT_REPLY_REWRITE;
+ break;
+ case IP_LOOKUP_NEXT_MIDCHAIN:
+ next0 = BFD_UDP_INPUT_NEXT_REPLY_MIDCHAIN;
+ break;
+ default:
+ /* drop */
+ break;
+ }
}
}
}
+
bfd_unlock (bm);
vlib_set_next_frame_buffer (vm, rt, next0, bi0);
@@ -1566,6 +1723,10 @@ bfd_udp_sw_if_add_del (CLIB_UNUSED (vnet_main_t *vnm), u32 sw_if_index,
{
continue;
}
+ if (bs->hop_type == BFD_HOP_TYPE_MULTI)
+ {
+ continue;
+ }
if (bs->udp.key.sw_if_index != sw_if_index)
{
continue;
@@ -1593,24 +1754,47 @@ clib_error_t *
bfd_udp_stats_init (bfd_udp_main_t *bum)
{
const char *name4 = "/bfd/udp4/sessions";
- bum->udp4_sessions_count_stat_seg_entry = vlib_stats_add_gauge ("%s", name4);
+ bum->udp4_sh_sessions_count_stat_seg_entry =
+ vlib_stats_add_gauge ("%s", name4);
- vlib_stats_set_gauge (bum->udp4_sessions_count_stat_seg_entry, 0);
- if (~0 == bum->udp4_sessions_count_stat_seg_entry)
+ vlib_stats_set_gauge (bum->udp4_sh_sessions_count_stat_seg_entry, 0);
+ if (~0 == bum->udp4_sh_sessions_count_stat_seg_entry)
{
return clib_error_return (
0, "Could not create stat segment entry for %s", name4);
}
const char *name6 = "/bfd/udp6/sessions";
- bum->udp6_sessions_count_stat_seg_entry = vlib_stats_add_gauge ("%s", name6);
+ bum->udp6_sh_sessions_count_stat_seg_entry =
+ vlib_stats_add_gauge ("%s", name6);
- vlib_stats_set_gauge (bum->udp6_sessions_count_stat_seg_entry, 0);
- if (~0 == bum->udp6_sessions_count_stat_seg_entry)
+ vlib_stats_set_gauge (bum->udp6_sh_sessions_count_stat_seg_entry, 0);
+ if (~0 == bum->udp6_sh_sessions_count_stat_seg_entry)
{
return clib_error_return (
0, "Could not create stat segment entry for %s", name6);
}
+ const char *name4_mh = "/bfd/udp4/sessions_mh";
+ bum->udp4_mh_sessions_count_stat_seg_entry =
+ vlib_stats_add_gauge ("%s", name4_mh);
+
+ vlib_stats_set_gauge (bum->udp4_mh_sessions_count_stat_seg_entry, 0);
+ if (~0 == bum->udp4_mh_sessions_count_stat_seg_entry)
+ {
+ return clib_error_return (
+ 0, "Could not create stat segment entry for %s", name4_mh);
+ }
+ const char *name6_mh = "/bfd/udp6/sessions_mh";
+ bum->udp6_mh_sessions_count_stat_seg_entry =
+ vlib_stats_add_gauge ("%s", name6_mh);
+
+ vlib_stats_set_gauge (bum->udp6_mh_sessions_count_stat_seg_entry, 0);
+ if (~0 == bum->udp6_mh_sessions_count_stat_seg_entry)
+ {
+ return clib_error_return (
+ 0, "Could not create stat segment entry for %s", name6_mh);
+ }
+
return 0;
}
@@ -1620,8 +1804,10 @@ bfd_udp_stats_init (bfd_udp_main_t *bum)
static clib_error_t *
bfd_udp_init (vlib_main_t * vm)
{
- bfd_udp_main.udp4_sessions_count = 0;
- bfd_udp_main.udp6_sessions_count = 0;
+ bfd_udp_main.udp4_sh_sessions_count = 0;
+ bfd_udp_main.udp6_sh_sessions_count = 0;
+ bfd_udp_main.udp4_mh_sessions_count = 0;
+ bfd_udp_main.udp6_mh_sessions_count = 0;
mhash_init (&bfd_udp_main.bfd_session_idx_by_bfd_key, sizeof (uword),
sizeof (bfd_udp_key_t));
bfd_udp_main.bfd_main = &bfd_main;
diff --git a/src/vnet/bfd/bfd_udp.h b/src/vnet/bfd/bfd_udp.h
index 8f4bfee2bd7..362e9541dfe 100644
--- a/src/vnet/bfd/bfd_udp.h
+++ b/src/vnet/bfd/bfd_udp.h
@@ -26,12 +26,10 @@
/** identifier of BFD session based on UDP transport only */
typedef CLIB_PACKED (struct {
- union {
- /** interface to which the session is tied - single-hop */
- u32 sw_if_index;
- /** the FIB index the peer is in - multi-hop*/
- u32 fib_index;
- };
+ /** interface to which the session is tied - single-hop */
+ u16 sw_if_index;
+ /** the FIB index the peer is in - multi-hop*/
+ u16 fib_index;
/** local address */
ip46_address_t local_addr;
/** peer address */