Fix LISP map-request resend deadlock 77/3277/3
authorFlorin Coras <[email protected]>
Wed, 5 Oct 2016 13:05:34 +0000 (16:05 +0300)
committerDamjan Marion <[email protected]>
Wed, 5 Oct 2016 14:56:04 +0000 (14:56 +0000)
Change-Id: I2cc57079741279669241b88d0317853e1312e8c5
Signed-off-by: Florin Coras <[email protected]>
vnet/vnet/lisp-cp/control.c

index 579f4f3..166c533 100644 (file)
@@ -3562,14 +3562,17 @@ send_map_request_thread_fn (void *arg)
   map_request_args_t *a = arg;
   lisp_cp_main_t *lcm = vnet_lisp_cp_get_main ();
 
-  lisp_pending_map_request_lock (lcm);
-
   if (a->is_resend)
+    /* if resending, we already have the lock */
     resend_encapsulated_map_request (lcm, &a->seid, &a->deid, a->smr_invoked);
   else
-    send_encapsulated_map_request (lcm, &a->seid, &a->deid, a->smr_invoked);
+    {
+      /* get lock before sending map-request */
+      lisp_pending_map_request_lock (lcm);
+      send_encapsulated_map_request (lcm, &a->seid, &a->deid, a->smr_invoked);
+      lisp_pending_map_request_unlock (lcm);
+    }
 
-  lisp_pending_map_request_unlock (lcm);
 
   return 0;
 }