api: verify message size on receipt
[vpp.git] / src / vnet / ip / ip_api.c
index f5ebd02..b1b7ff3 100644 (file)
@@ -514,7 +514,9 @@ vl_api_add_del_ip_punt_redirect_v2_t_handler (
     goto out;
 
   if (0 != n_paths)
-    vec_validate (rpaths, n_paths - 1);
+    {
+      vec_validate (rpaths, n_paths - 1);
+    }
 
   for (ii = 0; ii < n_paths; ii++)
     {
@@ -608,7 +610,7 @@ u32
 ip_table_get_unused_id (fib_protocol_t fproto)
 {
   int i, j;
-  u32 seed = random_default_seed ();
+  static u32 seed = 0;
   /* limit to 1M tries */
   for (j = 0; j < 1 << 10; j++)
     {
@@ -944,20 +946,14 @@ ip_table_create (fib_protocol_t fproto,
       fib_index = fib_table_find (fproto, table_id);
       mfib_index = mfib_table_find (fproto, table_id);
 
-      if (~0 == fib_index)
-       {
-         fib_table_find_or_create_and_lock_w_name (fproto, table_id,
-                                                   (is_api ?
-                                                    FIB_SOURCE_API :
-                                                    FIB_SOURCE_CLI), name);
-       }
-      if (~0 == mfib_index)
-       {
-         mfib_table_find_or_create_and_lock_w_name (fproto, table_id,
-                                                    (is_api ?
-                                                     MFIB_SOURCE_API :
-                                                     MFIB_SOURCE_CLI), name);
-       }
+      /*
+       * Always try to re-lock in case the fib was deleted by an API call
+       * but was not yet freed because some other locks were held
+       */
+      fib_table_find_or_create_and_lock_w_name (
+       fproto, table_id, (is_api ? FIB_SOURCE_API : FIB_SOURCE_CLI), name);
+      mfib_table_find_or_create_and_lock_w_name (
+       fproto, table_id, (is_api ? MFIB_SOURCE_API : MFIB_SOURCE_CLI), name);
 
       if ((~0 == fib_index) || (~0 == mfib_index))
        call_elf_section_ip_table_callbacks (vnm, table_id, 1 /* is_add */ ,
@@ -985,9 +981,8 @@ mroute_add_del_handler (u8 is_add,
     {
       if (is_add)
        {
-         mfib_entry_index =
-           mfib_table_entry_paths_update (fib_index, prefix,
-                                          MFIB_SOURCE_API, rpaths);
+         mfib_entry_index = mfib_table_entry_paths_update (
+           fib_index, prefix, MFIB_SOURCE_API, entry_flags, rpaths);
        }
       else
        {