X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Finterface_api.c;h=3b0c515f01394108e8361677a964d40e16fa0620;hb=c12eae73f;hp=4d5dab30f3801c83c5fc2db8498479ae7fc4008f;hpb=e0792fdff6a9cc141f1cb4c6c1d2ac478cf44ee2;p=vpp.git diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 4d5dab30f38..3b0c515f013 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -202,6 +202,8 @@ send_sw_interface_details (vpe_api_main_t * am, { vnet_hw_interface_t *hi = vnet_get_sup_hw_interface (am->vnet_main, swif->sw_if_index); + vnet_device_class_t *dev_class = + vnet_get_device_class (am->vnet_main, hi->dev_class_index); vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); clib_memset (mp, 0, sizeof (*mp)); @@ -245,6 +247,10 @@ send_sw_interface_details (vpe_api_main_t * am, strncpy ((char *) mp->interface_name, (char *) interface_name, ARRAY_LEN (mp->interface_name) - 1); + if (dev_class && dev_class->name) + strncpy ((char *) mp->interface_dev_type, (char *) dev_class->name, + ARRAY_LEN (mp->interface_dev_type) - 1); + /* Send the L2 address for ethernet physical intfcs */ if (swif->sup_sw_if_index == swif->sw_if_index && hi->hw_class_index == ethernet_hw_interface_class.index) @@ -352,9 +358,8 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp) if (mp->name_filter_valid) { - filter = - format (0, ".*%s", vl_api_string_len (&mp->name_filter), - vl_api_from_api_string (&mp->name_filter), 0); + filter = vl_api_from_api_to_vec (&mp->name_filter); + vec_add1 (filter, 0); /* Ensure it's a C string for strcasecmp() */ } char *strcasestr (char *, char *); /* lnx hdr file botch */ @@ -1237,74 +1242,30 @@ vl_api_create_subif_t_handler (vl_api_create_subif_t * mp) { vl_api_create_subif_reply_t *rmp; vnet_main_t *vnm = vnet_get_main (); - u32 sw_if_index = ~0; - int rv = 0; - u32 sub_id; - vnet_sw_interface_t *si; + u32 sub_sw_if_index = ~0; vnet_hw_interface_t *hi; - vnet_sw_interface_t template; - uword *p; - vnet_interface_main_t *im = &vnm->interface_main; - u64 sup_and_sub_key; - clib_error_t *error; + int rv = 0; VALIDATE_SW_IF_INDEX (mp); - si = vnet_get_sup_sw_interface (vnm, ntohl (mp->sw_if_index)); hi = vnet_get_sup_hw_interface (vnm, ntohl (mp->sw_if_index)); if (hi->bond_info == VNET_HW_INTERFACE_BOND_INFO_SLAVE) - { - rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED; - goto out; - } - - sw_if_index = si->sw_if_index; - sub_id = ntohl (mp->sub_id); - - sup_and_sub_key = ((u64) (sw_if_index) << 32) | (u64) sub_id; - - p = hash_get_mem (im->sw_if_index_by_sup_and_sub, &sup_and_sub_key); - if (p) - { - if (CLIB_DEBUG > 0) - clib_warning ("sup sw_if_index %d, sub id %d already exists\n", - sw_if_index, sub_id); - rv = VNET_API_ERROR_SUBIF_ALREADY_EXISTS; - goto out; - } - - clib_memset (&template, 0, sizeof (template)); - template.type = VNET_SW_INTERFACE_TYPE_SUB; - template.flood_class = VNET_FLOOD_CLASS_NORMAL; - template.sup_sw_if_index = sw_if_index; - template.sub.id = sub_id; - template.sub.eth.raw_flags = ntohl (mp->sub_if_flags); - template.sub.eth.outer_vlan_id = ntohs (mp->outer_vlan_id); - template.sub.eth.inner_vlan_id = ntohs (mp->inner_vlan_id); - - error = vnet_create_sw_interface (vnm, &template, &sw_if_index); - if (error) - { - clib_error_report (error); - rv = VNET_API_ERROR_SUBIF_CREATE_FAILED; - goto out; - } - - u64 *kp = clib_mem_alloc (sizeof (*kp)); - *kp = sup_and_sub_key; - - hash_set (hi->sub_interface_sw_if_index_by_id, sub_id, sw_if_index); - hash_set_mem (im->sw_if_index_by_sup_and_sub, kp, sw_if_index); + rv = VNET_API_ERROR_BOND_SLAVE_NOT_ALLOWED; + else + rv = vnet_create_sub_interface (ntohl (mp->sw_if_index), + ntohl (mp->sub_id), + ntohl (mp->sub_if_flags), + ntohs (mp->inner_vlan_id), + ntohs (mp->outer_vlan_id), + &sub_sw_if_index); BAD_SW_IF_INDEX_LABEL; -out: - /* *INDENT-OFF* */ REPLY_MACRO2(VL_API_CREATE_SUBIF_REPLY, ({ - rmp->sw_if_index = ntohl(sw_if_index); + rmp->sw_if_index = ntohl(sub_sw_if_index); })); /* *INDENT-ON* */ }