Re: [PATCH net-next v3 08/24] ovpn: introduce the ovpn_socket object

Sabrina Dubroca
2024-05-09T13:33:05Z

2024-05-08, 22:38:58 +0200, Antonio Quartulli wrote:
> On 08/05/2024 19:10, Sabrina Dubroca wrote:
> > 2024-05-06, 03:16:21 +0200, Antonio Quartulli wrote:
> > > diff --git a/drivers/net/ovpn/socket.c b/drivers/net/ovpn/socket.c
> > > new file mode 100644
> > > index 000000000000..a4a4d69162f0
> > > --- /dev/null
> > > +++ b/drivers/net/ovpn/socket.c
> > [...]
> > > +
> > > +/* Finalize release of socket, called after RCU grace period */
> >
> > kref_put seems to call ovpn_socket_release_kref without waiting, and
> > then that calls ovpn_socket_detach immediately as well. Am I missing
> > something?
>
> hmm what do we need to wait for exactly? (Maybe I am missing something)
> The ovpn_socket will survive a bit longer thanks to kfree_rcu.

The way I read this comment, it says that ovpn_socket_detach will be
called after one RCU grace period, but I don't see where that grace
period would come from.

ovpn_socket_put -> kref_put(release=ovpn_socket_release_kref) ->
ovpn_socket_release_kref -> ovpn_socket_detach

No grace period here.

Or am I misinterpreting the comment? There will be a grace period
caused by kfree_rcu before the ovpn_socket is actually freed, is that
what the comment means?

> > > +static void ovpn_socket_detach(struct socket *sock)
> > > +{
> > > + if (!sock)
> > > + return;
> > > +
> > > + sockfd_put(sock);
> > > +}
> >

--
Sabrina