Revert "Enforce FIB table creation before use"
[vpp.git] / src / vnet / interface_api.c
index 0731ab3..c19f0a8 100644 (file)
@@ -138,7 +138,7 @@ vl_api_sw_interface_set_mtu_t_handler (vl_api_sw_interface_set_mtu_t * mp)
 
 static void
 send_sw_interface_details (vpe_api_main_t * am,
-                          unix_shared_memory_queue_t * q,
+                          vl_api_registration_t * rp,
                           vnet_sw_interface_t * swif,
                           u8 * interface_name, u32 context)
 {
@@ -233,7 +233,7 @@ send_sw_interface_details (vpe_api_main_t * am,
   if (tag)
     strncpy ((char *) mp->tag, (char *) tag, ARRAY_LEN (mp->tag) - 1);
 
-  vl_msg_api_send_shmem (q, (u8 *) & mp);
+  vl_msg_api_send (rp, (u8 *) mp);
 }
 
 static void
@@ -242,11 +242,15 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp)
   vpe_api_main_t *am = &vpe_api_main;
   vnet_sw_interface_t *swif;
   vnet_interface_main_t *im = &am->vnet_main->interface_main;
+  vl_api_registration_t *rp;
 
-  unix_shared_memory_queue_t *q =
-    vl_api_client_index_to_input_queue (mp->client_index);
-  if (q == 0)
-    return;
+  rp = vl_api_client_index_to_registration (mp->client_index);
+
+  if (rp == 0)
+    {
+      clib_warning ("Client %d AWOL", mp->client_index);
+      return;
+    }
 
   u8 *filter = 0, *name = 0;
   if (mp->name_filter_valid)
@@ -268,7 +272,7 @@ vl_api_sw_interface_dump_t_handler (vl_api_sw_interface_dump_t * mp)
     if (filter && !strcasestr((char *) name, (char *) filter))
        continue;
 
-    send_sw_interface_details (am, q, swif, name, mp->context);
+    send_sw_interface_details (am, rp, swif, name, mp->context);
   }));
   /* *INDENT-ON* */
 
@@ -281,27 +285,38 @@ static void
   (vl_api_sw_interface_add_del_address_t * mp)
 {
   vlib_main_t *vm = vlib_get_main ();
+  vnet_main_t *vnm = vnet_get_main ();
   vl_api_sw_interface_add_del_address_reply_t *rmp;
   int rv = 0;
   u32 is_del;
+  clib_error_t *error = 0;
 
   VALIDATE_SW_IF_INDEX (mp);
 
   is_del = mp->is_add == 0;
+  vnm->api_errno = 0;
 
   if (mp->del_all)
     ip_del_all_interface_addresses (vm, ntohl (mp->sw_if_index));
   else if (mp->is_ipv6)
-    ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
-                                  (void *) mp->address,
-                                  mp->address_length, is_del);
+    error = ip6_add_del_interface_address (vm, ntohl (mp->sw_if_index),
+                                          (void *) mp->address,
+                                          mp->address_length, is_del);
   else
-    ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
-                                  (void *) mp->address,
-                                  mp->address_length, is_del);
+    error = ip4_add_del_interface_address (vm, ntohl (mp->sw_if_index),
+                                          (void *) mp->address,
+                                          mp->address_length, is_del);
+
+  if (error)
+    {
+      rv = vnm->api_errno;
+      clib_error_report (error);
+      goto done;
+    }
 
   BAD_SW_IF_INDEX_LABEL;
 
+done:
   REPLY_MACRO (VL_API_SW_INTERFACE_ADD_DEL_ADDRESS_REPLY);
 }
 
@@ -864,6 +879,7 @@ static void vl_api_sw_interface_set_mac_address_t_handler
   vl_api_sw_interface_set_mac_address_reply_t *rmp;
   vnet_main_t *vnm = vnet_get_main ();
   u32 sw_if_index = ntohl (mp->sw_if_index);
+  vnet_sw_interface_t *si;
   u64 mac;
   clib_error_t *error;
   int rv = 0;
@@ -877,7 +893,8 @@ static void vl_api_sw_interface_set_mac_address_t_handler
         | (u64) mp->mac_address[4] << (8 * 4)
         | (u64) mp->mac_address[5] << (8 * 5));
 
-  error = vnet_hw_interface_change_mac_address (vnm, sw_if_index, mac);
+  si = vnet_get_sw_interface (vnm, sw_if_index);
+  error = vnet_hw_interface_change_mac_address (vnm, si->hw_if_index, mac);
   if (error)
     {
       rv = VNET_API_ERROR_UNIMPLEMENTED;