From: Tom Parkin <tparkin@katalix.com>
To: Guillaume Nault <gnault@redhat.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>,
netdev@vger.kernel.org, g.nault@alphalink.fr,
Cong Wang <cong.wang@bytedance.com>,
Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp>,
Jakub Sitnicki <jakub@cloudflare.com>,
Eric Dumazet <edumazet@google.com>
Subject: Re: [Patch net 1/2] l2tp: convert l2tp_tunnel_list to idr
Date: Mon, 9 Jan 2023 09:55:06 +0000 [thread overview]
Message-ID: <20230109095506.GA29862@katalix.com> (raw)
In-Reply-To: <Y7nMo02WWWwoGmv0@debian>
[-- Attachment #1: Type: text/plain, Size: 1549 bytes --]
On Sat, Jan 07, 2023 at 20:48:51 +0100, Guillaume Nault wrote:
> On Thu, Jan 05, 2023 at 11:13:38AM -0800, Cong Wang wrote:
> > +int l2tp_tunnel_create(struct net *net, int fd, int version, u32 tunnel_id,
> > + u32 peer_tunnel_id, struct l2tp_tunnel_cfg *cfg,
> > + struct l2tp_tunnel **tunnelp)
> > {
> > struct l2tp_tunnel *tunnel = NULL;
> > int err;
> > enum l2tp_encap_type encap = L2TP_ENCAPTYPE_UDP;
> > + struct l2tp_net *pn = l2tp_pernet(net);
> >
> > if (cfg)
> > encap = cfg->encap;
> >
> > + spin_lock_bh(&pn->l2tp_tunnel_idr_lock);
> > + err = idr_alloc_u32(&pn->l2tp_tunnel_idr, NULL, &tunnel_id, tunnel_id,
> > + GFP_ATOMIC);
> > + if (err) {
> > + spin_unlock_bh(&pn->l2tp_tunnel_idr_lock);
> > + return err;
> > + }
> > + spin_unlock_bh(&pn->l2tp_tunnel_idr_lock);
>
> Why reserving the tunnel_id in l2tp_tunnel_create()? This function is
> supposed to just allocate a structure and pre-initialise some fields.
> The only cleanup required upon error after this call is to kfree() the
> new structure. So I can't see any reason to guarantee the id will be
> accepted by the future l2tp_tunnel_register() call.
>
> Looks like you could reserve the id at the beginning of
> l2tp_tunnel_register() instead. That'd avoid changing the API and thus
> the side effects on l2tp_{ppp,netlink}.c. Also we wouldn't need create
> l2tp_tunnel_remove().
>
FWIW I also think that'd make more sense, and leave callsites will
less tidyup to do on behalf of l2tp_core.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
next prev parent reply other threads:[~2023-01-09 10:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-05 19:13 [Patch net 0/2] l2tp: fix race conditions in l2tp_tunnel_register() Cong Wang
2023-01-05 19:13 ` [Patch net 1/2] l2tp: convert l2tp_tunnel_list to idr Cong Wang
2023-01-07 18:25 ` Saeed Mahameed
2023-01-07 19:48 ` Cong Wang
2023-01-07 19:48 ` Guillaume Nault
2023-01-09 9:55 ` Tom Parkin [this message]
2023-01-10 6:49 ` Cong Wang
2023-01-05 19:13 ` [Patch net 2/2] l2tp: close all race conditions in l2tp_tunnel_register() Cong Wang
2023-01-07 18:41 ` Saeed Mahameed
2023-01-07 19:52 ` Cong Wang
2023-01-10 1:36 ` Jakub Kicinski
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=20230109095506.GA29862@katalix.com \
--to=tparkin@katalix.com \
--cc=cong.wang@bytedance.com \
--cc=edumazet@google.com \
--cc=g.nault@alphalink.fr \
--cc=gnault@redhat.com \
--cc=jakub@cloudflare.com \
--cc=netdev@vger.kernel.org \
--cc=penguin-kernel@i-love.sakura.ne.jp \
--cc=xiyou.wangcong@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.