2 * Copyright (c) 2011-2016 Cisco and/or its affiliates.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at:
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
17 * @brief BFD CLI implementation
20 #include <vlib/vlib.h>
22 #include <vppinfra/format.h>
23 #include <vnet/api_errno.h>
24 #include <vnet/ip/format.h>
25 #include <vnet/bfd/bfd_api.h>
26 #include <vnet/bfd/bfd_main.h>
29 format_bfd_session_cli (u8 * s, va_list * args)
31 vlib_main_t *vm = va_arg (*args, vlib_main_t *);
32 bfd_main_t *bm = va_arg (*args, bfd_main_t *);
33 bfd_session_t *bs = va_arg (*args, bfd_session_t *);
34 switch (bs->transport)
36 case BFD_TRANSPORT_UDP4:
37 s = format (s, "%=10u %-32s %20U %20U\n", bs->bs_idx, "IPv4 address",
38 format_ip4_address, bs->udp.key.local_addr.ip4.as_u8,
39 format_ip4_address, bs->udp.key.peer_addr.ip4.as_u8);
41 case BFD_TRANSPORT_UDP6:
42 s = format (s, "%=10u %-32s %20U %20U\n", bs->bs_idx, "IPv6 address",
43 format_ip6_address, &bs->udp.key.local_addr.ip6,
44 format_ip6_address, &bs->udp.key.peer_addr.ip6);
47 s = format (s, "%10s %-32s %20s %20s\n", "", "Session state",
48 bfd_state_string (bs->local_state),
49 bfd_state_string (bs->remote_state));
50 s = format (s, "%10s %-32s %20s %20s\n", "", "Diagnostic code",
51 bfd_diag_code_string (bs->local_diag),
52 bfd_diag_code_string (bs->remote_diag));
53 s = format (s, "%10s %-32s %20u %20u\n", "", "Detect multiplier",
54 bs->local_detect_mult, bs->remote_detect_mult);
55 s = format (s, "%10s %-32s %20u %20llu\n", "",
56 "Required Min Rx Interval (usec)",
57 bs->config_required_min_rx_usec, bs->remote_min_rx_usec);
58 s = format (s, "%10s %-32s %20u %20u\n", "",
59 "Desired Min Tx Interval (usec)",
60 bs->config_desired_min_tx_usec, bfd_clocks_to_usec (bm,
61 bs->remote_desired_min_tx_clocks));
63 format (s, "%10s %-32s %20u\n", "", "Transmit interval",
64 bfd_clocks_to_usec (bm, bs->transmit_interval_clocks));
65 u64 now = clib_cpu_time_now ();
67 if (bs->last_tx_clocks > 0)
69 tmp = format (tmp, "%.2fs ago", (now - bs->last_tx_clocks) *
70 vm->clib_time.seconds_per_clock);
71 s = format (s, "%10s %-32s %20v\n", "", "Last control frame tx", tmp);
72 vec_reset_length (tmp);
74 if (bs->last_rx_clocks)
76 tmp = format (tmp, "%.2fs ago", (now - bs->last_rx_clocks) *
77 vm->clib_time.seconds_per_clock);
78 s = format (s, "%10s %-32s %20v\n", "", "Last control frame rx", tmp);
79 vec_reset_length (tmp);
82 format (s, "%10s %-32s %20u %20llu\n", "", "Min Echo Rx Interval (usec)",
83 1, bs->remote_min_echo_rx_usec);
86 s = format (s, "%10s %-32s %20u\n", "", "Echo transmit interval",
87 bfd_clocks_to_usec (bm, bs->echo_transmit_interval_clocks));
88 tmp = format (tmp, "%.2fs ago", (now - bs->echo_last_tx_clocks) *
89 vm->clib_time.seconds_per_clock);
90 s = format (s, "%10s %-32s %20v\n", "", "Last echo frame tx", tmp);
91 vec_reset_length (tmp);
92 tmp = format (tmp, "%.6fs",
93 (bs->echo_last_rx_clocks - bs->echo_last_tx_clocks) *
94 vm->clib_time.seconds_per_clock);
96 format (s, "%10s %-32s %20v\n", "", "Last echo frame roundtrip time",
101 s = format (s, "%10s %-32s %20s %20s\n", "", "Demand mode", "no",
102 bs->remote_demand ? "yes" : "no");
103 s = format (s, "%10s %-32s %20s\n", "", "Poll state",
104 bfd_poll_state_string (bs->poll_state));
105 if (bs->auth.curr_key)
107 s = format (s, "%10s %-32s %20u\n", "", "Authentication config key ID",
108 bs->auth.curr_key->conf_key_id);
109 s = format (s, "%10s %-32s %20u\n", "", "Authentication BFD key ID",
110 bs->auth.curr_bfd_key_id);
111 s = format (s, "%10s %-32s %20u %20u\n", "", "Sequence number",
112 bs->auth.local_seq_number, bs->auth.remote_seq_number);
117 static clib_error_t *
118 show_bfd (vlib_main_t * vm, unformat_input_t * input,
119 CLIB_UNUSED (vlib_cli_command_t * lmd))
121 bfd_main_t *bm = &bfd_main;
122 bfd_session_t *bs = NULL;
124 if (unformat (input, "keys"))
126 bfd_auth_key_t *key = NULL;
127 u8 *s = format (NULL, "%=10s %=25s %=10s\n", "Configuration Key ID",
128 "Type", "Use Count");
130 pool_foreach (key, bm->auth_keys, {
131 s = format (s, "%10u %-25s %10u\n", key->conf_key_id,
132 bfd_auth_type_str (key->auth_type), key->use_count);
135 vlib_cli_output (vm, "%v\n", s);
137 vlib_cli_output (vm, "Number of configured BFD keys: %lu\n",
138 (u64) pool_elts (bm->auth_keys));
140 else if (unformat (input, "sessions"))
142 u8 *s = format (NULL, "%=10s %=32s %=20s %=20s\n", "Index", "Property",
143 "Local value", "Remote value");
145 pool_foreach (bs, bm->sessions, {
146 s = format (s, "%U", format_bfd_session_cli, vm, bm, bs);
149 vlib_cli_output (vm, "%v", s);
151 vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n",
152 (u64) pool_elts (bm->sessions));
154 else if (unformat (input, "echo-source"))
162 bfd_udp_get_echo_source (&is_set, &sw_if_index, &have_usable_ip4, &ip4,
163 &have_usable_ip6, &ip6);
166 vnet_sw_interface_t *sw_if =
167 vnet_get_sw_interface_safe (&vnet_main, sw_if_index);
168 vnet_hw_interface_t *hw_if =
169 vnet_get_hw_interface (&vnet_main, sw_if->hw_if_index);
170 u8 *s = format (NULL, "UDP echo source is: %v\n", hw_if->name);
171 s = format (s, "IPv4 address usable as echo source: ");
174 s = format (s, "%U\n", format_ip4_address, &ip4);
178 s = format (s, "none\n");
180 s = format (s, "IPv6 address usable as echo source: ");
183 s = format (s, "%U\n", format_ip6_address, &ip6);
187 s = format (s, "none\n");
189 vlib_cli_output (vm, "%v", s);
194 vlib_cli_output (vm, "UDP echo source is not set.\n");
199 vlib_cli_output (vm, "Number of configured BFD sessions: %lu\n",
200 (u64) pool_elts (bm->sessions));
201 vlib_cli_output (vm, "Number of configured BFD keys: %lu\n",
202 (u64) pool_elts (bm->auth_keys));
208 VLIB_CLI_COMMAND (show_bfd_command, static) = {
210 .short_help = "show bfd [keys|sessions|echo-source]",
211 .function = show_bfd,
216 format_vnet_api_errno (u8 * s, va_list * args)
218 vnet_api_error_t api_error = va_arg (*args, vnet_api_error_t);
221 s = format (s, "%s", c); \
225 foreach_vnet_api_error default:s = format (s, "UNKNOWN");
231 static clib_error_t *
232 bfd_cli_key_add (vlib_main_t * vm, unformat_input_t * input,
233 CLIB_UNUSED (vlib_cli_command_t * lmd))
235 clib_error_t *ret = NULL;
238 u8 *vec_auth_type = NULL;
239 bfd_auth_type_e auth_type = BFD_AUTH_TYPE_reserved;
241 static const u8 keyed_sha1[] = "keyed-sha1";
242 static const u8 meticulous_keyed_sha1[] = "meticulous-keyed-sha1";
244 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
246 if (unformat (input, "conf-key-id %u", &key_id))
250 else if (unformat (input, "type %U", unformat_token, "a-zA-Z0-9-",
253 if (vec_len (vec_auth_type) == sizeof (keyed_sha1) - 1 &&
254 0 == memcmp (vec_auth_type, keyed_sha1,
255 sizeof (keyed_sha1) - 1))
257 auth_type = BFD_AUTH_TYPE_keyed_sha1;
259 else if (vec_len (vec_auth_type) ==
260 sizeof (meticulous_keyed_sha1) - 1 &&
261 0 == memcmp (vec_auth_type, meticulous_keyed_sha1,
262 sizeof (meticulous_keyed_sha1) - 1))
264 auth_type = BFD_AUTH_TYPE_meticulous_keyed_sha1;
268 ret = clib_error_return (0, "invalid type `%v'", vec_auth_type);
272 else if (unformat (input, "secret %U", unformat_hex_string, &secret))
274 /* nothing to do here */
278 ret = clib_error_return (0, "Unknown input `%U'",
279 format_unformat_error, input);
287 clib_error_return (0, "required parameter missing: `conf-key-id'");
292 ret = clib_error_return (0, "required parameter missing: `type'");
297 ret = clib_error_return (0, "required parameter missing: `secret'");
301 vnet_api_error_t rv =
302 bfd_auth_set_key (key_id, auth_type, vec_len (secret), secret);
306 clib_error_return (0, "`bfd_auth_set_key' API call failed, rv=%d:%U",
307 (int) rv, format_vnet_api_errno, rv);
311 vec_free (vec_auth_type);
316 VLIB_CLI_COMMAND (bfd_cli_key_add_command, static) = {
317 .path = "bfd key set",
318 .short_help = "bfd key set"
320 " type <keyed-sha1|meticulous-keyed-sha1> "
322 .function = bfd_cli_key_add,
326 static clib_error_t *
327 bfd_cli_key_del (vlib_main_t * vm, unformat_input_t * input,
328 CLIB_UNUSED (vlib_cli_command_t * lmd))
330 clib_error_t *ret = NULL;
333 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
335 if (!unformat (input, "conf-key-id %u", &key_id))
337 ret = clib_error_return (0, "Unknown input `%U'",
338 format_unformat_error, input);
343 vnet_api_error_t rv = bfd_auth_del_key (key_id);
347 clib_error_return (0, "`bfd_auth_del_key' API call failed, rv=%d:%U",
348 (int) rv, format_vnet_api_errno, rv);
356 VLIB_CLI_COMMAND (bfd_cli_key_del_command, static) = {
357 .path = "bfd key del",
358 .short_help = "bfd key del conf-key-id <id>",
359 .function = bfd_cli_key_del,
363 #define INTERFACE_STR "interface"
364 #define LOCAL_ADDR_STR "local-addr"
365 #define PEER_ADDR_STR "peer-addr"
366 #define CONF_KEY_ID_STR "conf-key-id"
367 #define BFD_KEY_ID_STR "bfd-key-id"
368 #define DESIRED_MIN_TX_STR "desired-min-tx"
369 #define REQUIRED_MIN_RX_STR "required-min-rx"
370 #define DETECT_MULT_STR "detect-mult"
371 #define ADMIN_STR "admin"
372 #define DELAYED_STR "delayed"
374 static const unsigned mandatory = 1;
375 static const unsigned optional = 0;
377 #define DECLARE(t, n, s, r, ...) \
381 #define UNFORMAT(t, n, s, r, ...) \
382 if (unformat (input, s " " __VA_ARGS__, &n)) \
384 something_parsed = 1; \
388 #define CHECK_MANDATORY(t, n, s, r, ...) \
389 if (mandatory == r && !have_##n) \
391 ret = clib_error_return (0, "Required parameter `%s' missing.", s); \
395 static clib_error_t *
396 bfd_cli_udp_session_add (vlib_main_t * vm, unformat_input_t * input,
397 CLIB_UNUSED (vlib_cli_command_t * lmd))
399 clib_error_t *ret = NULL;
400 #define foreach_bfd_cli_udp_session_add_cli_param(F) \
401 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
402 unformat_vnet_sw_interface, &vnet_main) \
403 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
404 unformat_ip46_address) \
405 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
406 unformat_ip46_address) \
407 F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \
408 F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \
409 F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u") \
410 F (u32, conf_key_id, CONF_KEY_ID_STR, optional, "%u") \
411 F (u32, bfd_key_id, BFD_KEY_ID_STR, optional, "%u")
413 foreach_bfd_cli_udp_session_add_cli_param (DECLARE);
415 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
417 int something_parsed = 0;
418 foreach_bfd_cli_udp_session_add_cli_param (UNFORMAT);
420 if (!something_parsed)
422 ret = clib_error_return (0, "Unknown input `%U'",
423 format_unformat_error, input);
428 foreach_bfd_cli_udp_session_add_cli_param (CHECK_MANDATORY);
430 if (1 == have_conf_key_id + have_bfd_key_id)
432 ret = clib_error_return (0, "Incompatible parameter combination, `%s' "
433 "and `%s' must be either both specified or none",
434 CONF_KEY_ID_STR, BFD_KEY_ID_STR);
438 if (detect_mult > 255)
440 ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
441 DETECT_MULT_STR, detect_mult);
445 if (have_bfd_key_id && bfd_key_id > 255)
447 ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
448 BFD_KEY_ID_STR, bfd_key_id);
452 vnet_api_error_t rv =
453 bfd_udp_add_session (sw_if_index, &local_addr, &peer_addr, desired_min_tx,
455 detect_mult, have_conf_key_id, conf_key_id,
460 clib_error_return (0,
461 "`bfd_add_add_session' API call failed, rv=%d:%U",
462 (int) rv, format_vnet_api_errno, rv);
471 VLIB_CLI_COMMAND (bfd_cli_udp_session_add_command, static) = {
472 .path = "bfd udp session add",
473 .short_help = "bfd udp session add"
474 " interface <interface>"
475 " local-addr <local-address>"
476 " peer-addr <peer-address>"
477 " desired-min-tx <desired min tx interval>"
478 " required-min-rx <required min rx interval>"
479 " detect-mult <detect multiplier> "
481 " conf-key-id <config key ID>"
482 " bfd-key-id <BFD key ID>"
484 .function = bfd_cli_udp_session_add,
488 static clib_error_t *
489 bfd_cli_udp_session_mod (vlib_main_t * vm, unformat_input_t * input,
490 CLIB_UNUSED (vlib_cli_command_t * lmd))
492 clib_error_t *ret = NULL;
493 #define foreach_bfd_cli_udp_session_mod_cli_param(F) \
494 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
495 unformat_vnet_sw_interface, &vnet_main) \
496 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
497 unformat_ip46_address) \
498 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
499 unformat_ip46_address) \
500 F (u32, desired_min_tx, DESIRED_MIN_TX_STR, mandatory, "%u") \
501 F (u32, required_min_rx, REQUIRED_MIN_RX_STR, mandatory, "%u") \
502 F (u32, detect_mult, DETECT_MULT_STR, mandatory, "%u")
504 foreach_bfd_cli_udp_session_mod_cli_param (DECLARE);
506 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
508 int something_parsed = 0;
509 foreach_bfd_cli_udp_session_mod_cli_param (UNFORMAT);
511 if (!something_parsed)
513 ret = clib_error_return (0, "Unknown input `%U'",
514 format_unformat_error, input);
519 foreach_bfd_cli_udp_session_mod_cli_param (CHECK_MANDATORY);
521 if (detect_mult > 255)
523 ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
524 DETECT_MULT_STR, detect_mult);
528 vnet_api_error_t rv =
529 bfd_udp_mod_session (sw_if_index, &local_addr, &peer_addr,
530 desired_min_tx, required_min_rx, detect_mult);
534 clib_error_return (0,
535 "`bfd_udp_mod_session' API call failed, rv=%d:%U",
536 (int) rv, format_vnet_api_errno, rv);
545 VLIB_CLI_COMMAND (bfd_cli_udp_session_mod_command, static) = {
546 .path = "bfd udp session mod",
547 .short_help = "bfd udp session mod interface"
548 " <interface> local-addr"
549 " <local-address> peer-addr"
550 " <peer-address> desired-min-tx"
551 " <desired min tx interval> required-min-rx"
552 " <required min rx interval> detect-mult"
553 " <detect multiplier> ",
554 .function = bfd_cli_udp_session_mod,
558 static clib_error_t *
559 bfd_cli_udp_session_del (vlib_main_t * vm, unformat_input_t * input,
560 CLIB_UNUSED (vlib_cli_command_t * lmd))
562 clib_error_t *ret = NULL;
563 #define foreach_bfd_cli_udp_session_del_cli_param(F) \
564 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
565 unformat_vnet_sw_interface, &vnet_main) \
566 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
567 unformat_ip46_address) \
568 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
569 unformat_ip46_address)
571 foreach_bfd_cli_udp_session_del_cli_param (DECLARE);
573 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
575 int something_parsed = 0;
576 foreach_bfd_cli_udp_session_del_cli_param (UNFORMAT);
578 if (!something_parsed)
580 ret = clib_error_return (0, "Unknown input `%U'",
581 format_unformat_error, input);
586 foreach_bfd_cli_udp_session_del_cli_param (CHECK_MANDATORY);
588 vnet_api_error_t rv =
589 bfd_udp_del_session (sw_if_index, &local_addr, &peer_addr);
593 clib_error_return (0,
594 "`bfd_udp_del_session' API call failed, rv=%d:%U",
595 (int) rv, format_vnet_api_errno, rv);
604 VLIB_CLI_COMMAND (bfd_cli_udp_session_del_command, static) = {
605 .path = "bfd udp session del",
606 .short_help = "bfd udp session del interface"
607 " <interface> local-addr"
608 " <local-address> peer-addr"
610 .function = bfd_cli_udp_session_del,
614 static clib_error_t *
615 bfd_cli_udp_session_set_flags (vlib_main_t * vm, unformat_input_t * input,
616 CLIB_UNUSED (vlib_cli_command_t * lmd))
618 clib_error_t *ret = NULL;
619 #define foreach_bfd_cli_udp_session_set_flags_cli_param(F) \
620 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
621 unformat_vnet_sw_interface, &vnet_main) \
622 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
623 unformat_ip46_address) \
624 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
625 unformat_ip46_address) \
626 F (u8 *, admin_up_down_token, ADMIN_STR, mandatory, "%v", \
627 &admin_up_down_token)
629 foreach_bfd_cli_udp_session_set_flags_cli_param (DECLARE);
631 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
633 int something_parsed = 0;
634 foreach_bfd_cli_udp_session_set_flags_cli_param (UNFORMAT);
636 if (!something_parsed)
638 ret = clib_error_return (0, "Unknown input `%U'",
639 format_unformat_error, input);
644 foreach_bfd_cli_udp_session_set_flags_cli_param (CHECK_MANDATORY);
647 static const char up[] = "up";
648 static const char down[] = "down";
649 if (!memcmp (admin_up_down_token, up, sizeof (up) - 1))
653 else if (!memcmp (admin_up_down_token, down, sizeof (down) - 1))
660 clib_error_return (0, "Unrecognized value for `%s' parameter: `%v'",
661 ADMIN_STR, admin_up_down_token);
664 vnet_api_error_t rv = bfd_udp_session_set_flags (sw_if_index, &local_addr,
665 &peer_addr, admin_up_down);
669 clib_error_return (0,
670 "`bfd_udp_session_set_flags' API call failed, rv=%d:%U",
671 (int) rv, format_vnet_api_errno, rv);
680 VLIB_CLI_COMMAND (bfd_cli_udp_session_set_flags_command, static) = {
681 .path = "bfd udp session set-flags",
682 .short_help = "bfd udp session set-flags"
683 " interface <interface>"
684 " local-addr <local-address>"
685 " peer-addr <peer-address>"
687 .function = bfd_cli_udp_session_set_flags,
691 static clib_error_t *
692 bfd_cli_udp_session_auth_activate (vlib_main_t * vm, unformat_input_t * input,
693 CLIB_UNUSED (vlib_cli_command_t * lmd))
695 clib_error_t *ret = NULL;
696 #define foreach_bfd_cli_udp_session_auth_activate_cli_param(F) \
697 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
698 unformat_vnet_sw_interface, &vnet_main) \
699 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
700 unformat_ip46_address) \
701 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
702 unformat_ip46_address) \
703 F (u8 *, delayed_token, DELAYED_STR, optional, "%v") \
704 F (u32, conf_key_id, CONF_KEY_ID_STR, mandatory, "%u") \
705 F (u32, bfd_key_id, BFD_KEY_ID_STR, mandatory, "%u")
707 foreach_bfd_cli_udp_session_auth_activate_cli_param (DECLARE);
709 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
711 int something_parsed = 0;
712 foreach_bfd_cli_udp_session_auth_activate_cli_param (UNFORMAT);
714 if (!something_parsed)
716 ret = clib_error_return (0, "Unknown input `%U'",
717 format_unformat_error, input);
722 foreach_bfd_cli_udp_session_auth_activate_cli_param (CHECK_MANDATORY);
725 if (have_delayed_token)
727 static const char yes[] = "yes";
728 static const char no[] = "no";
729 if (!memcmp (delayed_token, yes, sizeof (yes) - 1))
733 else if (!memcmp (delayed_token, no, sizeof (no) - 1))
740 clib_error_return (0,
741 "Unrecognized value for `%s' parameter: `%v'",
742 DELAYED_STR, delayed_token);
747 if (have_bfd_key_id && bfd_key_id > 255)
749 ret = clib_error_return (0, "%s value `%u' out of range <1,255>",
750 BFD_KEY_ID_STR, bfd_key_id);
754 vnet_api_error_t rv =
755 bfd_udp_auth_activate (sw_if_index, &local_addr, &peer_addr, conf_key_id,
756 bfd_key_id, is_delayed);
760 clib_error_return (0,
761 "`bfd_udp_auth_activate' API call failed, rv=%d:%U",
762 (int) rv, format_vnet_api_errno, rv);
771 VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_activate_command, static) = {
772 .path = "bfd udp session auth activate",
773 .short_help = "bfd udp session auth activate"
774 " interface <interface>"
775 " local-addr <local-address>"
776 " peer-addr <peer-address>"
777 " conf-key-id <config key ID>"
778 " bfd-key-id <BFD key ID>"
779 " [ delayed <yes|no> ]",
780 .function = bfd_cli_udp_session_auth_activate,
783 static clib_error_t *
784 bfd_cli_udp_session_auth_deactivate (vlib_main_t *vm, unformat_input_t *input,
785 CLIB_UNUSED (vlib_cli_command_t *lmd))
787 clib_error_t *ret = NULL;
788 #define foreach_bfd_cli_udp_session_auth_deactivate_cli_param(F) \
789 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
790 unformat_vnet_sw_interface, &vnet_main) \
791 F (ip46_address_t, local_addr, LOCAL_ADDR_STR, mandatory, "%U", \
792 unformat_ip46_address) \
793 F (ip46_address_t, peer_addr, PEER_ADDR_STR, mandatory, "%U", \
794 unformat_ip46_address) \
795 F (u8 *, delayed_token, DELAYED_STR, optional, "%v")
797 foreach_bfd_cli_udp_session_auth_deactivate_cli_param (DECLARE);
799 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
801 int something_parsed = 0;
802 foreach_bfd_cli_udp_session_auth_deactivate_cli_param (UNFORMAT);
804 if (!something_parsed)
806 ret = clib_error_return (0, "Unknown input `%U'",
807 format_unformat_error, input);
812 foreach_bfd_cli_udp_session_auth_deactivate_cli_param (CHECK_MANDATORY);
815 if (have_delayed_token)
817 static const char yes[] = "yes";
818 static const char no[] = "no";
819 if (!memcmp (delayed_token, yes, sizeof (yes) - 1))
823 else if (!memcmp (delayed_token, no, sizeof (no) - 1))
829 ret = clib_error_return (
830 0, "Unrecognized value for `%s' parameter: `%v'", DELAYED_STR,
836 vnet_api_error_t rv = bfd_udp_auth_deactivate (sw_if_index, &local_addr,
837 &peer_addr, is_delayed);
840 ret = clib_error_return (
841 0, "`bfd_udp_auth_deactivate' API call failed, rv=%d:%U", (int)rv,
842 format_vnet_api_errno, rv);
851 VLIB_CLI_COMMAND (bfd_cli_udp_session_auth_deactivate_command, static) = {
852 .path = "bfd udp session auth deactivate",
853 .short_help = "bfd udp session auth deactivate"
854 " interface <interface>"
855 " local-addr <local-address>"
856 " peer-addr <peer-address>"
857 "[ delayed <yes|no> ]",
858 .function = bfd_cli_udp_session_auth_deactivate,
862 static clib_error_t *
863 bfd_cli_udp_set_echo_source (vlib_main_t * vm, unformat_input_t * input,
864 CLIB_UNUSED (vlib_cli_command_t * lmd))
866 clib_error_t *ret = NULL;
867 #define foreach_bfd_cli_udp_set_echo_source_cli_param(F) \
868 F (u32, sw_if_index, INTERFACE_STR, mandatory, "%U", \
869 unformat_vnet_sw_interface, &vnet_main)
871 foreach_bfd_cli_udp_set_echo_source_cli_param (DECLARE);
873 while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
875 int something_parsed = 0;
876 foreach_bfd_cli_udp_set_echo_source_cli_param (UNFORMAT);
878 if (!something_parsed)
880 ret = clib_error_return (0, "Unknown input `%U'",
881 format_unformat_error, input);
886 foreach_bfd_cli_udp_set_echo_source_cli_param (CHECK_MANDATORY);
888 vnet_api_error_t rv = bfd_udp_set_echo_source (sw_if_index);
892 clib_error_return (0,
893 "`bfd_udp_set_echo_source' API call failed, rv=%d:%U",
894 (int) rv, format_vnet_api_errno, rv);
903 VLIB_CLI_COMMAND (bfd_cli_udp_set_echo_source_cmd, static) = {
904 .path = "bfd udp echo-source set",
905 .short_help = "bfd udp echo-source set interface <interface>",
906 .function = bfd_cli_udp_set_echo_source,
910 static clib_error_t *
911 bfd_cli_udp_del_echo_source (vlib_main_t * vm, unformat_input_t * input,
912 CLIB_UNUSED (vlib_cli_command_t * lmd))
914 vnet_api_error_t rv = bfd_udp_del_echo_source ();
917 return clib_error_return (0,
918 "`bfd_udp_del_echo_source' API call failed, rv=%d:%U",
919 (int) rv, format_vnet_api_errno, rv);
926 VLIB_CLI_COMMAND (bfd_cli_udp_del_echo_source_cmd, static) = {
927 .path = "bfd udp echo-source del",
928 .short_help = "bfd udp echo-source del",
929 .function = bfd_cli_udp_del_echo_source,
934 * fd.io coding-style-patch-verification: ON
937 * eval: (c-set-style "gnu")