Skip to contentSkip to conversation

Fix to have sysfs track rename of network devices

PATCH Mark Huth 2 participants 2 messages Aug 14, 2003 – Aug 15, 2003

Subsystems (2)
lore
Share & tools
lore

Mark Huth

author
#0 lore raw

Description:

When an Ethernet interface is renamed in the kernel via the ioctl SIOCSIFNAME, the sysfs directories /sys/class/net/ethX are not changed to the new name. This patch ensures sysfs is updated to the new name specified by the rename ioctl.

Thanks,
Mark Huth

net/core/dev.c +2 -0
diff -uNr linux-2.6.0-test3/net/core/dev.c linux-2.6.0-test3-fixifrename/net/core/dev.c
@@ -2345,9 +2345,11 @@
 				return -EBUSY;
 			if (__dev_get_by_name(ifr->ifr_newname))
 				return -EEXIST;
+			netdev_unregister_sysfs(dev);
 			memcpy(dev->name, ifr->ifr_newname, IFNAMSIZ);
 			dev->name[IFNAMSIZ - 1] = 0;
 			strlcpy(dev->class_dev.class_id, dev->name, BUS_ID_SIZE);
+			netdev_register_sysfs(dev);
 			notifier_call_chain(&netdev_chain,
 					    NETDEV_CHANGENAME, dev);
 			return 0;
#1 lore raw

Please don't use HTML encoded emails on this list. It makes you look like a bozo. :-)