wireguard: add dos mitigation support
[vpp.git] / src / plugins / avf / avf_api.c
index 1ddc45f..05b4ead 100644 (file)
@@ -29,6 +29,7 @@
 #include <avf/avf.api_enum.h>
 #include <avf/avf.api_types.h>
 
+#define REPLY_MSG_ID_BASE (am->msg_id_base)
 #include <vlibapi/api_helper_macros.h>
 
 static void
@@ -52,10 +53,8 @@ vl_api_avf_create_t_handler (vl_api_avf_create_t * mp)
   rv = args.rv;
 
   /* *INDENT-OFF* */
-  REPLY_MACRO2 (VL_API_AVF_CREATE_REPLY + am->msg_id_base,
-    ({
-      rmp->sw_if_index = ntohl (args.sw_if_index);
-    }));
+  REPLY_MACRO2 (VL_API_AVF_CREATE_REPLY,
+               ({ rmp->sw_if_index = ntohl (args.sw_if_index); }));
   /* *INDENT-ON* */
 }
 
@@ -66,7 +65,6 @@ vl_api_avf_delete_t_handler (vl_api_avf_delete_t * mp)
   vnet_main_t *vnm = vnet_get_main ();
   avf_main_t *am = &avf_main;
   vl_api_avf_delete_reply_t *rmp;
-  avf_device_t *ad;
   vnet_hw_interface_t *hw;
   int rv = 0;
 
@@ -79,12 +77,11 @@ vl_api_avf_delete_t_handler (vl_api_avf_delete_t * mp)
       goto reply;
     }
 
-  ad = pool_elt_at_index (am->devices, hw->dev_instance);
-
-  avf_delete_if (vm, ad);
+  vlib_process_signal_event (vm, avf_process_node.index,
+                            AVF_PROCESS_EVENT_DELETE_IF, hw->dev_instance);
 
 reply:
-  REPLY_MACRO (VL_API_AVF_DELETE_REPLY + am->msg_id_base);
+  REPLY_MACRO (VL_API_AVF_DELETE_REPLY);
 }
 
 /* set tup the API message handling tables */
@@ -93,9 +90,13 @@ static clib_error_t *
 avf_plugin_api_hookup (vlib_main_t * vm)
 {
   avf_main_t *avm = &avf_main;
+  api_main_t *am = vlibapi_get_main ();
 
   /* ask for a correctly-sized block of API message decode slots */
   avm->msg_id_base = setup_message_id_table ();
+
+  vl_api_set_msg_thread_safe (am, avm->msg_id_base + VL_API_AVF_DELETE, 1);
+
   return 0;
 }