Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 66392
b: refs/heads/master
c: d8a5ec6
h: refs/heads/master
v: v3
  • Loading branch information
Eric W. Biederman authored and David S. Miller committed Oct 10, 2007
1 parent 0d67b57 commit a0eadb2
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ce286d327341295f58d89864d746a524287cfdf9
refs/heads/master: d8a5ec672768c3cf4d51d7a63fc071520afa1617
1 change: 1 addition & 0 deletions trunk/include/linux/if_link.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ enum
IFLA_LINKMODE,
IFLA_LINKINFO,
#define IFLA_LINKINFO IFLA_LINKINFO
IFLA_NET_NS_PID,
__IFLA_MAX
};

Expand Down
35 changes: 35 additions & 0 deletions trunk/net/core/rtnetlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#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 Down Expand Up @@ -727,19 +728,53 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = {
[IFLA_WEIGHT] = { .type = NLA_U32 },
[IFLA_OPERSTATE] = { .type = NLA_U8 },
[IFLA_LINKMODE] = { .type = NLA_U8 },
[IFLA_NET_NS_PID] = { .type = NLA_U32 },
};

static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX+1] = {
[IFLA_INFO_KIND] = { .type = NLA_STRING },
[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_pid(pid);
if (tsk) {
task_lock(tsk);
if (tsk->nsproxy)
net = get_net(tsk->nsproxy->net_ns);
task_unlock(tsk);
}
rcu_read_unlock();
return net;
}

static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm,
struct nlattr **tb, char *ifname, int modified)
{
int send_addr_notify = 0;
int err;

if (tb[IFLA_NET_NS_PID]) {
struct net *net;
net = get_net_ns_by_pid(nla_get_u32(tb[IFLA_NET_NS_PID]));
if (IS_ERR(net)) {
err = PTR_ERR(net);
goto errout;
}
err = dev_change_net_namespace(dev, net, ifname);
put_net(net);
if (err)
goto errout;
modified = 1;
}

if (tb[IFLA_MAP]) {
struct rtnl_link_ifmap *u_map;
struct ifmap k_map;
Expand Down

0 comments on commit a0eadb2

Please sign in to comment.