diff options
author | 2024-09-03 11:52:20 -0400 | |
---|---|---|
committer | 2024-10-15 15:46:01 -0400 | |
commit | 17a918133ba056851c848cbd95dcd241b900cd3d (patch) | |
tree | 12ca4e9ce461e8fc8a4f945ea3830629e5a93a2f /src/vnet/bfd/bfd_cli.c | |
parent | 514098ee82737732c4491700254625d30b0e6bbb (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/bfd_cli.c')
-rw-r--r-- | src/vnet/bfd/bfd_cli.c | 150 |
1 files changed, 95 insertions, 55 deletions
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, }; |