diff options
author | Christian Brauner <christian.brauner@ubuntu.com> | 2020-02-27 04:37:19 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-02-26 20:07:26 -0800 |
commit | ef6a4c88e9e11bc32cd02b052d04745af9691412 (patch) | |
tree | 3047e1dc97e973e40c22babe7ba0d831307c0f00 /net/core/dev.c | |
parent | d755407d4444c3e0fbd7d7c3aa666d595e9ab217 (diff) | |
download | lwn-ef6a4c88e9e11bc32cd02b052d04745af9691412.tar.gz lwn-ef6a4c88e9e11bc32cd02b052d04745af9691412.zip |
net: fix sysfs permssions when device changes network namespace
Now that we moved all the helpers in place and make use netdev_change_owner()
to fixup the permissions when moving network devices between network
namespaces.
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/dev.c')
-rw-r--r-- | net/core/dev.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 4770dde3448d..dbbfff123196 100644 --- a/net/core/dev.c +++ b/net/core/dev.c @@ -10003,6 +10003,7 @@ EXPORT_SYMBOL(unregister_netdev); int dev_change_net_namespace(struct net_device *dev, struct net *net, const char *pat) { + struct net *net_old = dev_net(dev); int err, new_nsid, new_ifindex; ASSERT_RTNL(); @@ -10018,7 +10019,7 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char /* Get out if there is nothing todo */ err = 0; - if (net_eq(dev_net(dev), net)) + if (net_eq(net_old, net)) goto out; /* Pick the destination device name, and ensure @@ -10094,6 +10095,12 @@ int dev_change_net_namespace(struct net_device *dev, struct net *net, const char err = device_rename(&dev->dev, dev->name); WARN_ON(err); + /* Adapt owner in case owning user namespace of target network + * namespace is different from the original one. + */ + err = netdev_change_owner(dev, net_old, net); + WARN_ON(err); + /* Add the device back in the hashes */ list_netdevice(dev); |