interface: callback to manage extra MAC addresses
[vpp.git] / src / vnet / interface_api.c
index 687f599..4d5dab3 100644 (file)
@@ -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)                         \
@@ -899,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)
 {