Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 130893 - udev 090 - eth0 and eth1 ignore rules to swap their names
Summary: udev 090 - eth0 and eth1 ignore rules to swap their names
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High normal (vote)
Assignee: Greg Kroah-Hartman (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: udev-meta
  Show dependency tree
 
Reported: 2006-04-22 14:50 UTC by dswhite42
Modified: 2006-08-30 21:39 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
same for udev 079-r1 on AMD64 with linux-2.6.15-gentoo-r7 (Text File,4 bytes, text/plain)
2006-04-30 13:40 UTC, fred nijdam
Details

Note You need to log in before you can comment on or make changes to this bug.
Description dswhite42 2006-04-22 14:50:35 UTC
I have two NICs - a built-in motherboard NIC (identified as a "RealTek RTL8139") and a Netgear card (curiously identified as a "Lite-On 82c168 PNIC rev 32"). There also appears to be a 3rd "NIC" - my IEEE1394 port. These cards used to be, respectively, eth0, eth1, and eth2 but about 4 weeks ago they suddenly switched places and became eth2, eth0, and eth1 respectively.

Looking around, I traced the problem to udev, and after reading http://reactivated.net/writing_udev_rules.html#example-iface, I ran these commands:

--------------------------------------------------
> udevinfo -a -p /sys/class/net/eth0/ | grep address
    SYSFS{address}=="00:a0:cc:60:c8:43"

> udevinfo -a -p /sys/class/net/eth1/ | grep address
    SYSFS{address}=="00:50:8d:00:00:f4:a8:54"

> udevinfo -a -p /sys/class/net/eth2/ | grep address
    SYSFS{address}=="00:50:8d:f5:a8:54"
--------------------------------------------------

then created the file /etc/udev/rules.d/49-nic.rules with these rules:

--------------------------------------------------
# Force DSL connection to be "eth0" (udev default assignment: eth2)
# (DSL NIC = RealTek RTL8139)
KERNEL=="eth*", SYSFS{address}=="00:50:8d:f5:a8:54", NAME="eth0"

# Force LAN connection to be "eth1" (udev default assignment: eth0)
# (LAN NIC = Lite-On 82c168 PNIC rev 32)
KERNEL=="eth*", SYSFS{address}=="00:a0:cc:60:c8:43", NAME="eth1"

# Force 1394 connection to be "eth2" (default assignment: eth1)
# (1394 connection = IEEE-1394 IPv4 over 1394 Ethernet)
KERNEL=="eth*", SYSFS{address}=="00:50:8d:00:00:f4:a8:54", NAME="eth2"
--------------------------------------------------

This worked perfectly... for about 3 weeks. But some update that I've gotten in the last week or so (presumably to udev?) seems to be breaking things again. Once again eth0 and eth1 have swapped positions (eth2, the IEEE1394 interface, oddly stays the same).

I thought perhaps my /etc/udev/rules.d/49-nic.rules wasn't being read, so I deleted it and added my custom eth* rules to the top of /etc/udev/rules.d/50-udev.rules. But that didn't seem to make any difference.

Then after discovering the udevtest script, I gave it a try. Here's what I get:

--------------------------------------------------
> udevtest /class/net/eth0

main: looking at device '/class/net/eth0' from subsystem 'net'
wait_for_sysfs: file '/sys/class/net/eth0/address' appeared after 0 loops
udev_rules_get_name: rule applied, 'eth0' becomes 'eth1'
rename_net_if: changing net interface name from 'eth0' to 'eth1'
udev_device_event: renamed netif to 'eth1'
main: run: '/sbin/modprobe '
main: run: '/sbin/udev_run_devd net'
main: run: 'socket:/org/kernel/udev/monitor'

> udevtest /class/net/eth1

main: looking at device '/class/net/eth1' from subsystem 'net'
wait_for_sysfs: file '/sys/class/net/eth1/address' appeared after 0 loops
udev_rules_get_name: rule applied, 'eth1' becomes 'eth0'
rename_net_if: changing net interface name from 'eth1' to 'eth0'
udev_device_event: renamed netif to 'eth0'
main: run: '/sbin/modprobe '
main: run: '/sbin/udev_run_devd net'
main: run: 'socket:/org/kernel/udev/monitor'

> udevtest /class/net/eth2

main: looking at device '/class/net/eth2' from subsystem 'net'
wait_for_sysfs: file '/sys/class/net/eth2/address' appeared after 0 loops
udev_rules_get_name: rule applied, 'eth2' becomes 'eth2'
main: run: '/sbin/modprobe '
main: run: '/sbin/udev_run_devd net'
main: run: 'socket:/org/kernel/udev/monitor'
--------------------------------------------------

So if I'm reading this right, the rules ARE being processed and eth0 is supposed to be renamed to eth1 (and vice versa). So why is it not actually happening? Why does 00:50:8d:00:00:f4:a8:54 remain eth1, and 00:a0:cc:60:c8:43 remains eth0?

I'm running:

    * kernel 2.6.15-gentoo-r5
    * baselayout 1.12.0_pre18
    * portage 2.1_pre9-r2
    * udev 090

Standard info here:

Portage 2.1_pre9-r2 (default-linux/x86/2005.0, gcc-3.4.6, glibc-2.4-r1, 2.6.15-gentoo-r5 i686)
=================================================================
System uname: 2.6.15-gentoo-r5 i686 Intel(R) Pentium(R) 4 CPU 2.80GHz
Gentoo Base System version 1.12.0_pre18
dev-lang/python:     2.4.2-r1
sys-apps/sandbox:    1.2.17
sys-devel/autoconf:  2.13, 2.59-r7
sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2
sys-devel/binutils:  2.16.1-r2
sys-devel/libtool:   1.5.22
virtual/os-headers:  2.6.11-r5
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CBUILD="i686-pc-linux-gnu"
CFLAGS="-O3 -march=pentium4 -pipe -fomit-frame-pointer"
CHOST="i686-pc-linux-gnu"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3.4/env /usr/kde/3.4/share/config /usr/kde/3.4/shutdown /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/X11/xkb /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/eselect/compiler /etc/gconf /etc/revdep-rebuild /etc/terminfo /etc/env.d"
CXXFLAGS="-O3 -march=pentium4 -pipe -fomit-frame-pointer"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict"
GENTOO_MIRRORS="ftp://gentoo.mirrors.pair.com/ http://gentoo.mirrors.pair.com/ http://www.gtlib.cc.gatech.edu/pub/gentoo ftp://ftp.gtlib.cc.gatech.edu/pub/gentoo "
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.gentoo.org/gentoo-portage"
USE="X acl alsa apache2 apm arts avi berkdb bitmap-fonts cdr cli crypt cups curl dga directfb dri dvd dvdr eds emboss encode esd fbcon flash foomaticdb fortran gd gdbm ggi gif gnome gphoto2 gpm gstreamer gtk gtk2 imap imlib isdnlog java jpeg kde ldap libg++ libwww mad maildir matrox mbox mcal mikmod mmx motif mp3 mpeg mysql nas ncurses nls odbc ogg oggvorbis opengl oss pam pcre pdflib perl png ppds pppd python qt quicktime readline reflection samba sasl scanner sdl session snmp spell spl sse ssl tcltk tcpd tiff truetype truetype-fonts type1-fonts usb vorbis x86 xml xml2 xmms xorg xv zlib elibc_glibc input_devices_keyboard input_devices_mouse kernel_linux userland_GNU video_cards_mga video_cards_vesa video_cards_fbdev"
Unset:  ASFLAGS, CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LC_ALL, LDFLAGS, LINGUAS
Comment 1 dswhite42 2006-04-22 15:21:23 UTC
Some further notes:

1) I noticed this text during the boot process:

udevd-event[2528]: rename_net_if: error changing net interface name: File exists
udevd-event[2606]: rename_net_if: error changing net interface name: File exists
udevd-event[2746]: rename_net_if: error changing net interface name: File exists

This made me suspect that the reason eth0 couldn't be renamed to eth1 was that an eth1 device had already been created by the time these udev rules were being run.  And since something had already determined which NICs would be eth0, eth1, and eth2, I couldn't swap any of their names with each other.

2) To test this, I tried these modified udev rules:

KERNEL=="eth*", SYSFS{address}=="00:50:8d:f5:a8:54", NAME="neweth0"
KERNEL=="eth*", SYSFS{address}=="00:a0:cc:60:c8:43", NAME="neweth1"
KERNEL=="eth*", SYSFS{address}=="00:50:8d:00:00:f4:a8:54", NAME="neweth2"

Sure enough, when I rebooted, ifconfig showed neweth0, neweth1, and neweth2 instead of eth0, eth1, and eth2.  So I'm guessing something in the latest udev package is triggering an event that causes eth0, eth1, and eth2 to be created, which cannot be overwritten by my custom eth0, eth1 and eth2 assignments.

3) I tried these various settings of RC_COLDPLUG in /etc/conf.d/rc just to see if it would help.  

RC_COLDPLUG="yes"

RC_COLDPLUG="!net.eth*"

RC_COLDPLUG="no"

None of them made any difference - the problem still remains.
Comment 2 fred nijdam 2006-04-30 13:40:20 UTC
Created attachment 85855 [details]
same for udev 079-r1 on AMD64 with linux-2.6.15-gentoo-r7

see description. Nice thing is that indeed the rename for eth2 succeeds!
Comment 3 fred nijdam 2006-05-03 14:24:42 UTC
[ebuild   R   ] sys-fs/udev-087
setting udev_log="err" in udev.conf
comes up with a UDEV failure message -device in use-

sitching to init 1 and running nameif does the job.

Comment 4 Benoit Boissinot 2006-07-06 01:19:14 UTC
Probably fixed in 095 (from the Changelog):
"netif rename: optimistic loop for the name to become free"
Comment 5 Greg Kroah-Hartman (RETIRED) gentoo-dev 2006-08-30 21:34:31 UTC
Fixed in latest version of udev, please upgrade.
Comment 6 Greg Kroah-Hartman (RETIRED) gentoo-dev 2006-08-30 21:39:29 UTC
forgot to mark fixed...