[Devel] [PATCH RH7] net: don't skip device_rename for non-root container netns

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Wed Feb 22 13:59:58 MSK 2023


This patch effectively reverts the commit:
b1c5e22266b5 ("ve/net: allow to rename devices in non-ve namespaces")

The patch says that it allows to rename devices, but instead it skips
call to device_rename for non-root netnses of the container. Ending up
with not renamed sysfs link for the renamed device. And if such
inconsistent device with different device name and sysfs name is moved
to root netns of container the systemd-udevd gets an event notification
about it with mixed names. Systemd obviousely does not expect this and
goes mad if at the same time old moved device name intersects with some
other device name in root netns of container, thus systemd disables this
other device (e.g. eth0 and breaks container network).

The original patch from vz6
diff-ve-net-allow-to-rename-devices-in-non-ve-namespaces
seems just to be a crutch for
diff-ve-vedev-dont-call-netdev_fixup_sysfs-if-device_add-was-not-called
so that sysfs entries of vedev don't break on netns creation.

But as we don't have the latter now we also don't need the former.

https://jira.sw.ru/browse/PSBM-145324

Signed-off-by: Pavel Tikhomirov <ptikhomirov at virtuozzo.com>
---
 net/core/dev.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/net/core/dev.c b/net/core/dev.c
index ec3e2d31c203..addd254c9c3c 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -1196,14 +1196,11 @@ int dev_change_name(struct net_device *dev, const char *newname)
 	}
 
 rollback:
-	if (!dev_net(dev)->owner_ve->ve_netns ||
-	    dev_net(dev)->owner_ve->ve_netns == dev->nd_net) {
-		ret = device_rename(&dev->dev, dev->name);
-		if (ret) {
-			memcpy(dev->name, oldname, IFNAMSIZ);
-			write_seqcount_end(&devnet_rename_seq);
-			return ret;
-		}
+	ret = device_rename(&dev->dev, dev->name);
+	if (ret) {
+		memcpy(dev->name, oldname, IFNAMSIZ);
+		write_seqcount_end(&devnet_rename_seq);
+		return ret;
 	}
 
 	write_seqcount_end(&devnet_rename_seq);
-- 
2.39.2



More information about the Devel mailing list