From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guillaume Nault Subject: Re: [PATCH net-next v2 04/16] l2tp: refactor tunnel lifetime handling wrt its socket Date: Mon, 12 Feb 2018 19:48:37 +0100 Message-ID: <20180212184837.GC1422@alphalink.fr> References: <1518430280-16671-1-git-send-email-jchapman@katalix.com> <1518430280-16671-5-git-send-email-jchapman@katalix.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: netdev@vger.kernel.org, kbuild-all@01.org To: James Chapman Return-path: Received: from zimbra.alphalink.fr ([217.15.80.77]:54905 "EHLO zimbra.alphalink.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754177AbeBLSsl (ORCPT ); Mon, 12 Feb 2018 13:48:41 -0500 Content-Disposition: inline In-Reply-To: <1518430280-16671-5-git-send-email-jchapman@katalix.com> Sender: netdev-owner@vger.kernel.org List-ID: On Mon, Feb 12, 2018 at 10:11:08AM +0000, James Chapman wrote: > Ensure that the tunnel's socket is always extant while the tunnel > object exists. Hold a ref on the socket until the tunnel is destroyed > and ensure that all tunnel destroy paths go through a common function > (l2tp_tunnel_delete). > > Since the tunnel's socket is now guaranteed to exist if the tunnel > exists, we no longer need to use sockfd_lookup via l2tp_sock_to_tunnel > to derive the tunnel from the socket since this is always > sk_user_data. > > The tunnel object gains a new closing flag which is protected by a > spinlock. The existing dead flag which is accessed using > test_and_set_bit APIs is no longer used so is removed. > > --- a/net/l2tp/l2tp_core.c > +++ b/net/l2tp/l2tp_core.c > @@ -193,6 +148,12 @@ static void l2tp_tunnel_sock_put(struct sock *sk) > return &tunnel->session_hlist[hash_32(session_id, L2TP_HASH_BITS)]; > } > > +void l2tp_tunnel_free(struct l2tp_tunnel *tunnel) > +{ > + sock_put(tunnel->sock); > + /* the tunnel is freed in the socket destructor */ > +} > + EXPORT_SYMBOL_GPL(l2tp_tunnel_free) is missing.