X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Finterface_api.c;h=4d5dab30f3801c83c5fc2db8498479ae7fc4008f;hb=e0792fdff;hp=9a695ed5bdde21aca6b9e630a43351c3cb376e39;hpb=053204ab039d34a990ff0e14c32ce3b294fcce0e;p=vpp.git diff --git a/src/vnet/interface_api.c b/src/vnet/interface_api.c index 9a695ed5bdd..4d5dab30f38 100644 --- a/src/vnet/interface_api.c +++ b/src/vnet/interface_api.c @@ -68,6 +68,7 @@ _(SW_INTERFACE_GET_TABLE, sw_interface_get_table) \ _(SW_INTERFACE_SET_UNNUMBERED, sw_interface_set_unnumbered) \ _(SW_INTERFACE_CLEAR_STATS, sw_interface_clear_stats) \ _(SW_INTERFACE_TAG_ADD_DEL, sw_interface_tag_add_del) \ +_(SW_INTERFACE_ADD_DEL_MAC_ADDRESS, sw_interface_add_del_mac_address) \ _(SW_INTERFACE_SET_MAC_ADDRESS, sw_interface_set_mac_address) \ _(SW_INTERFACE_GET_MAC_ADDRESS, sw_interface_get_mac_address) \ _(CREATE_VLAN_SUBIF, create_vlan_subif) \ @@ -166,8 +167,10 @@ vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp) VALIDATE_SW_IF_INDEX (mp); for (i = 0; i < VNET_N_MTU; i++) - per_protocol_mtu[i] = ntohl (mp->mtu[i]); - + { + per_protocol_mtu[i] = ntohl (mp->mtu[i]); + clib_warning ("MTU %u", per_protocol_mtu[i]); + } vnet_sw_interface_set_protocol_mtu (vnm, sw_if_index, per_protocol_mtu); BAD_SW_IF_INDEX_LABEL; @@ -200,14 +203,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); - uint32_t if_name_len = strlen ((char *) interface_name); - u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index); - uint32_t tag_len = 0; - if (tag != NULL) - tag_len = strlen ((char *) tag); - vl_api_sw_interface_details_t *mp = - vl_msg_api_alloc (sizeof (*mp) + if_name_len + tag_len); - clib_memset (mp, 0, sizeof (*mp) + if_name_len + tag_len); + vl_api_sw_interface_details_t *mp = vl_msg_api_alloc (sizeof (*mp)); + clib_memset (mp, 0, sizeof (*mp)); mp->_vl_msg_id = ntohs (VL_API_SW_INTERFACE_DETAILS); mp->sw_if_index = ntohl (swif->sw_if_index); mp->sup_sw_if_index = ntohl (swif->sup_sw_if_index); @@ -245,6 +242,9 @@ send_sw_interface_details (vpe_api_main_t * am, mp->context = context; + strncpy ((char *) mp->interface_name, + (char *) interface_name, ARRAY_LEN (mp->interface_name) - 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) @@ -306,12 +306,9 @@ send_sw_interface_details (vpe_api_main_t * am, mp->i_sid = i_sid; } - char *p = (char *) &mp->interface_name; - p += - vl_api_to_api_string (if_name_len, (char *) interface_name, - (vl_api_string_t *) p); - if (tag != NULL) - vl_api_to_api_string (tag_len, (char *) tag, (vl_api_string_t *) p); + u8 *tag = vnet_get_sw_interface_tag (vnet_get_main (), swif->sw_if_index); + if (tag) + strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1); vl_api_send_msg (rp, (u8 *) mp); } @@ -356,7 +353,8 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp) if (mp->name_filter_valid) { filter = - format (0, "%s%c", vl_api_from_api_string (&mp->name_filter), 0); + format (0, ".*%s", vl_api_string_len (&mp->name_filter), + vl_api_from_api_string (&mp->name_filter), 0); } char *strcasestr (char *, char *); /* lnx hdr file botch */ @@ -884,13 +882,14 @@ static void vl_api_sw_interface_tag_add_del_t_handler if (mp->is_add) { - if (vl_api_from_api_string (&mp->tag)[0] == 0) + if (mp->tag[0] == 0) { rv = VNET_API_ERROR_INVALID_VALUE; goto out; } - tag = format (0, "%s%c", vl_api_from_api_string (&mp->tag), 0); + mp->tag[ARRAY_LEN (mp->tag) - 1] = 0; + tag = format (0, "%s%c", mp->tag, 0); vnet_set_sw_interface_tag (vnm, tag, sw_if_index); } else @@ -901,6 +900,34 @@ out: REPLY_MACRO (VL_API_SW_INTERFACE_TAG_ADD_DEL_REPLY); } +static void vl_api_sw_interface_add_del_mac_address_t_handler + (vl_api_sw_interface_add_del_mac_address_t * mp) +{ + vl_api_sw_interface_add_del_mac_address_reply_t *rmp; + vnet_main_t *vnm = vnet_get_main (); + u32 sw_if_index = ntohl (mp->sw_if_index); + vnet_hw_interface_t *hi; + clib_error_t *error; + int rv = 0; + + VALIDATE_SW_IF_INDEX (mp); + + /* for subifs, the MAC should be changed on the actual hw if */ + hi = vnet_get_sup_hw_interface (vnm, sw_if_index); + error = vnet_hw_interface_add_del_mac_address (vnm, hi->hw_if_index, + mp->addr, mp->is_add); + if (error) + { + rv = VNET_API_ERROR_UNIMPLEMENTED; + clib_error_report (error); + goto out; + } + + BAD_SW_IF_INDEX_LABEL; +out: + REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_MAC_ADDRESS_REPLY); +} + static void vl_api_sw_interface_set_mac_address_t_handler (vl_api_sw_interface_set_mac_address_t * mp) {