bond_interface_details_t *bondif = NULL;
/* *INDENT-OFF* */
- pool_foreach (bif, bm->interfaces,
+ pool_foreach (bif, bm->interfaces) {
vec_add2(r_bondifs, bondif, 1);
clib_memset (bondif, 0, sizeof (*bondif));
bondif->id = bif->id;
bondif->numa_only = bif->numa_only;
bondif->active_members = vec_len (bif->active_members);
bondif->members = vec_len (bif->members);
- );
+ }
/* *INDENT-ON* */
*out_bondifs = r_bondifs;
{
vnet_main_t *vnm = vnet_get_main ();
ethernet_interface_t *b_ei;
- mac_address_t *sec_mac;
+ ethernet_interface_address_t *sec_mac;
vnet_hw_interface_t *s_hwif;
b_ei = ethernet_get_interface (ðernet_main, bif->hw_if_index);
vec_foreach (sec_mac, b_ei->secondary_addrs)
vnet_hw_interface_add_del_mac_address (vnm, s_hwif->hw_if_index,
- sec_mac->bytes, is_add);
+ sec_mac->mac.bytes, is_add);
}
static void
void
bond_create_if (vlib_main_t * vm, bond_create_if_args_t * args)
{
+ vnet_eth_interface_registration_t eir = {};
bond_main_t *bm = &bond_main;
vnet_main_t *vnm = vnet_get_main ();
vnet_sw_interface_t *sw;
bond_if_t *bif;
- vnet_hw_interface_t *hw;
if ((args->mode == BOND_MODE_LACP) && bm->lacp_plugin_loaded == 0)
{
bif->mode = args->mode;
bif->gso = args->gso;
+ if (bif->lb == BOND_LB_L2)
+ bif->hash_func =
+ vnet_hash_function_from_name ("hash-eth-l2", VNET_HASH_FN_TYPE_ETHERNET);
+ else if (bif->lb == BOND_LB_L34)
+ bif->hash_func = vnet_hash_function_from_name ("hash-eth-l34",
+ VNET_HASH_FN_TYPE_ETHERNET);
+ else if (bif->lb == BOND_LB_L23)
+ bif->hash_func = vnet_hash_function_from_name ("hash-eth-l23",
+ VNET_HASH_FN_TYPE_ETHERNET);
+
// Adjust requested interface id
if (bif->id == ~0)
bif->id = bif->dev_instance;
args->hw_addr[1] = 0xfe;
}
memcpy (bif->hw_address, args->hw_addr, 6);
- args->error = ethernet_register_interface
- (vnm, bond_dev_class.index, bif->dev_instance /* device instance */ ,
- bif->hw_address /* ethernet address */ ,
- &bif->hw_if_index, 0 /* flag change */ );
- if (args->error)
- {
- args->rv = VNET_API_ERROR_INVALID_REGISTRATION;
- hash_unset (bm->id_used, bif->id);
- pool_put (bm->interfaces, bif);
- return;
- }
+ eir.dev_class_index = bond_dev_class.index;
+ eir.dev_instance = bif->dev_instance;
+ eir.address = bif->hw_address;
+ bif->hw_if_index = vnet_eth_register_interface (vnm, &eir);
sw = vnet_get_hw_sw_interface (vnm, bif->hw_if_index);
bif->sw_if_index = sw->sw_if_index;
bif->group = bif->sw_if_index;
bif->numa_only = args->numa_only;
- hw = vnet_get_hw_interface (vnm, bif->hw_if_index);
/*
* Add GSO and Checksum offload flags if GSO is enabled on Bond
*/
if (args->gso)
{
- hw->flags |= (VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO |
- VNET_HW_INTERFACE_FLAG_SUPPORTS_TX_L4_CKSUM_OFFLOAD);
+ vnet_hw_if_set_caps (vnm, bif->hw_if_index,
+ VNET_HW_IF_CAP_TCP_GSO |
+ VNET_HW_IF_CAP_TX_TCP_CKSUM |
+ VNET_HW_IF_CAP_TX_UDP_CKSUM);
}
if (vlib_get_thread_main ()->n_vlib_mains > 1)
clib_spinlock_init (&bif->lockp);
if (args.mode == BOND_MODE_LACP)
args.numa_only = 1;
else
- return clib_error_return (0,
- "Only lacp mode supports numa-only so far!");
+ {
+ unformat_free (line_input);
+ return clib_error_return (
+ 0, "Only lacp mode supports numa-only so far!");
+ }
}
else
- return clib_error_return (0, "unknown input `%U'",
- format_unformat_error, input);
+ {
+ unformat_free (line_input);
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
}
unformat_free (line_input);
clib_error_return (0, "bond interface cannot be added as member");
return;
}
- if (bif->gso && !(mif_hw->flags & VNET_HW_INTERFACE_FLAG_SUPPORTS_GSO))
+ if (bif->gso && !(mif_hw->caps & VNET_HW_IF_CAP_TCP_GSO))
{
args->rv = VNET_API_ERROR_INVALID_INTERFACE;
args->error =
"load balance", "active members", "members");
/* *INDENT-OFF* */
- pool_foreach (bif, bm->interfaces,
- ({
+ pool_foreach (bif, bm->interfaces)
+ {
vlib_cli_output (vm, "%-16U %-12d %-13U %-13U %-14u %u",
format_bond_interface_name, bif->dev_instance,
bif->sw_if_index, format_bond_mode, bif->mode,
format_bond_load_balance, bif->lb,
vec_len (bif->active_members), vec_len (bif->members));
- }));
+ }
/* *INDENT-ON* */
}
u32 *sw_if_index;
/* *INDENT-OFF* */
- pool_foreach (bif, bm->interfaces,
- ({
+ pool_foreach (bif, bm->interfaces)
+ {
vlib_cli_output (vm, "%U", format_bond_interface_name, bif->dev_instance);
vlib_cli_output (vm, " mode: %U",
format_bond_mode, bif->mode);
vlib_cli_output (vm, " interface id: %d", bif->id);
vlib_cli_output (vm, " sw_if_index: %d", bif->sw_if_index);
vlib_cli_output (vm, " hw_if_index: %d", bif->hw_if_index);
- }));
+ }
/* *INDENT-ON* */
}