31 u8 switching_active = 0;
49 (bif->
mode == BOND_MODE_ACTIVE_BACKUP) && switching_active)
74 (bif->
mode == BOND_MODE_ACTIVE_BACKUP))
94 memset (bondif, 0,
sizeof (*bondif));
99 strlen ((
const char *) hi->
name)));
101 bondif->
lb = bif->
lb;
107 *out_bondifs = r_bondifs;
114 u32 bond_sw_if_index)
132 memset (slaveif, 0,
sizeof (*slaveif));
140 strlen ((
const char *) hi->
name)));
146 *out_slaveifs = r_slaveifs;
200 u32 *sif_sw_if_index;
206 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
215 for (i = 0; i <
vec_len (s_list); i++)
217 sif_sw_if_index = s_list[
i];
234 memset (bif, 0,
sizeof (*bif));
250 args->
rv = VNET_API_ERROR_FEATURE_DISABLED;
254 if (args->
mode > BOND_MODE_LACP || args->
mode < BOND_MODE_ROUND_ROBIN)
256 args->
rv = VNET_API_ERROR_INVALID_ARGUMENT;
260 if (args->
lb > BOND_LB_L23)
262 args->
rv = VNET_API_ERROR_INVALID_ARGUMENT;
267 memset (bif, 0,
sizeof (*bif));
273 if (bif->
mode == BOND_MODE_ROUND_ROBIN)
274 bif->
lb = BOND_LB_RR;
275 else if (bif->
mode == BOND_MODE_BROADCAST)
276 bif->
lb = BOND_LB_BC;
277 else if (bif->
mode == BOND_MODE_ACTIVE_BACKUP)
278 bif->
lb = BOND_LB_AB;
285 rnd = (
u32) (now * 1e6);
288 memcpy (args->
hw_addr + 2, &rnd, sizeof (rnd));
300 args->
rv = VNET_API_ERROR_INVALID_REGISTRATION;
333 args.
lb = BOND_LB_L2;
338 else if (((args.
mode == BOND_MODE_LACP) || (args.
mode == BOND_MODE_XOR))
339 &&
unformat (line_input,
"load-balance %U",
342 else if (
unformat (line_input,
"hw-addr %U",
351 if (mode_is_set == 0)
361 .path =
"create bond",
362 .short_help =
"create bond mode {round-robin | active-backup | broadcast | " 363 "{lacp | xor} [load-balance { l2 | l23 | l34 }]} [hw-addr <mac-address>]",
383 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
394 if (sw_if_index == ~0)
396 "please specify interface name or sw_if_index");
399 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
410 .path =
"delete bond",
411 .short_help =
"delete bond {<interface> | sw_if_index <sw_idx>}",
432 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
439 args->
rv = VNET_API_ERROR_VALUE_EXIST;
446 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
452 memset (sif, 0,
sizeof (*sif));
515 if (bif->
mode == BOND_MODE_LACP)
547 "Error encountered on input feature arc enable");
571 else if (
unformat (line_input,
"passive"))
573 else if (
unformat (line_input,
"long-timeout"))
586 if (args.
group == ~0)
588 if (args.
slave == ~0)
599 .short_help =
"bond add <BondEthernetx> <slave-interface> " 600 "[passive] [long-timeout]",
614 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
651 if (args.
slave == ~0)
662 .short_help =
"bond del <slave-interface>",
674 "interface name",
"sw_if_index",
"mode",
675 "load balance",
"active slaves",
"slaves");
680 vlib_cli_output (vm,
"%-16U %-12d %-13U %-13U %-14u %u",
681 format_bond_interface_name, bif->dev_instance,
682 bif->sw_if_index, format_bond_mode, bif->mode,
683 format_bond_load_balance, bif->lb,
684 vec_len (bif->active_slaves), vec_len (bif->slaves));
699 vlib_cli_output (vm,
"%U", format_bond_interface_name, bif->dev_instance);
700 vlib_cli_output (vm,
" mode: %U",
701 format_bond_mode, bif->mode);
702 vlib_cli_output (vm,
" load balance: %U",
703 format_bond_load_balance, bif->lb);
704 if (bif->mode == BOND_MODE_ROUND_ROBIN)
705 vlib_cli_output (vm,
" last xmit slave index: %u",
706 bif->lb_rr_last_index);
707 vlib_cli_output (vm,
" number of active slaves: %d",
708 vec_len (bif->active_slaves));
709 vec_foreach (sw_if_index, bif->active_slaves)
711 vlib_cli_output (vm,
" %U", format_vnet_sw_if_index_name,
712 vnet_get_main (), *sw_if_index);
717 vlib_cli_output (vm,
" %U", format_vnet_sw_if_index_name,
718 vnet_get_main (), *sw_if_index);
755 .short_help =
"show bond [details]",
#define vec_foreach_index(var, v)
Iterate over vector indices.
static uword unformat_bond_mode(unformat_input_t *input, va_list *args)
#define hash_set(h, key, value)
static void bond_delete_neighbor(vlib_main_t *vm, bond_if_t *bif, slave_if_t *sif)
static void show_bond_details(vlib_main_t *vm)
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
int bond_delete_if(vlib_main_t *vm, u32 sw_if_index)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)
#define hash_unset(h, key)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
vnet_main_t * vnet_get_main(void)
static vnet_hw_interface_t * vnet_get_sup_hw_interface(vnet_main_t *vnm, u32 sw_if_index)
static clib_error_t * detach_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vnet_interface_main_t interface_main
int bond_dump_ifs(bond_interface_details_t **out_bondifs)
static bond_if_t * bond_get_master_by_sw_if_index(u32 sw_if_index)
static f64 vlib_time_now(vlib_main_t *vm)
static_always_inline void clib_spinlock_unlock_if_init(clib_spinlock_t *p)
static vnet_hw_interface_t * vnet_get_hw_interface(vnet_main_t *vnm, u32 hw_if_index)
#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 uword * clib_bitmap_set(uword *ai, uword i, uword value)
Sets the ith bit of a bitmap to new_value Removes trailing zeros from the bitmap. ...
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
lacp_enable_disable_func lacp_enable_disable
unformat_function_t unformat_vnet_sw_interface
static clib_error_t * enslave_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VNET_HW_INTERFACE_FLAG_LINK_UP
#define vec_validate_aligned(V, I, A)
Make sure vector is long enough for given index (no header, specified alignment)
#define pool_get(P, E)
Allocate an object E from a pool P (unspecified alignment).
void bond_enable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
bond_per_thread_data_t * per_thread_data
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
static clib_error_t * show_bond_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
memset(h->entries, 0, sizeof(h->entries[0])*entries)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
#define VLIB_INIT_FUNCTION(x)
uword * active_slave_by_sw_if_index
void bond_enslave(vlib_main_t *vm, bond_enslave_args_t *args)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
static void clib_spinlock_init(clib_spinlock_t *p)
void ethernet_set_rx_redirect(vnet_main_t *vnm, vnet_hw_interface_t *hi, u32 enable)
static clib_error_t * bond_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define LACP_LONG_TIMOUT_TIME
vnet_device_class_t bond_dev_class
#define pool_elt_at_index(p, i)
Returns pointer to element at given index.
static void vlib_process_signal_event(vlib_main_t *vm, uword node_index, uword type_opaque, uword data)
static uword unformat_bond_load_balance(unformat_input_t *input, va_list *args)
u8 persistent_hw_address[6]
#define pool_put(P, E)
Free an object E in pool P.
vnet_sw_interface_flags_t flags
#define vec_del1(v, i)
Delete the element at index I.
#define LACP_SHORT_TIMOUT_TIME
static clib_error_t * bond_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void bond_detach_slave(vlib_main_t *vm, bond_detach_slave_args_t *args)
#define vec_free(V)
Free vector's memory (no header).
uword * bond_by_sw_if_index
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, u8 *mac_address)
#define clib_memcpy(a, b, c)
void bond_disable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
static void show_bond(vlib_main_t *vm)
BOND interface details struct.
#define VLIB_CLI_COMMAND(x,...)
uword * slave_by_sw_if_index
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void bond_create_if(vlib_main_t *vm, bond_create_if_args_t *args)
static bond_if_t * bond_get_master_by_dev_instance(u32 dev_instance)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
#define clib_bitmap_free(v)
Free a bitmap.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
uword * port_number_bitmap
vnet_sw_interface_t * sw_interfaces
int bond_dump_slave_ifs(slave_interface_details_t **out_slaveifs, u32 bond_sw_if_index)
slave interface details struct
static u32 random_u32(u32 *seed)
32-bit random number generator
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, u32 flags)
static slave_if_t * bond_get_slave_by_sw_if_index(u32 sw_if_index)
lacp_port_info_t actor_admin
clib_error_t * bond_cli_init(vlib_main_t *vm)
#define CLIB_CACHE_LINE_BYTES
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
int vnet_feature_enable_disable(const char *arc_name, const char *node_name, u32 sw_if_index, int enable_disable, void *feature_config, u32 n_feature_config_bytes)
bond_per_port_queue_t * per_port_queue
u32 ethernet_set_flags(vnet_main_t *vnm, u32 hw_if_index, u32 flags)