1249c05836b0ec37ebe7d72bdd7232408c5ba70a
[people/pmueller/ipfire-2.x.git] / src / patches / udev-096-netif_rename.patch
1 diff -Naur udev-096.org/udev_device.c udev-096/udev_device.c
2 --- udev-096.org/udev_device.c 2006-07-09 21:48:19.000000000 +0200
3 +++ udev-096/udev_device.c 2009-04-28 22:04:56.000000000 +0200
4 @@ -102,40 +102,8 @@
5 strlcpy(ifr.ifr_newname, udev->name, IFNAMSIZ);
6 retval = ioctl(sk, SIOCSIFNAME, &ifr);
7 if (retval != 0) {
8 - int loop;
9 -
10 - /* see if the destination interface name already exists */
11 - if (errno != EEXIST) {
12 - err("error changing netif name: %s", strerror(errno));
13 - goto exit;
14 - }
15 -
16 - /* free our own name, another process may wait for us */
17 - strlcpy(ifr.ifr_newname, udev->dev->kernel_name, IFNAMSIZ);
18 - strlcat(ifr.ifr_newname, "_rename", IFNAMSIZ);
19 - retval = ioctl(sk, SIOCSIFNAME, &ifr);
20 - if (retval != 0) {
21 - err("error changing netif name: %s", strerror(errno));
22 - goto exit;
23 - }
24 -
25 - /* wait 30 seconds for our target to become available */
26 - strlcpy(ifr.ifr_name, ifr.ifr_newname, IFNAMSIZ);
27 - strlcpy(ifr.ifr_newname, udev->name, IFNAMSIZ);
28 - loop = 30 * 20;
29 - while (loop--) {
30 - retval = ioctl(sk, SIOCSIFNAME, &ifr);
31 - if (retval != 0) {
32 - if (errno != EEXIST) {
33 - err("error changing net interface name: %s", strerror(errno));
34 - break;
35 - }
36 - dbg("wait for netif '%s' to become free, loop=%i", udev->name, (30 * 20) - loop);
37 - usleep(1000 * 1000 / 20);
38 - }
39 - }
40 + err("error changing netif name: %s", strerror(errno));
41 }
42 -
43 exit:
44 close(sk);
45 return retval;