37 case BFD_TRANSPORT_UDP4:
38 s =
format (s,
"%=10u %-32s %20U %20U\n", bs->
bs_idx,
"IPv4 address",
42 case BFD_TRANSPORT_UDP6:
43 s =
format (s,
"%=10u %-32s %20U %20U\n", bs->
bs_idx,
"IPv6 address",
48 s =
format (s,
"%10s %-32s %20s %20s\n",
"",
"Session state",
51 s =
format (s,
"%10s %-32s %20s %20s\n",
"",
"Diagnostic code",
54 s =
format (s,
"%10s %-32s %20u %20u\n",
"",
"Detect multiplier",
56 s =
format (s,
"%10s %-32s %20u %20llu\n",
"",
57 "Required Min Rx Interval (usec)",
59 s =
format (s,
"%10s %-32s %20u %20u\n",
"",
60 "Desired Min Tx Interval (usec)",
64 format (s,
"%10s %-32s %20u\n",
"",
"Transmit interval",
72 s =
format (s,
"%10s %-32s %20v\n",
"",
"Last control frame tx", tmp);
79 s =
format (s,
"%10s %-32s %20v\n",
"",
"Last control frame rx", tmp);
83 format (s,
"%10s %-32s %20u %20llu\n",
"",
"Min Echo Rx Interval (usec)",
87 s =
format (s,
"%10s %-32s %20u\n",
"",
"Echo transmit interval",
91 s =
format (s,
"%10s %-32s %20v\n",
"",
"Last echo frame tx", tmp);
93 tmp =
format (tmp,
"%.6fs",
97 format (s,
"%10s %-32s %20v\n",
"",
"Last echo frame roundtrip time",
102 s =
format (s,
"%10s %-32s %20s %20s\n",
"",
"Demand mode",
"no",
104 s =
format (s,
"%10s %-32s %20s\n",
"",
"Poll state",
108 s =
format (s,
"%10s %-32s %20u\n",
"",
"Authentication config key ID",
110 s =
format (s,
"%10s %-32s %20u\n",
"",
"Authentication BFD key ID",
112 s =
format (s,
"%10s %-32s %20u %20u\n",
"",
"Sequence number",
133 u8 *s =
format (NULL,
"%=10s %=25s %=10s\n",
"Configuration Key ID",
134 "Type",
"Use Count");
137 s = format (s,
"%10u %-25s %10u\n", key->conf_key_id,
138 bfd_auth_type_str (key->auth_type), key->use_count);
146 else if (
unformat (line_input,
"sessions"))
148 u8 *s =
format (NULL,
"%=10s %=32s %=20s %=20s\n",
"Index",
"Property",
149 "Local value",
"Remote value");
152 s = format (s,
"%U", format_bfd_session_cli, vm, bm, bs);
160 else if (
unformat (line_input,
"echo-source"))
169 &have_usable_ip6, &ip6);
176 u8 *s =
format (NULL,
"UDP echo source is: %v\n", hw_if->
name);
177 s =
format (s,
"IPv4 address usable as echo source: ");
186 s =
format (s,
"IPv6 address usable as echo source: ");
216 .short_help =
"show bfd [keys|sessions|echo-source]",
228 u8 *vec_auth_type = NULL;
232 static const u8 keyed_sha1[] =
"keyed-sha1";
233 static const u8 meticulous_keyed_sha1[] =
"meticulous-keyed-sha1";
241 if (
unformat (line_input,
"conf-key-id %u", &key_id))
248 if (
vec_len (vec_auth_type) ==
sizeof (keyed_sha1) - 1 &&
249 0 == memcmp (vec_auth_type, keyed_sha1,
250 sizeof (keyed_sha1) - 1))
252 auth_type = BFD_AUTH_TYPE_keyed_sha1;
254 else if (
vec_len (vec_auth_type) ==
255 sizeof (meticulous_keyed_sha1) - 1 &&
256 0 == memcmp (vec_auth_type, meticulous_keyed_sha1,
257 sizeof (meticulous_keyed_sha1) - 1))
259 auth_type = BFD_AUTH_TYPE_meticulous_keyed_sha1;
313 .path =
"bfd key set",
314 .short_help =
"bfd key set" 316 " type <keyed-sha1|meticulous-keyed-sha1> " 336 if (!
unformat (line_input,
"conf-key-id %u", &key_id))
358 .path =
"bfd key del",
359 .short_help =
"bfd key del conf-key-id <id>",
364 #define INTERFACE_STR "interface" 365 #define LOCAL_ADDR_STR "local-addr" 366 #define PEER_ADDR_STR "peer-addr" 367 #define CONF_KEY_ID_STR "conf-key-id" 368 #define BFD_KEY_ID_STR "bfd-key-id" 369 #define DESIRED_MIN_TX_STR "desired-min-tx" 370 #define REQUIRED_MIN_RX_STR "required-min-rx" 371 #define DETECT_MULT_STR "detect-mult" 372 #define ADMIN_STR "admin" 373 #define DELAYED_STR "delayed" 375 static const unsigned mandatory = 1;
376 static const unsigned optional = 0;
378 #define DECLARE(t, n, s, r, ...) \ 382 #define UNFORMAT(t, n, s, r, ...) \ 383 if (unformat (line_input, s " " __VA_ARGS__, &n)) \ 385 something_parsed = 1; \ 389 #define CHECK_MANDATORY(t, n, s, r, ...) \ 390 WARN_OFF(tautological-compare) \ 391 if (mandatory == r && !have_##n) \ 393 WARN_ON(tautological-compare) \ 394 ret = clib_error_return (0, "Required parameter `%s' missing.", s); \ 404 #define foreach_bfd_cli_udp_session_add_cli_param(F) \ 405 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 406 unformat_vnet_sw_interface, &vnet_main) \ 407 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 408 unformat_ip46_address) \ 409 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 410 unformat_ip46_address) \ 411 F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \ 412 F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \ 413 F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u") \ 414 F (u32, conf_key_id, CONF_KEY_ID_STR, optional, "%u") \ 415 F (u32, bfd_key_id, BFD_KEY_ID_STR, optional, "%u") 425 int something_parsed = 0;
428 if (!something_parsed)
438 if (1 == have_conf_key_id + have_bfd_key_id)
441 "and `%s' must be either both specified or none",
446 if (detect_mult > 255)
453 if (have_bfd_key_id && bfd_key_id > 255)
463 detect_mult, have_conf_key_id, conf_key_id,
469 "`bfd_add_add_session' API call failed, rv=%d:%U",
480 .path =
"bfd udp session add",
481 .short_help =
"bfd udp session add" 482 " interface <interface>" 483 " local-addr <local-address>" 484 " peer-addr <peer-address>" 485 " desired-min-tx <desired min tx interval>" 486 " required-min-rx <required min rx interval>" 487 " detect-mult <detect multiplier> " 489 " conf-key-id <config key ID>" 490 " bfd-key-id <BFD key ID>" 502 #define foreach_bfd_cli_udp_session_mod_cli_param(F) \ 503 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 504 unformat_vnet_sw_interface, &vnet_main) \ 505 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 506 unformat_ip46_address) \ 507 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 508 unformat_ip46_address) \ 509 F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \ 510 F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \ 511 F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u") 521 int something_parsed = 0;
524 if (!something_parsed)
534 if (detect_mult > 255)
543 desired_min_tx, required_min_rx, detect_mult);
548 "`bfd_udp_mod_session' API call failed, rv=%d:%U",
559 .path =
"bfd udp session mod",
560 .short_help =
"bfd udp session mod interface" 561 " <interface> local-addr" 562 " <local-address> peer-addr" 563 " <peer-address> desired-min-tx" 564 " <desired min tx interval> required-min-rx" 565 " <required min rx interval> detect-mult" 566 " <detect multiplier> ",
577 #define foreach_bfd_cli_udp_session_del_cli_param(F) \ 578 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 579 unformat_vnet_sw_interface, &vnet_main) \ 580 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 581 unformat_ip46_address) \ 582 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 583 unformat_ip46_address) 593 int something_parsed = 0;
596 if (!something_parsed)
612 "`bfd_udp_del_session' API call failed, rv=%d:%U",
623 .path =
"bfd udp session del",
624 .short_help =
"bfd udp session del interface" 625 " <interface> local-addr" 626 " <local-address> peer-addr" 638 #define foreach_bfd_cli_udp_session_set_flags_cli_param(F) \ 639 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 640 unformat_vnet_sw_interface, &vnet_main) \ 641 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 642 unformat_ip46_address) \ 643 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 644 unformat_ip46_address) \ 645 F (u8 *, admin_up_down_token, ADMIN_STR, mandatory, "%v", \ 646 &admin_up_down_token) 656 int something_parsed = 0;
659 if (!something_parsed)
670 static const char up[] =
"up";
671 static const char down[] =
"down";
672 if (!memcmp (admin_up_down_token, up,
sizeof (up) - 1))
676 else if (!memcmp (admin_up_down_token, down,
sizeof (down) - 1))
688 &peer_addr, admin_up_down);
693 "`bfd_udp_session_set_flags' API call failed, rv=%d:%U",
704 .path =
"bfd udp session set-flags",
705 .short_help =
"bfd udp session set-flags" 706 " interface <interface>" 707 " local-addr <local-address>" 708 " peer-addr <peer-address>" 721 #define foreach_bfd_cli_udp_session_auth_activate_cli_param(F) \ 722 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 723 unformat_vnet_sw_interface, &vnet_main) \ 724 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 725 unformat_ip46_address) \ 726 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 727 unformat_ip46_address) \ 728 F (u8 *, delayed_token, DELAYED_STR, optional, "%v") \ 729 F (u32, conf_key_id, CONF_KEY_ID_STR, mandatory, "%u") \ 730 F (u32, bfd_key_id, BFD_KEY_ID_STR, mandatory, "%u") 740 int something_parsed = 0;
743 if (!something_parsed)
754 if (have_delayed_token)
756 static const char yes[] =
"yes";
757 static const char no[] =
"no";
758 if (!memcmp (delayed_token, yes,
sizeof (yes) - 1))
762 else if (!memcmp (delayed_token, no,
sizeof (no) - 1))
770 "Unrecognized value for `%s' parameter: `%v'",
776 if (have_bfd_key_id && bfd_key_id > 255)
785 bfd_key_id, is_delayed);
790 "`bfd_udp_auth_activate' API call failed, rv=%d:%U",
801 .path =
"bfd udp session auth activate",
802 .short_help =
"bfd udp session auth activate" 803 " interface <interface>" 804 " local-addr <local-address>" 805 " peer-addr <peer-address>" 806 " conf-key-id <config key ID>" 807 " bfd-key-id <BFD key ID>" 808 " [ delayed <yes|no> ]",
818 #define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F) \ 819 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 820 unformat_vnet_sw_interface, &vnet_main) \ 821 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \ 822 unformat_ip46_address) \ 823 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \ 824 unformat_ip46_address) \ 825 F (u8 *, delayed_token, DELAYED_STR, optional, "%v") 835 int something_parsed = 0;
838 if (!something_parsed)
849 if (have_delayed_token)
851 static const char yes[] =
"yes";
852 static const char no[] =
"no";
853 if (!memcmp (delayed_token, yes,
sizeof (yes) - 1))
857 else if (!memcmp (delayed_token, no,
sizeof (no) - 1))
864 0,
"Unrecognized value for `%s' parameter: `%v'",
DELAYED_STR,
871 &peer_addr, is_delayed);
875 0,
"`bfd_udp_auth_deactivate' API call failed, rv=%d:%U", (
int)rv,
886 .path =
"bfd udp session auth deactivate",
887 .short_help =
"bfd udp session auth deactivate" 888 " interface <interface>" 889 " local-addr <local-address>" 890 " peer-addr <peer-address>" 891 "[ delayed <yes|no> ]",
902 #define foreach_bfd_cli_udp_set_echo_source_cli_param(F) \ 903 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \ 904 unformat_vnet_sw_interface, &vnet_main) 914 int something_parsed = 0;
917 if (!something_parsed)
932 "`bfd_udp_set_echo_source' API call failed, rv=%d:%U",
943 .path =
"bfd udp echo-source set",
944 .short_help =
"bfd udp echo-source set interface <interface>",
957 "`bfd_udp_del_echo_source' API call failed, rv=%d:%U",
966 .path =
"bfd udp echo-source del",
967 .short_help =
"bfd udp echo-source del",
u8 curr_bfd_key_id
current key ID sent out in bfd packet
static clib_error_t * bfd_cli_udp_session_mod(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
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)
modify existing session
static clib_error_t * bfd_cli_key_del(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
u64 echo_last_rx_clocks
timestamp of last echo packet received
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
bfd_diag_code_e local_diag
local diagnostics
static u64 clib_cpu_time_now(void)
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)
create a new bfd session
vnet_api_error_t bfd_auth_del_key(u32 conf_key_id)
delete existing authentication key
u64 last_tx_clocks
timestamp of last packet transmitted
static clib_error_t * bfd_cli_udp_session_set_flags(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
u32 remote_seq_number
remote sequence number
vnet_api_error_t bfd_udp_del_echo_source()
unset echo-source interface
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
void bfd_udp_get_echo_source(int *is_set, u32 *sw_if_index, int *have_usable_ip4, ip4_address_t *ip4, int *have_usable_ip6, ip6_address_t *ip6)
get echo source information - used by CLI
#define foreach_bfd_cli_udp_session_auth_activate_cli_param(F)
u32 bfd_clocks_to_usec(const bfd_main_t *bm, u64 clocks)
vnet_api_error_t bfd_udp_del_session(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr)
delete existing session
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
const char * bfd_poll_state_string(bfd_poll_state_e state)
static clib_error_t * bfd_cli_udp_set_echo_source(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
u64 remote_min_rx_usec
remote min rx interval (microseconds)
#define clib_error_return(e, args...)
#define foreach_bfd_cli_udp_set_echo_source_cli_param(F)
vnet_api_error_t bfd_auth_set_key(u32 conf_key_id, u8 auth_type, u8 key_len, const u8 *key)
create or modify bfd authentication key
#define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F)
#define CHECK_MANDATORY(t, n, s, r,...)
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
bfd_udp_key_t key
key identifying this session
bfd_transport_e transport
transport type for this session
#define foreach_bfd_cli_udp_session_mod_cli_param(F)
u64 echo_last_tx_clocks
timestamp of last echo packet transmitted
bfd_poll_state_e poll_state
state info regarding poll sequence
static clib_error_t * show_bfd(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
static clib_error_t * bfd_cli_udp_session_auth_deactivate(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
#define foreach_bfd_cli_udp_session_set_flags_cli_param(F)
u8 local_detect_mult
configured detect multiplier
#define DECLARE(t, n, s, r,...)
static u8 * format_vnet_api_errno(u8 *s, va_list *args)
u64 last_rx_clocks
timestamp of last packet received
vnet_api_error_t bfd_udp_session_set_flags(u32 sw_if_index, const ip46_address_t *local_addr, const ip46_address_t *peer_addr, u8 admin_up_down)
set session admin down/up
bfd_diag_code_e remote_diag
remote diagnostics
u64 transmit_interval_clocks
transmit interval
#define foreach_bfd_cli_udp_session_del_cli_param(F)
#define vec_free(V)
Free vector's memory (no header).
struct bfd_session_s::@52 auth
authentication information
u32 config_desired_min_tx_usec
configured desired min tx interval (microseconds)
#define UNFORMAT(t, n, s, r,...)
const char * bfd_diag_code_string(bfd_diag_code_e diag)
static clib_error_t * bfd_cli_udp_session_auth_activate(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
static clib_error_t * bfd_cli_udp_del_echo_source(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
#define VLIB_CLI_COMMAND(x,...)
u8 echo
1 is echo function is active, 0 otherwise
u64 remote_desired_min_tx_clocks
remote desired min tx interval (clocks)
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 bfd_key_id, u8 is_delayed)
activate authentication for existing session
u32 conf_key_id
global configuration key ID
bfd_state_e local_state
session state
u64 echo_transmit_interval_clocks
transmit interval for echo packets
u32 local_seq_number
sequence number incremented occasionally or always (if meticulous)
vnet_api_error_t bfd_udp_set_echo_source(u32 loopback_sw_if_index)
set echo-source interface
u32 config_required_min_rx_usec
configured required min rx interval (microseconds)
static clib_error_t * bfd_cli_udp_session_del(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
u32 bs_idx
index in bfd_main.sessions pool
static u8 * format_bfd_session_cli(u8 *s, va_list *args)
u64 remote_min_echo_rx_usec
remote min echo rx interval (microseconds)
bfd_state_e remote_state
remote session state
const char * bfd_state_string(bfd_state_e state)
static clib_error_t * bfd_cli_udp_session_add(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
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)
deactivate authentication for existing session
bfd_auth_key_t * curr_key
current key in use
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define foreach_bfd_cli_udp_session_add_cli_param(F)
static clib_error_t * bfd_cli_key_add(vlib_main_t *vm, unformat_input_t *input, CLIB_UNUSED(vlib_cli_command_t *lmd))
u8 remote_detect_mult
remote detect multiplier
static vnet_sw_interface_t * vnet_get_sw_interface_or_null(vnet_main_t *vnm, u32 sw_if_index)
static uword pool_elts(void *v)
Number of active elements in a pool.