Fix sending GARP/NA on Bonded Interface Active/Backup Link Up/Down

For bonded interface in Active/Backup mode (mode 1), we need to
send a GARP/NA packet, if IP address is present, on slave link
state change to up or down to help with route convergence. The
callback from DPDK happens in a separate thread so we need to make
sure RPC call is used to signal the send_garp_na process in the
main thread. Also need to fix DPDK polling so the slave links are
not polled.

Change-Id: If5fd8ea2d28c54dd28726ac403ad366386ce9651
Signed-off-by: John Lo <loj@cisco.com>
diff --git a/src/vlibmemory/memory_vlib.c b/src/vlibmemory/memory_vlib.c
index b6b8752..77959e6 100644
--- a/src/vlibmemory/memory_vlib.c
+++ b/src/vlibmemory/memory_vlib.c
@@ -1452,8 +1452,9 @@
   clib_warning ("unimplemented");
 }
 
-void
-vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
+always_inline void
+vl_api_rpc_call_main_thread_inline (void *fp, u8 * data, u32 data_length,
+				    u8 force_rpc)
 {
   vl_api_rpc_call_t *mp;
   api_main_t *am = &api_main;
@@ -1461,7 +1462,7 @@
   unix_shared_memory_queue_t *q;
 
   /* Main thread: call the function directly */
-  if (vlib_get_thread_index () == 0)
+  if ((force_rpc == 0) && (vlib_get_thread_index () == 0))
     {
       vlib_main_t *vm = vlib_get_main ();
       void (*call_fp) (void *);
@@ -1507,6 +1508,29 @@
   pthread_mutex_unlock (&q->mutex);
 }
 
+/*
+ * Check if called from worker threads.
+ * If so, make rpc call of fp through shmem.
+ * Otherwise, call fp directly
+ */
+void
+vl_api_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
+{
+  vl_api_rpc_call_main_thread_inline (fp, data, data_length,	/*force_rpc */
+				      0);
+}
+
+/*
+ * Always make rpc call of fp through shmem, useful for calling from threads
+ * not setup as worker threads, such as DPDK callback thread
+ */
+void
+vl_api_force_rpc_call_main_thread (void *fp, u8 * data, u32 data_length)
+{
+  vl_api_rpc_call_main_thread_inline (fp, data, data_length,	/*force_rpc */
+				      1);
+}
+
 static void
 vl_api_trace_plugin_msg_ids_t_handler (vl_api_trace_plugin_msg_ids_t * mp)
 {