* [PATCH] Sanitizing netif-rename code
@ 2007-01-23 16:12 Matthias Schwarzott
2007-01-24 9:51 ` Kay Sievers
2007-01-24 11:58 ` Alexander E. Patrakov
0 siblings, 2 replies; 3+ messages in thread
From: Matthias Schwarzott @ 2007-01-23 16:12 UTC (permalink / raw)
To: linux-hotplug
[-- Attachment #1: Type: text/plain, Size: 859 bytes --]
Hi there!
The attached patch comes origins from this Bugreport:
http://bugs.gentoo.org/show_bug.cgi?id=158531
The original code from udev_device.c / function rename_netif looks like this:
while (loop--) {
retval = ioctl(sk, SIOCSIFNAME, &ifr);
if (retval != 0) {
if (errno != EEXIST) {
err("error changing net interface name %s to %s: %s",
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
break;
}
dbg("wait for netif '%s' to become free, loop=%i", udev->name, (30 * 20) -
loop);
usleep(1000 * 1000 / 20);
}
}
In some loop the rename-syscall will succeed, and retval is 0.
In this case the loop is not left, but just retried the loop and executing the
rename code over and over again.
Attached patch adds something similar to that (inside the loop):
if (retval == 0)
break;
Greetings
Matthias
--
Matthias Schwarzott (zzam)
[-- Attachment #2: udev-103-busywait.patch --]
[-- Type: text/x-diff, Size: 876 bytes --]
diff -Nur udev-103old/udev_device.c udev-103/udev_device.c
--- udev-103old/udev_device.c 2006-10-20 14:43:35.000000000 +0200
+++ udev-103/udev_device.c 2006-12-20 12:04:52.000000000 +0100
@@ -122,16 +122,18 @@
strlcpy(ifr.ifr_newname, udev->name, IFNAMSIZ);
loop = 30 * 20;
while (loop--) {
- retval = ioctl(sk, SIOCSIFNAME, &ifr);
- if (retval != 0) {
+ retval = ioctl(sk, SIOCSIFNAME, &ifr);
+ if (retval == 0) {
+ break;
+ } else {
if (errno != EEXIST) {
err("error changing net interface name %s to %s: %s",
ifr.ifr_name, ifr.ifr_newname, strerror(errno));
break;
}
- dbg("wait for netif '%s' to become free, loop=%i", udev->name, (30 * 20) - loop);
- usleep(1000 * 1000 / 20);
}
+ dbg("wait for netif '%s' to become free, loop=%i", udev->name, (30 * 20) - loop);
+ usleep(1000 * 1000 / 20);
}
}
[-- Attachment #3: Type: text/plain, Size: 347 bytes --]
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
[-- Attachment #4: Type: text/plain, Size: 226 bytes --]
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-01-24 11:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-23 16:12 [PATCH] Sanitizing netif-rename code Matthias Schwarzott
2007-01-24 9:51 ` Kay Sievers
2007-01-24 11:58 ` Alexander E. Patrakov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).