All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Nicolas Dichtel <nicolas.dichtel@6wind.com>, netdev@vger.kernel.org
Cc: davem@davemloft.net, ebiederm@xmission.com, stephen@networkplumber.org
Subject: Re: [RFC PATCH net-next 1/5] netns: allocate netns ids
Date: Wed, 02 Jul 2014 17:33:09 +0400	[thread overview]
Message-ID: <53B40A15.3030603@cogentembedded.com> (raw)
In-Reply-To: <1404302346-4507-2-git-send-email-nicolas.dichtel@6wind.com>

Hello.

On 07/02/2014 03:59 PM, Nicolas Dichtel wrote:

> With this patch, netns allocates ids for all netns. Each netns has its own list
> of ids, it means that the id is valid only in the current netns.

> For homogeneity, an id is also allocated for the netns owner itself.

> Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
[...]

> diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
> index 85b62691f4f2..2976864cef13 100644
> --- a/net/core/net_namespace.c
> +++ b/net/core/net_namespace.c
> @@ -144,6 +144,30 @@ static void ops_free_list(const struct pernet_operations *ops,
>   	}
>   }
>
> +static int net_eq_idr(int id, void *net, void *peer)
> +{
> +	return net_eq(net, peer) ? id : 0;
> +}
> +
> +int net2id(struct net *net, struct net *peer)
> +{
> +	ASSERT_RTNL();
> +	return idr_for_each(&(net)->netns_ids, net_eq_idr, (peer)) ? : -ENOENT;

    I don't think the inner parens are needed, this is not a macro body...

> +}
> +
> +struct net *get_net_from_netnsid(struct net *net, int id)
> +{
> +	struct net *peer;
> +
> +	rcu_read_lock();
> +	peer = idr_find(&(net)->netns_ids, id);

    Same here.

> +	if (peer)
> +		get_net(peer);
> +	rcu_read_unlock();
> +
> +	return peer;
> +}
> +
>   /*
>    * setup_net runs the initializers for the network namespace object.
>    */
[...]

WBR, Sergei

  reply	other threads:[~2014-07-02 13:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-13 15:39 Problem with iflink in netns Stephen Hemminger
2014-05-13 18:20 ` Cong Wang
2014-05-13 20:05   ` Stephen Hemminger
2014-05-13 20:44     ` Cong Wang
2014-05-14  0:51       ` Stephen Hemminger
2014-05-14 21:11         ` Cong Wang
2014-05-14  8:23 ` Nicolas Dichtel
2014-07-02 11:59   ` [RFC PATCH net-next 0/5] netns: allow to identify peer netns Nicolas Dichtel
2014-07-02 11:59     ` [RFC PATCH net-next 1/5] netns: allocate netns ids Nicolas Dichtel
2014-07-02 13:33       ` Sergei Shtylyov [this message]
2014-07-02 13:57         ` Nicolas Dichtel
2014-07-02 11:59     ` [RFC PATCH net-next 2/5] netns: add genl cmd to get the id of a netns Nicolas Dichtel
2014-07-02 11:59     ` [RFC PATCH net-next 3/5] rtnl: add link netns id to interface messages Nicolas Dichtel
2014-07-02 11:59     ` [RFC PATCH net-next 4/5] iptunnels: advertise link netns via netlink Nicolas Dichtel
2014-07-02 11:59     ` [RFC PATCH net-next 5/5] rtnl: allow to create device with IFLA_LINK_NETNSID set Nicolas Dichtel
2014-07-02 20:09     ` [RFC PATCH net-next 0/5] netns: allow to identify peer netns Eric W. Biederman
2014-07-02 21:47       ` Nicolas Dichtel
2014-07-15 14:32       ` Nicolas Dichtel

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=53B40A15.3030603@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=ebiederm@xmission.com \
    --cc=netdev@vger.kernel.org \
    --cc=nicolas.dichtel@6wind.com \
    --cc=stephen@networkplumber.org \
    /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.