mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonio Quartulli <antonio@openvpn.net>
To: Sabrina Dubroca <sd@queasysnail.net>
Cc: netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Donald Hunter <donald.hunter@gmail.com>,
	Shuah Khan <shuah@kernel.org>,
	ryazanov.s.a@gmail.com, Andrew Lunn <andrew+netdev@lunn.ch>,
	Simon Horman <horms@kernel.org>,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Xiao Liang <shaw.leon@gmail.com>,
	steffen.klassert@secunet.com, antony.antony@secunet.com,
	willemdebruijn.kernel@gmail.com, David Ahern <dsahern@kernel.org>,
	Andrew Lunn <andrew@lunn.ch>,
	Shuah Khan <skhan@linuxfoundation.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH net-next v19 00/26] Introducing OpenVPN Data Channel Offload
Date: Fri, 14 Feb 2025 14:54:20 +0100	[thread overview]
Message-ID: <507c0388-8ce4-47fa-90b3-b46ae170045a@openvpn.net> (raw)
In-Reply-To: <0c0de58a-4dac-4b3b-9fc5-2a58a145d5ab@openvpn.net>

On 13/02/2025 20:40, Antonio Quartulli wrote:
> On 13/02/2025 16:46, Sabrina Dubroca wrote:
>> 2025-02-13, 12:46:34 +0100, Antonio Quartulli wrote:
>>> On 13/02/2025 00:34, Sabrina Dubroca wrote:
>>>> Hello,
>>>>
>>>> 2025-02-11, 01:39:53 +0100, Antonio Quartulli wrote:
>>>>> All minor and major reported problems have been finally addressed.
>>>>> Big thanks to Sabrina, who took the time to guide me through
>>>>> converting the peer socket to an RCU pointer.
>>>>
>>>> Something is off (not sure if it's new to this version): if I use
>>>> test-tcp.sh to setup a set of interfaces and peers (I stop the test
>>>> just after setup to keep the environment alive), then remove all netns
>>>> with "ip -all netns delete", I expect all devices to go away, but they
>>>> don't. With debug messages enabled I'm seeing some activity from the
>>>> module ("tun0: sending keepalive to peer 3" and so on), and
>>>> ovpn_net_uninit/ovpn_priv_free never got called.
>>>
>>> I can reproduce it. If later I rmmod ovpn I then get all the 
>>> "Deleting peer"
>>> messages.
>>> So instances are not being purged on netns exit.
>>>
>>> Will dive into it.
>>
>> I think the socket holds a ref on the netns, so it's not getting
>> destroyed, simply "removed" from iproute's point of view. And the
>> socket isn't going away as long as it's used by a peer.
> 
> After a deep dive I was getting to the same conclusion:
> cleanup_net() is never invoked because we lack an invocation of put_net().
> sk_alloc() invokes get_net(), so this is the ref that is not being 
> released.
> 
>>
>> If I delete the peer(s) for the ovpn device and then the netns it was
>> in, the netns is fully removed, and the ovpn device is gone. Also no
>> issue if I delete the ovpn device before its netns, then everything is
>> destroyed as expected.
>>
>> I'm not sure that can be solved, as least under the current refcount
>> scheme.
> 
> I went back to v12 of the patchset (which is pre-refcount-restructuring) 
> and indeed the problem there doesn't exist.
> 
> However, it's unclear to me how in v12 the socket release was happening 
> upon netns delete. Who was triggering that? ovpn still needed to call 
> sockfd_put() in order to let it go.
> 
> Will investigate some more and think about a solution.
> 

I may have done something wrong, but today I tried again and I am 
reproducing this issue also on v8 + 6.11.

I am indeed wondering how it could have ever worked: if we don't delete 
the peer, we don't detach the socket, hence the following chain:

sockfd_put() -> sk_destructor() -> put_net()

does not happen.

Shouldn't we be notified somehow that the netns is going away?

For example in wireguard/device.c the socket is released in 
pernet_operations.pre_exit().

But pre_exit() is invoked in cleanup_net(), which is invoked ONLY if the 
net refcount has reached 0...but how can it be zero before the sockets 
have been released?

I must be missing something, because this seems to be a reference loop.


I'll keep digging..

Regards,


-- 
Antonio Quartulli
OpenVPN Inc.


  reply	other threads:[~2025-02-14 13:54 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-11  0:39 Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 01/26] net: introduce OpenVPN Data Channel Offload (ovpn) Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 02/26] ovpn: add basic netlink support Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 03/26] ovpn: add basic interface creation/destruction/management routines Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 04/26] ovpn: keep carrier always on for MP interfaces Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 05/26] ovpn: introduce the ovpn_peer object Antonio Quartulli
2025-02-11  0:39 ` [PATCH net-next v19 06/26] ovpn: introduce the ovpn_socket object Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 07/26] ovpn: implement basic TX path (UDP) Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 08/26] ovpn: implement basic RX " Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 09/26] ovpn: implement packet processing Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 10/26] ovpn: store tunnel and transport statistics Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 11/26] ipv6: export inet6_stream_ops via EXPORT_SYMBOL_GPL Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 12/26] ovpn: implement TCP transport Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 13/26] skb: implement skb_send_sock_locked_with_flags() Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 14/26] ovpn: add support for MSG_NOSIGNAL in tcp_sendmsg Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 15/26] ovpn: implement multi-peer support Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 16/26] ovpn: implement peer lookup logic Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 17/26] ovpn: implement keepalive mechanism Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 18/26] ovpn: add support for updating local UDP endpoint Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 19/26] ovpn: add support for peer floating Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 20/26] ovpn: implement peer add/get/dump/delete via netlink Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 21/26] ovpn: implement key add/get/del/swap " Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 22/26] ovpn: kill key and notify userspace in case of IV exhaustion Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 23/26] ovpn: notify userspace when a peer is deleted Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 24/26] ovpn: add basic ethtool support Antonio Quartulli
2025-02-11  0:40 ` [PATCH net-next v19 25/26] testing/selftests: add test tool and scripts for ovpn module Antonio Quartulli
2025-02-13  0:36   ` kernel test robot
2025-02-14  1:49   ` kernel test robot
2025-02-11  0:40 ` [PATCH net-next v19 26/26] mailmap: remove unwanted entry for Antonio Quartulli Antonio Quartulli
2025-02-12 23:34 ` [PATCH net-next v19 00/26] Introducing OpenVPN Data Channel Offload Sabrina Dubroca
2025-02-13 11:46   ` Antonio Quartulli
2025-02-13 15:46     ` Sabrina Dubroca
2025-02-13 19:40       ` Antonio Quartulli
2025-02-14 13:54         ` Antonio Quartulli [this message]
2025-02-14 14:00           ` Antonio Quartulli
2025-02-13 14:26 ` Sean Anderson
2025-02-13 19:46   ` Antonio Quartulli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=507c0388-8ce4-47fa-90b3-b46ae170045a@openvpn.net \
    --to=antonio@openvpn.net \
    --cc=akpm@linux-foundation.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=andrew@lunn.ch \
    --cc=antony.antony@secunet.com \
    --cc=donald.hunter@gmail.com \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=sd@queasysnail.net \
    --cc=shaw.leon@gmail.com \
    --cc=shuah@kernel.org \
    --cc=skhan@linuxfoundation.org \
    --cc=steffen.klassert@secunet.com \
    --cc=willemdebruijn.kernel@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®