Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 158963
b: refs/heads/master
c: 30ffee8
h: refs/heads/master
i:
  158961: b5fcd5c
  158959: b27a7ee
v: v3
  • Loading branch information
Johannes Berg authored and David S. Miller committed Jul 12, 2009
1 parent 7c724f0 commit 84124be
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 21 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 134e63756d5f3d0f7604dfcca847b09d1b14fd66
refs/heads/master: 30ffee8480c13fbcf8ab6c28e31f79dfff683117
2 changes: 2 additions & 0 deletions trunk/include/net/net_namespace.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,8 @@ static inline struct net *copy_net_ns(unsigned long flags, struct net *net_ns)

extern struct list_head net_namespace_list;

extern struct net *get_net_ns_by_pid(pid_t pid);

#ifdef CONFIG_NET_NS
extern void __put_net(struct net *net);

Expand Down
21 changes: 21 additions & 0 deletions trunk/net/core/net_namespace.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <linux/sched.h>
#include <linux/idr.h>
#include <linux/rculist.h>
#include <linux/nsproxy.h>
#include <net/net_namespace.h>
#include <net/netns/generic.h>

Expand Down Expand Up @@ -201,6 +202,26 @@ struct net *copy_net_ns(unsigned long flags, struct net *old_net)
}
#endif

struct net *get_net_ns_by_pid(pid_t pid)
{
struct task_struct *tsk;
struct net *net;

/* Lookup the network namespace */
net = ERR_PTR(-ESRCH);
rcu_read_lock();
tsk = find_task_by_vpid(pid);
if (tsk) {
struct nsproxy *nsproxy;
nsproxy = task_nsproxy(tsk);
if (nsproxy)
net = get_net(nsproxy->net_ns);
}
rcu_read_unlock();
return net;
}
EXPORT_SYMBOL_GPL(get_net_ns_by_pid);

static int __init net_ns_init(void)
{
struct net_generic *ng;
Expand Down
21 changes: 1 addition & 20 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <linux/security.h>
#include <linux/mutex.h>
#include <linux/if_addr.h>
#include <linux/nsproxy.h>

#include <asm/uaccess.h>
#include <asm/system.h>
Expand All @@ -52,6 +51,7 @@
#include <net/pkt_sched.h>
#include <net/fib_rules.h>
#include <net/rtnetlink.h>
#include <net/net_namespace.h>

struct rtnl_link
{
Expand Down Expand Up @@ -725,25 +725,6 @@ static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
[IFLA_INFO_DATA] = { .type = NLA_NESTED },
};

static struct net *get_net_ns_by_pid(pid_t pid)
{
struct task_struct *tsk;
struct net *net;

/* Lookup the network namespace */
net = ERR_PTR(-ESRCH);
rcu_read_lock();
tsk = find_task_by_vpid(pid);
if (tsk) {
struct nsproxy *nsproxy;
nsproxy = task_nsproxy(tsk);
if (nsproxy)
net = get_net(nsproxy->net_ns);
}
rcu_read_unlock();
return net;
}

static int validate_linkmsg(struct net_device *dev, struct nlattr *tb[])
{
if (dev) {
Expand Down

0 comments on commit 84124be

Please sign in to comment.