There is a potential deadlock between the thread destroying the ipf
and the clean thread as they are using the latch and the ipf lock in
the opposite order. The latch itself is thread-safe, so we should
not be holding the lock while setting it and waiting for the clean
thread that may be waiting for the lock.
Fixes: 4ea96698f667 ("Userspace datapath: Add fragmentation handling.")
Signed-off-by: Ilya Maximets <[email protected]>
---
Version 2:
* Split from the large patch.
Version 1:
*
https://patchwork.ozlabs.org/project/openvswitch/patch/[email protected]/
lib/ipf.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/ipf.c b/lib/ipf.c
index b16797312..a81d6728a 100644
--- a/lib/ipf.c
+++ b/lib/ipf.c
@@ -1374,11 +1374,12 @@ ipf_init(void)
void
ipf_destroy(struct ipf *ipf)
{
- ovs_mutex_lock(&ipf->ipf_lock);
latch_set(&ipf->ipf_clean_thread_exit);
pthread_join(ipf->ipf_clean_thread, NULL);
latch_destroy(&ipf->ipf_clean_thread_exit);
+ ovs_mutex_lock(&ipf->ipf_lock);
+
struct ipf_list *ipf_list;
HMAP_FOR_EACH_POP (ipf_list, node, &ipf->frag_lists) {
while (ipf_list->last_sent_idx < ipf_list->last_inuse_idx) {
--
2.51.0
_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev