api: fix mp-safe mark for some messages and add more 25/38525/2
authorVladislav Grishenko <themiron@yandex-team.ru>
Sat, 18 Mar 2023 21:57:01 +0000 (02:57 +0500)
committerOle Tr�an <otroan@employees.org>
Wed, 6 Sep 2023 08:34:33 +0000 (08:34 +0000)
Several api messages were not mp-safe although marked as such
because non-zero base id was not taken into account, and therefore
some other (from zero base id) were falsely mp-safe instead.

Keep messages as mp-safe, as they falsely were before:
    10   get_first_msg_id                              0       1
    12   api_versions                                  0       1

Messages that are no longer mp-safe as they weren't marked:
    15   sockclnt_create                               0       1
    33   proxy_arp_intfc_dump                          0       1

Fix messages to be really mp-safe:
    809  bridge_domain_dump                            0       1
    920  ip_route_add_del                              0       1
    921  ip_route_add_del_v2                           0       1
    1362 get_node_graph                                0       1
    1671 create_vhost_user_if                          0       1
    1675 create_vhost_user_if_v2                       0       1

Additionally mark messages as mp-safe, seems they need no barrier:
    1360 show_threads                                  0       1
    1370 show_version                                  0       1
    1372 show_vpe_system_time                          0       1

Type: fix
Change-Id: Ie6c1e3aa89f26bf51bfbcb7e7c4d9fee885487b7
Signed-off-by: Vladislav Grishenko <themiron@yandex-team.ru>
src/plugins/vhost/vhost_user_api.c
src/vlibmemory/memclnt_api.c
src/vlibmemory/vlib_api.c
src/vnet/ip/ip_api.c
src/vnet/l2/l2_api.c
src/vpp/api/api.c

index d522803..3b0840a 100644 (file)
@@ -335,15 +335,18 @@ static clib_error_t *
 vhost_user_api_hookup (vlib_main_t * vm)
 {
   api_main_t *am = vlibapi_get_main ();
-  /* Mark CREATE_VHOST_USER_IF as mp safe */
-  vl_api_set_msg_thread_safe (am, VL_API_CREATE_VHOST_USER_IF, 1);
-  vl_api_set_msg_thread_safe (am, VL_API_CREATE_VHOST_USER_IF_V2, 1);
 
   /*
    * Set up the (msg_name, crc, message-id) table
    */
   REPLY_MSG_ID_BASE = setup_message_id_table ();
 
+  /* Mark CREATE_VHOST_USER_IF as mp safe */
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_CREATE_VHOST_USER_IF, 1);
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_CREATE_VHOST_USER_IF_V2, 1);
+
   return 0;
 }
 
index 728edf7..7eb61fe 100644 (file)
@@ -190,6 +190,9 @@ vlib_api_init (void)
   foreach_vlib_api_msg;
 #undef _
 
+  /* Mark messages as mp safe */
+  vl_api_set_msg_thread_safe (am, VL_API_GET_FIRST_MSG_ID, 1);
+  vl_api_set_msg_thread_safe (am, VL_API_API_VERSIONS, 1);
   vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING, 1);
   vl_api_set_msg_thread_safe (am, VL_API_CONTROL_PING_REPLY, 1);
 
index 3d4f882..705e9c2 100644 (file)
@@ -340,7 +340,10 @@ vlib_apis_hookup (vlib_main_t *vm)
    */
   msg_id_base = setup_message_id_table ();
 
-  vl_api_set_msg_thread_safe (am, VL_API_GET_NODE_GRAPH, 1);
+  /* Mark messages as mp safe */
+  vl_api_set_msg_thread_safe (am, msg_id_base + VL_API_GET_NODE_GRAPH, 1);
+  vl_api_set_msg_thread_safe (am, msg_id_base + VL_API_SHOW_THREADS, 1);
+
   return 0;
 }
 
index 667ea4c..2c95897 100644 (file)
@@ -2133,17 +2133,21 @@ ip_api_hookup (vlib_main_t * vm)
   api_main_t *am = vlibapi_get_main ();
 
   /*
-   * Mark the route add/del API as MP safe
+   * Set up the (msg_name, crc, message-id) table
    */
-  vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL, 1);
-  vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_REPLY, 1);
-  vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_V2, 1);
-  vl_api_set_msg_thread_safe (am, VL_API_IP_ROUTE_ADD_DEL_V2_REPLY, 1);
+  REPLY_MSG_ID_BASE = setup_message_id_table ();
 
   /*
-   * Set up the (msg_name, crc, message-id) table
+   * Mark the route add/del API as MP safe
    */
-  REPLY_MSG_ID_BASE = setup_message_id_table ();
+  vl_api_set_msg_thread_safe (am, REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_ADD_DEL,
+                             1);
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_ADD_DEL_REPLY, 1);
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_ADD_DEL_V2, 1);
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_IP_ROUTE_ADD_DEL_V2_REPLY, 1);
 
   return 0;
 }
index cb22547..a06f7ff 100644 (file)
@@ -1312,14 +1312,15 @@ l2_api_hookup (vlib_main_t * vm)
 {
   api_main_t *am = vlibapi_get_main ();
 
-  /* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
-  vl_api_set_msg_thread_safe (am, VL_API_BRIDGE_DOMAIN_DUMP, 1);
-
   /*
    * Set up the (msg_name, crc, message-id) table
    */
   REPLY_MSG_ID_BASE = setup_message_id_table ();
 
+  /* Mark VL_API_BRIDGE_DOMAIN_DUMP as mp safe */
+  vl_api_set_msg_thread_safe (
+    am, REPLY_MSG_ID_BASE + VL_API_BRIDGE_DOMAIN_DUMP, 1);
+
   return 0;
 }
 
index 7b1b790..d14906a 100644 (file)
@@ -241,11 +241,18 @@ static void vl_api_##nn##_t_handler (                                   \
 static clib_error_t *
 vpe_api_hookup (vlib_main_t * vm)
 {
+  api_main_t *am = vlibapi_get_main ();
+
   /*
    * Set up the (msg_name, crc, message-id) table
    */
   msg_id_base = setup_message_id_table ();
 
+  /* Mark messages as mp safe */
+  vl_api_set_msg_thread_safe (am, msg_id_base + VL_API_SHOW_VERSION, 1);
+  vl_api_set_msg_thread_safe (am, msg_id_base + VL_API_SHOW_VPE_SYSTEM_TIME,
+                             1);
+
   return 0;
 }