l2tp: avoid using drain_workqueue in l2tp_pre_exit_net
authorJames Chapman <jchapman@katalix.com>
Fri, 23 Aug 2024 14:22:57 +0000 (15:22 +0100)
committerJakub Kicinski <kuba@kernel.org>
Tue, 27 Aug 2024 20:37:22 +0000 (13:37 -0700)
commit73d33bd063c4cfef3db17f9bec3d202928ed8631
tree233e222bc0b7052fa98eff2cd137fda7567be92b
parentaed7136a37148465dcc899b806584fe70fd4ae72
l2tp: avoid using drain_workqueue in l2tp_pre_exit_net

Recent commit fc7ec7f554d7 ("l2tp: delete sessions using work queue")
incorrectly uses drain_workqueue. The use of drain_workqueue in
l2tp_pre_exit_net is flawed because the workqueue is shared by all
nets and it is therefore possible for new work items to be queued
for other nets while drain_workqueue runs.

Instead of using drain_workqueue, use __flush_workqueue twice. The
first one will run all tunnel delete work items and any work already
queued. When tunnel delete work items are run, they may queue
new session delete work items, which the second __flush_workqueue will
run.

In l2tp_exit_net, warn if any of the net's idr lists are not empty.

Fixes: fc7ec7f554d7 ("l2tp: delete sessions using work queue")
Signed-off-by: James Chapman <jchapman@katalix.com>
Link: https://patch.msgid.link/20240823142257.692667-1-jchapman@katalix.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/l2tp/l2tp_core.c