Enforce FIB table creation before use
[vpp.git] / src / vnet / interface_api.c
index 45b472e..ee13135 100644 (file)
@@ -365,6 +365,14 @@ ip_table_bind (fib_protocol_t fproto,
   fib_source_t src;
   mfib_source_t msrc;
 
+  fib_index = fib_table_find (fproto, table_id);
+  mfib_index = mfib_table_find (fproto, table_id);
+
+  if (~0 == fib_index || ~0 == mfib_index)
+    {
+      return (VNET_API_ERROR_NO_SUCH_FIB);
+    }
+
   if (is_api)
     {
       src = FIB_SOURCE_API;
@@ -376,32 +384,6 @@ ip_table_bind (fib_protocol_t fproto,
       msrc = MFIB_SOURCE_CLI;
     }
 
-  /*
-   * This is temporary whilst I do the song and dance with the CSIT version
-   */
-  if (0 != table_id)
-    {
-      fib_index = fib_table_find_or_create_and_lock (fproto, table_id, src);
-      mfib_index =
-       mfib_table_find_or_create_and_lock (fproto, table_id, msrc);
-    }
-  else
-    {
-      fib_index = 0;
-      mfib_index = 0;
-    }
-
-  /*
-   * This if table does not exist = error is what we want in the end.
-   */
-  /* fib_index = fib_table_find (fproto, table_id); */
-  /* mfib_index = mfib_table_find (fproto, table_id); */
-
-  /* if (~0 == fib_index || ~0 == mfib_index) */
-  /*   { */
-  /*     return (VNET_API_ERROR_NO_SUCH_FIB); */
-  /*   } */
-
   if (FIB_PROTOCOL_IP6 == fproto)
     {
       /*
@@ -508,15 +490,6 @@ ip_table_bind (fib_protocol_t fproto,
       ip4_main.mfib_index_by_sw_if_index[sw_if_index] = mfib_index;
     }
 
-  /*
-   * Temporary. undo the locks from the find and create at the staart
-   */
-  if (0 != table_id)
-    {
-      fib_table_unlock (fib_index, fproto, src);
-      mfib_table_unlock (mfib_index, fproto, msrc);
-    }
-
   return (0);
 }
 
@@ -879,6 +852,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;
@@ -892,7 +866,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;