Sanitizing netif-rename code
PATCH 1/1 Sanitizing netif-rename code
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
Signature · 1 line
Matthias Schwarzott (zzam)
udev_device.c +6 -4
@@ -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 ); } }
-------------------------------------------------------------------------
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
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 3 lines · Matthias Schwarzott
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.
Thanks! I've applied it without the "else" after the "break".
Kay
-------------------------------------------------------------------------
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ÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 6 lines · Kay Sievers
Quoted 3 lines · Matthias Schwarzott
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.Thanks! I've applied it without the "else" after the "break".
This also fixes the "Udev sometimes forgets to RUN a program when renaming
network interface" bug I reported earlier. Thanks!
Signature · 11 lines
Alexander E. Patrakov ------------------------------------------------------------------------- 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ÞVDEV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel