16 #include <vpp/app/version.h> 27 ip46_address_t
addr, *addrs;
28 u8 n_addrs4, n_addrs6;
38 n_addrs4 = n_addrs6 = 0;
53 else if (
unformat (input,
"vr_id %u", &vr_id))
57 else if (
unformat (input,
"priority %u", &priority))
59 else if (
unformat (input,
"interval %u", &interval))
61 else if (
unformat (input,
"no_preempt"))
63 else if (
unformat (input,
"accept_mode"))
65 else if (
unformat (input,
"unicast"))
81 if (sw_if_index == ~0)
83 else if (!vr_id || vr_id > 0xff)
88 if (!priority || priority > 0xff)
90 else if (interval > 0xffff)
113 case VNET_API_ERROR_ENTRY_ALREADY_EXISTS:
118 case VNET_API_ERROR_INVALID_SRC_ADDRESS:
123 case VNET_API_ERROR_ADDRESS_NOT_FOUND_FOR_INTERFACE:
125 "VR IP addresses not configured on interface");
130 case VNET_API_ERROR_NO_SUCH_ENTRY:
157 .path =
"vrrp vr add",
159 "vrrp vr add <interface> [vr_id <n>] [ipv6] [priority <value>] [interval <value>] [no_preempt] [accept_mode] [unicast] [<ip_addr> ...]",
174 .path =
"vrrp vr del",
175 .short_help =
"vrrp vr del <interface> [vr_id <n>] [ipv6]",
193 else if (
unformat (input,
"sw_if_index %u", &sw_if_index))
202 if (sw_if_index && (sw_if_index != ~0) &&
203 (sw_if_index != vr->config.sw_if_index))
205 vlib_cli_output (vm,
"%U", format_vrrp_vr,
215 .path =
"show vrrp vr",
217 "show vrrp vr [(<intf_name>|sw_if_index <n>)]",
239 is_ipv6 = is_start = is_stop = 0;
246 else if (
unformat (input,
"vr_id %u", &vr_id))
259 if (is_start == is_stop)
261 else if (sw_if_index == ~0)
268 vr_key.
is_ipv6 = (is_ipv6 != 0);
276 case VNET_API_ERROR_INIT_FAILED:
297 ip46_address_t
addr, *addrs;
298 u8 n_addrs4, n_addrs6;
305 n_addrs4 = n_addrs6 = 0;
315 else if (
unformat (input,
"vr_id %u", &vr_id))
337 if (sw_if_index == ~0)
341 else if (n_addrs4 && (n_addrs6 || is_ipv6))
349 vr_key.
is_ipv6 = (is_ipv6 != 0);
357 case VNET_API_ERROR_INVALID_ARGUMENT:
360 case VNET_API_ERROR_RSRC_IN_USE:
363 case VNET_API_ERROR_INVALID_DST_ADDRESS:
380 .path =
"vrrp proto",
382 "vrrp proto (start|stop) (<intf_name>|sw_if_index <n>) vr_id <n> [ipv6]",
390 .path =
"vrrp peers",
392 "vrrp peers (<intf_name>|sw_if_index <n>) vr_id <n> [ipv6] <peer1_addr> [<peer2_addr> ...]",
426 else if (
unformat (input,
"vr_id %u", &vr_id))
430 else if (
unformat (input,
"track-index %u priority %u", &track_if_index,
433 vec_add2 (track_intfs, track_intf, 1);;
434 track_intf->sw_if_index = track_if_index;
441 if (sw_if_index == ~0)
443 else if (!vr_id || vr_id > 0xff)
445 else if (is_add == is_del)
463 track_intf->sw_if_index);
466 if (!track_intf->priority)
474 "than VR priority (%u)",
494 .path =
"vrrp vr track-if",
496 "vrrp vr track-if (add|del) (<intf_name>|sw_if_index <n>) vr_id <n> [ipv6] track-index <n> priority <n> [ track-index <n> priority <n> ...]",
int vrrp_vr_start_stop(u8 is_start, vrrp_vr_key_t *vr_key)
static clib_error_t * vrrp_peers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_main_t * vnet_get_main(void)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define vec_add2(V, P, N)
Add N elements to end of vector V, return pointer to new elements in P.
static clib_error_t * vrrp_vr_add_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int vrrp_vr_set_peers(vrrp_vr_key_t *vr_key, ip46_address_t *peers)
static clib_error_t * vrrp_show_vr_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * vrrp_vr_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * vrrp_proto_start_stop_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define clib_error_return(e, args...)
static clib_error_t * vrrp_vr_track_if_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static uword vnet_sw_interface_is_valid(vnet_main_t *vnm, u32 sw_if_index)
#define vec_free(V)
Free vector's memory (no header).
static clib_error_t * vrrp_vr_add_del_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd, u8 is_add)
#define VLIB_CLI_COMMAND(x,...)
int vrrp_vr_add_del(u8 is_add, vrrp_vr_config_t *vr_conf)
static vrrp_vr_t * vrrp_vr_lookup(u32 sw_if_index, u8 vr_id, u8 is_ipv6)
#define vec_foreach(var, vec)
Vector iterator.
ip46_address_t * vr_addrs
int vrrp_vr_tracking_ifs_add_del(vrrp_vr_t *vr, vrrp_vr_tracking_if_t *track_ifs, u8 is_add)
vl_api_interface_index_t sw_if_index