32 u8 switching_active = 0;
41 if ((bif->
mode == BOND_MODE_ACTIVE_BACKUP) && (i == 0) &&
51 if (i < bif->n_numa_slaves)
162 if (bif->
mode == BOND_MODE_ACTIVE_BACKUP)
190 bondif->
id = bif->
id;
199 bondif->
lb = bif->
lb;
206 *out_bondifs = r_bondifs;
213 u32 bond_sw_if_index)
251 *out_slaveifs = r_slaveifs;
278 sec_mac->
bytes, is_add);
323 if (bif->
mode == BOND_MODE_LACP)
342 u32 *sif_sw_if_index;
347 return VNET_API_ERROR_INVALID_SW_IF_INDEX;
386 args->
rv = VNET_API_ERROR_FEATURE_DISABLED;
390 if (args->
mode > BOND_MODE_LACP || args->
mode < BOND_MODE_ROUND_ROBIN)
392 args->
rv = VNET_API_ERROR_INVALID_ARGUMENT;
396 if (args->
lb > BOND_LB_L23)
398 args->
rv = VNET_API_ERROR_INVALID_ARGUMENT;
415 args->
rv = VNET_API_ERROR_INSTANCE_IN_USE;
422 if (bif->
mode == BOND_MODE_ROUND_ROBIN)
423 bif->
lb = BOND_LB_RR;
424 else if (bif->
mode == BOND_MODE_BROADCAST)
425 bif->
lb = BOND_LB_BC;
426 else if (bif->
mode == BOND_MODE_ACTIVE_BACKUP)
427 bif->
lb = BOND_LB_AB;
434 rnd = (
u32) (now * 1e6);
437 memcpy (args->
hw_addr + 2, &rnd, sizeof (rnd));
449 args->
rv = VNET_API_ERROR_INVALID_REGISTRATION;
496 args.
lb = BOND_LB_L2;
502 else if (((args.
mode == BOND_MODE_LACP) || (args.
mode == BOND_MODE_XOR))
503 &&
unformat (line_input,
"load-balance %U",
506 else if (
unformat (line_input,
"hw-addr %U",
509 else if (
unformat (line_input,
"id %u", &args.
id))
511 else if (
unformat (line_input,
"gso"))
513 else if (
unformat (line_input,
"numa-only"))
515 if (args.
mode == BOND_MODE_LACP)
519 "Only lacp mode supports numa-only so far!");
527 if (mode_is_set == 0)
541 .path =
"create bond",
542 .short_help =
"create bond mode {round-robin | active-backup | broadcast | " 543 "{lacp | xor} [load-balance { l2 | l23 | l34 } [numa-only]]} " 544 "[hw-addr <mac-address>] [id <if-id>] [gso]",
564 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
575 if (sw_if_index == ~0)
577 "please specify interface name or sw_if_index");
580 if (rv == VNET_API_ERROR_INVALID_SW_IF_INDEX)
591 .path =
"delete bond",
592 .short_help =
"delete bond {<interface> | sw_if_index <sw_idx>}",
613 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
620 args->
rv = VNET_API_ERROR_VALUE_EXIST;
627 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
634 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
639 if (bif->
mode == BOND_MODE_LACP)
649 if (args->
error != 0)
651 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
662 if (args->
error != 0)
664 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
736 if (bif->
mode == BOND_MODE_LACP)
767 "Error encountered on input feature arc enable");
791 else if (
unformat (line_input,
"passive"))
793 else if (
unformat (line_input,
"long-timeout"))
806 if (args.
group == ~0)
808 if (args.
slave == ~0)
819 .short_help =
"bond add <BondEthernetx> <slave-interface> " 820 "[passive] [long-timeout]",
834 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
871 if (args.
slave == ~0)
882 .short_help =
"bond del <slave-interface>",
894 "interface name",
"sw_if_index",
"mode",
895 "load balance",
"active slaves",
"slaves");
900 vlib_cli_output (vm,
"%-16U %-12d %-13U %-13U %-14u %u",
901 format_bond_interface_name, bif->dev_instance,
902 bif->sw_if_index, format_bond_mode, bif->mode,
903 format_bond_load_balance, bif->lb,
904 vec_len (bif->active_slaves), vec_len (bif->slaves));
919 vlib_cli_output (vm,
"%U", format_bond_interface_name, bif->dev_instance);
920 vlib_cli_output (vm,
" mode: %U",
921 format_bond_mode, bif->mode);
922 vlib_cli_output (vm,
" load balance: %U",
923 format_bond_load_balance, bif->lb);
925 vlib_cli_output (vm,
" gso enable");
926 if (bif->mode == BOND_MODE_ROUND_ROBIN)
927 vlib_cli_output (vm,
" last xmit slave index: %u",
928 bif->lb_rr_last_index);
929 vlib_cli_output (vm,
" number of active slaves: %d",
930 vec_len (bif->active_slaves));
931 vec_foreach (sw_if_index, bif->active_slaves)
933 vlib_cli_output (vm,
" %U", format_vnet_sw_if_index_name,
934 vnet_get_main (), *sw_if_index);
935 if (bif->mode == BOND_MODE_ACTIVE_BACKUP)
937 slave_if_t *sif = bond_get_slave_by_sw_if_index (*sw_if_index);
939 vlib_cli_output (vm,
" weight: %u, is_local_numa: %u, " 940 "sw_if_index: %u", sif->weight,
941 sif->is_local_numa, sif->sw_if_index);
947 vlib_cli_output (vm,
" %U", format_vnet_sw_if_index_name,
948 vnet_get_main (), *sw_if_index);
986 .short_help =
"show bond [details]",
1002 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
1009 args->
rv = VNET_API_ERROR_INVALID_INTERFACE;
1013 if (bif->
mode != BOND_MODE_ACTIVE_BACKUP)
1015 args->
rv = VNET_API_ERROR_INVALID_ARGUMENT;
1021 old_weight = sif->
weight;
1032 (sif->
weight >= old_weight)))
1046 u8 weight_enter = 0;
1055 if (
unformat (line_input,
"sw_if_index %d", &sw_if_index))
1060 else if (
unformat (line_input,
"weight %u", &weight))
1071 if (sw_if_index == (
u32) ~ 0)
1073 args.
rv = VNET_API_ERROR_INVALID_INTERFACE;
1076 if (weight_enter == 0)
1078 args.
rv = VNET_API_ERROR_INVALID_ARGUMENT;
1091 .path =
"set interface bond",
1092 .short_help =
"set interface bond <interface> | sw_if_index <idx>"
#define vec_validate(V, I)
Make sure vector is long enough for given index (no header, unspecified alignment) ...
static uword vnet_sw_interface_is_up(vnet_main_t *vnm, u32 sw_if_index)
int bond_dump_slave_ifs(slave_interface_details_t **out_slaveifs, u32 bond_sw_if_index)
#define vec_foreach_index(var, v)
Iterate over vector indices.
void bond_create_if(vlib_main_t *vm, bond_create_if_args_t *args)
static uword unformat_bond_mode(unformat_input_t *input, va_list *args)
#define hash_set(h, key, value)
#define hash_unset(h, key)
void ethernet_delete_interface(vnet_main_t *vnm, u32 hw_if_index)
mac_address_t * secondary_addrs
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)
vnet_interface_main_t interface_main
static bond_if_t * bond_get_master_by_sw_if_index(u32 sw_if_index)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
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)
static clib_error_t * bond_delete_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void bond_sort_slaves(bond_if_t *bif)
#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
void bond_detach_slave(vlib_main_t *vm, bond_detach_slave_args_t *args)
unformat_function_t unformat_vnet_sw_interface
#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).
format_function_t format_vnet_sw_if_index_name
bond_per_thread_data_t * per_thread_data
#define vec_reset_length(v)
Reset vector length to zero NULL-pointer tolerant.
static clib_error_t * bond_create_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vnet_sw_interface_t * vnet_get_hw_sw_interface(vnet_main_t *vnm, u32 hw_if_index)
#define clib_memcpy(d, s, n)
ethernet_main_t ethernet_main
vlib_node_registration_t bond_process_node
(constructor) VLIB_REGISTER_NODE (bond_process_node)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
vl_api_interface_index_t sw_if_index
static clib_error_t * detach_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_INIT_FUNCTION(x)
vnet_hw_interface_flags_t flags
#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...)
void bond_enslave(vlib_main_t *vm, bond_enslave_args_t *args)
#define ALWAYS_ASSERT(truth)
static void clib_spinlock_init(clib_spinlock_t *p)
#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 int bond_slave_sort(void *a1, void *a2)
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.
#define vec_del1(v, i)
Delete the element at index I.
#define LACP_SHORT_TIMOUT_TIME
static clib_error_t * show_bond_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void bond_slave_add_del_mac_addrs(bond_if_t *bif, u32 sif_sw_if_index, u8 is_add)
sll srl srl sll sra u16x4 i
static void bond_delete_neighbor(vlib_main_t *vm, bond_if_t *bif, slave_if_t *sif)
#define vec_free(V)
Free vector's memory (no header).
uword * bond_by_sw_if_index
void bond_disable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
#define ETHERNET_INTERFACE_FLAG_ACCEPT_ALL
BOND interface details struct.
#define VLIB_CLI_COMMAND(x,...)
uword * slave_by_sw_if_index
clib_error_t * stat_segment_deregister_state_counter(u32 index)
uword unformat_ethernet_address(unformat_input_t *input, va_list *args)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
static bond_if_t * bond_get_master_by_dev_instance(u32 dev_instance)
#define vec_insert_elts(V, E, N, M)
Insert N vector elements starting at element M, insert given elements (no header, unspecified alignme...
#define vec_append(v1, v2)
Append v2 after v1.
#define clib_bitmap_free(v)
Free a bitmap.
ethernet_interface_t * ethernet_get_interface(ethernet_main_t *em, u32 hw_if_index)
static clib_error_t * enslave_interface_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * bond_set_intf_cmd(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void show_bond(vlib_main_t *vm)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
clib_error_t * ethernet_register_interface(vnet_main_t *vnm, u32 dev_class_index, u32 dev_instance, const u8 *address, u32 *hw_if_index_return, ethernet_flag_change_function_t flag_change)
clib_error_t * vnet_hw_interface_set_flags(vnet_main_t *vnm, u32 hw_if_index, vnet_hw_interface_flags_t flags)
uword * port_number_bitmap
#define vec_sort_with_function(vec, f)
Sort a vector using the supplied element comparison function.
void bond_set_intf_weight(vlib_main_t *vm, bond_set_intf_weight_args_t *args)
vnet_sw_interface_t * sw_interfaces
static void show_bond_details(vlib_main_t *vm)
slave interface details struct
int bond_delete_if(vlib_main_t *vm, u32 sw_if_index)
static u32 random_u32(u32 *seed)
32-bit random number generator
void bond_enable_collecting_distributing(vlib_main_t *vm, slave_if_t *sif)
clib_error_t * vnet_sw_interface_set_flags(vnet_main_t *vnm, u32 sw_if_index, vnet_sw_interface_flags_t flags)
static vlib_thread_main_t * vlib_get_thread_main()
#define vec_foreach(var, vec)
Vector iterator.
int bond_dump_ifs(bond_interface_details_t **out_bondifs)
clib_error_t * bond_cli_init(vlib_main_t *vm)
clib_error_t * vnet_hw_interface_add_del_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address, u8 is_add)
clib_error_t * vnet_hw_interface_change_mac_address(vnet_main_t *vnm, u32 hw_if_index, const u8 *mac_address)
static slave_if_t * bond_get_slave_by_sw_if_index(u32 sw_if_index)
lacp_port_info_t actor_admin
#define CLIB_CACHE_LINE_BYTES
static_always_inline void clib_spinlock_lock_if_init(clib_spinlock_t *p)
clib_error_t * stat_segment_register_state_counter(u8 *name, u32 *index)
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)