[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20150506114832.GF25248@pox.localdomain>
Date: Wed, 6 May 2015 13:48:32 +0200
From: Thomas Graf <tgraf@...g.ch>
To: Nicolas Dichtel <nicolas.dichtel@...nd.com>
Cc: netdev@...r.kernel.org, davem@...emloft.net, ebiederm@...ssion.com
Subject: Re: [PATCH net-next 4/6] netns: notify new nsid outside
__peernet2id()
On 05/06/15 at 11:58am, Nicolas Dichtel wrote:
> -static int __peernet2id(struct net *net, struct net *peer, bool alloc)
> +static int __peernet2id(struct net *net, struct net *peer, bool *alloc)
> {
> int id = idr_for_each(&net->netns_ids, net_eq_idr, peer);
> + bool alloc_it = *alloc;
>
> ASSERT_RTNL();
>
> + *alloc = false;
> +
> /* Magic value for id 0. */
> if (id == NET_ID_ZERO)
> return 0;
> if (id > 0)
> return id;
>
> - if (alloc) {
> + if (alloc_it) {
> id = alloc_netid(net, peer, -1);
> + *alloc = true;
> return id >= 0 ? id : NETNSA_NSID_NOT_ASSIGNED;
> }
>
> return NETNSA_NSID_NOT_ASSIGNED;
> }
Since you need the allocation behaviour from one call site only it
might be cleaner to add a __peernet2id_alloc() which is used from
the old __peernet2id() so you can call __peernet2id_alloc() from
peernet2id_alloc() and avoid putting these ugly bool alloc = false
in all other call sites.
Otherwise this looks good.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists