From: Matthias Schwarzott <zzam@gentoo.org>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] Sanitizing netif-rename code
Date: Tue, 23 Jan 2007 16:12:55 +0000 [thread overview]
Message-ID: <200701231712.56015.zzam@gentoo.org> (raw)
[-- 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
next reply other threads:[~2007-01-23 16:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-01-23 16:12 Matthias Schwarzott [this message]
2007-01-24 9:51 ` [PATCH] Sanitizing netif-rename code Kay Sievers
2007-01-24 11:58 ` Alexander E. Patrakov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200701231712.56015.zzam@gentoo.org \
--to=zzam@gentoo.org \
--cc=linux-hotplug@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).