netlink: add IFLA_NET_NS to move interface to network namespace by nsid
Subsystems (2)
PATCH 5/6 netlink: add IFLA_NET_NS to move interface to network namespace by nsid
This corresponds exactly to IFLA_NET_NS_PID except it takes a nsid parameter instead of a pid.
--- include/linux/if_link.h | 1 + net/core/rtnetlink.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-)
include/linux/if_link.h +1 -0
@@ -80,6 +80,7 @@ enum#define IFLA_LINKINFO IFLA_LINKINFOIFLA_NET_NS_PID ,IFLA_IFALIAS , +IFLA_NET_NS , __IFLA_MAX };
net/core/rtnetlink.c +16 -0
@@ -718,6 +718,7 @@ const struct nla_policy ifla_policy[IFLA_MAX+1] = { [IFLA_LINKINFO] = { .type = NLA_NESTED }, [IFLA_NET_NS_PID] = { .type = NLA_U32 }, [IFLA_IFALIAS] = { .type = NLA_STRING, .len = IFALIASZ-1 }, + [IFLA_NET_NS] = { .type = NLA_U32 }, };static const struct nla_policy ifla_info_policy[IFLA_INFO_MAX +1 ] = {
@@ -779,6 +780,21 @@ static int do_setlink(struct net_device *dev, struct ifinfomsg *ifm, modified =1 ; } +if (tb[IFLA_NET_NS ]) { +struct net *net; + + net =__get_net_ns_by_id (nla_get_u32 (tb[IFLA_NET_NS ])); +if (net ==NULL ) { + err = -EINVAL ; + 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;
Signature · 1 line
1.5.4.4