From: [email protected]
On Fri, 07 Aug 2026 08:36:20 +0200, Antonio Quartulli <[email protected]> wrote:
> Hi Ralf,
>
> On 29/07/2026 12:21, Ralf Lici wrote:
> > ovpn queues several work items whose callbacks execute module text.
> > These works currently run on the global system workqueues, so module
> > exit has no driver-owned drain point that guarantees the callbacks have
> > fully returned before the module text can be freed.
> >
> > Object references protect the objects used by the callbacks, but they do
> > not prove that a workqueue function has returned. In particular, a
> > worker can drop the final reference that unblocks device teardown while
> > it is still executing ovpn code.
> >
> > Add a module-owned workqueue and queue all ovpn work items on it. During
> > module exit, unregister rtnl and netlink first, flush the workqueue so
> > ordinary ovpn workers finish, run the final RCU barrier, and destroy the
> > workqueue last. This keeps the workqueue available for cleanup work
> > queued from RCU callbacks, while ensuring no ovpn work item can outlive
> > the module text.
> >
> > The per-device delayed keepalive work remains explicitly disabled during
> > netdev teardown (disable_delayed_work_sync in ndo_uninit), since
> > flush_workqueue does not flush delayed work that is still only pending
> > on its timer.
> >
> > Fixes: 3ecfd9349f40 ("ovpn: implement keepalive mechanism")
> > Fixes: 11851cbd60ea ("ovpn: implement TCP transport")
> > Signed-off-by: Ralf Lici <[email protected]>
> > ---
> > Changes since v5
> > https://lore.kernel.org/openvpn-devel/d530ecfc3719845075fbddd0cd7c34752bc2ce16.1783336121.git.r...@mandelbit.com/
> > - Update the module-exit ordering for the queue_rcu_work-based key-slot
> > release: flush ordinary ovpn work before rcu_barrier, then destroy the
> > workqueue after RCU callbacks have queued their cleanup work.
> >
> > Changes since v4
> > https://lore.kernel.org/openvpn-devel/6edfcc51e0855bfd34286b86d4e7f26bb3bcd3f7.1783099626.git.r...@mandelbit.com/
> > - Rebase on the pending keepalive and TCP deferred-work refcount fixes,
> > preserving their hold-before-queue and queue-failure put handling when
> > converting schedule_work to queue_work.
> >
> > Changes since v3
> > https://lore.kernel.org/openvpn-devel/49f38f89340e18ed30543d3990a7a7e20595b6af.1783080055.git.r...@mandelbit.com/
> > - Replace the RCU-deferred peer netdev reference release with a
> > module-owned workqueue that drains all ovpn work callbacks before
> > module text can be freed.
> >
> > drivers/net/ovpn/main.c | 19 ++++++++++++++++++-
> > drivers/net/ovpn/ovpnpriv.h | 4 ++++
> > drivers/net/ovpn/peer.c | 8 ++++----
> > drivers/net/ovpn/tcp.c | 9 ++++-----
> > 4 files changed, 30 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/net/ovpn/main.c b/drivers/net/ovpn/main.c
> > index 5093a3b5aba6..80d10f9ef7d8 100644
> > --- a/drivers/net/ovpn/main.c
> > +++ b/drivers/net/ovpn/main.c
> > @@ -12,6 +12,7 @@
> > #include <linux/module.h>
> > #include <linux/netdevice.h>
> > #include <linux/inetdevice.h>
> > +#include <linux/workqueue.h>
> > #include <net/gro_cells.h>
> > #include <net/ip.h>
> > #include <net/rtnetlink.h>
> > @@ -26,6 +27,9 @@
> > #include "tcp.h"
> > #include "udp.h"
> >
> > +/* module-owned workqueue on which all ovpn-specific work is queued */
> > +struct workqueue_struct *ovpn_wq;
> > +
> > static void ovpn_priv_free(struct net_device *net)
> > {
> > struct ovpn_priv *ovpn = netdev_priv(net);
> > @@ -237,10 +241,16 @@ static int __init ovpn_init(void)
> >
> > ovpn_tcp_init();
> >
> > + ovpn_wq = alloc_workqueue("ovpn", 0, 0);
>
> This is triggering:
>
>
> workqueue: ovpn is using neither WQ_PERCPU or WQ_UNBOUND. Setting WQ_PERCPU.
> WARNING: kernel/workqueue.c:5852 at __alloc_workqueue+0x1cf5/0x2060,
> CPU#0: swapper/0/1
>
>
> Can you fix it and resend this patch only please?
>
Sure. Apparently the development tree used for this series predated
commit 21c05ca88a54 ("workqueue: Add warnings and ensure one among
WQ_PERCPU or WQ_UNBOUND is present"), which now warns when the selection
is implicit.
I'll resend this patch, explicitly selecting WQ_PERCPU to preserve the
existing workqueue behavior.
>
> Regards,
>
Regards,
--
Ralf Lici
Mandelbit Srl
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel