Won't continue arguing with a dev, but if udev and eudev are absolutely identical and unconnected to systemd , why do we have two?Leio wrote:This has been NEVER the case as of yet.Tony0945 wrote:Leio, thank you for correcting me. In the past, udev depended on systemd which was the impetus for the eudev fork.

I swap my eth[01]names, with a udev mac rule. Kernel doesn't care.krinn wrote:That's where and what trouble users the most, because they naturally tend to want re-use eth* naming ; and this is where they fail, as kernel will only accept a renaming to another interface not already taken.

Eudev isn't exactly a carbon copy of udev, but it does seem to follow it (uses udev sources with some tweaks, from what I remember)Tony0945 wrote:Won't continue arguing with a dev, but if udev and eudev are absolutely identical and unconnected to systemd , why do we have two?Leio wrote:This has been NEVER the case as of yet.Tony0945 wrote:Leio, thank you for correcting me. In the past, udev depended on systemd which was the impetus for the eudev fork.
Perhaps udev was going to become dependant on systemd or rumored to become dependent on systemd. I DO recall that at one time it was an independent program than later subsumed into systemd or scheduled or rumored to become so.
I greatly doubt that dev time was wasted in packaging and upgrading two identical packages with no difference but the name.
It does, i don't think they have change that.Anon-E-moose wrote:I swap my eth[01]names, with a udev mac rule. Kernel doesn't care.
Tony0945 wrote:Hu, I once had a Tyan server board that behaved unpredictably. ...
OK, so we have two confirmed instances of people who were inconvenienced by the classic logic.mv wrote:I had. It is simply a question of luck and other kernel options.
What do you consider "the majority of the Linux community"?Leio wrote:The majority of the Linux community has decided that the pros far outweigh the cons,
The problem of generating automated names based on physical attributes seems simple enough. udev does it with no configuration at all, by default. Yes, persisting state so that a user-chosen name would be used would be a user-space problem, as would guaranteeing that hardware changes (such as moving to a different slot) does not change the name. Picking "predictable" default names could be done in the kernel. Could you cite these discussions?mv wrote:If this would have been possible, they would have done it. But there were long discussions, and the conclusion was that problems of this complexity should be solved in userspace.and would have done something like "predictable interface names" right in the kernel
So udev gets a chance to see the card come up with its original name, compute a new name, and assign that new name before any other user process is aware the card has a name at all? No process other than udev ever gets to see or consider using the old name in any way? My understanding was that udev was not special in this regard. It becomes aware of the new card through the same mechanism as everyone else, at the same time as everyone else sees it. If other processes see the card come up, then yes, there is a race where they could try to use the original name, then udev renames it out from under them. That race applies even if udev never picks a colliding name.mv wrote:No, it is not racy. It becomes only racy if the userspace tool should have been misconfigured by attempting to use names (e.g. "eth[0-9]*") which the kernel is supposed to use.Hu wrote:Why rename in usermode, which we know is racy
The policy isn't complicated. It's an integer selector of mode (classic, MAC-based, topography based), applied to every device that gets a name. It doesn't require a call back to usermode. It doesn't track state in any way. It only chooses what goes into the initial name, using only data the kernel already has loaded. If automatic name mangling isn't sufficient for the user's needs, then a user-space program like udev would need to step in to assign explicit names.mv wrote:There is no reason to have complicated policies in kernel, especially if many natural policies (e.g. based on MAC or other data which makes the device unique enough on your system) should be easily changeable on boot. That's exactly what tools like udev were originally developed for (long before udev became part of systemd).Hu wrote:when you could do a kernel patch to let userspace set a policy
Code: Select all
# more /etc/systemd/network/*
::::::::::::::
/etc/systemd/network/90internet0.link
::::::::::::::
[Match]
MACAddress=00:1c:c0:d6:XX:XX
[Link]
Name=internet0
::::::::::::::
/etc/systemd/network/90lan0.link
::::::::::::::
[Match]
MACAddress=00:07:e9:1f:XX:XX
[Link]
Name=lan0
::::::::::::::
/etc/systemd/network/90lanW0.link
::::::::::::::
[Match]
MACAddress=00:07:e9:1f:XX:XX
[Link]
Name=lanW0Code: Select all
[ 15.135066] internet0: renamed from ip_vti0
[ 15.153392] systemd-udevd[2814]: Error changing net interface name 'tunl0' to 'internet0': File exists
[ 134.657906] systemd-udevd[6193]: Error changing net interface name 'tun0' to 'internet0': Device or resource busy
[ 134.657929] systemd-udevd[6193]: could not rename interface '8' from 'tun0' to 'internet0': Device or resource busy
[ 134.679800] systemd-udevd[6193]: Process 'net.sh internet0 start' failed with exit code 1.
[ 134.829273] systemd-udevd[6226]: Error changing net interface name 'tun1' to 'internet0': Device or resource busy
[ 134.829312] systemd-udevd[6226]: could not rename interface '9' from 'tun1' to 'internet0': Device or resource busy
[ 15.152236] internet0: renamed from sit0
[ 15.183288] systemd-udevd[2830]: Error changing net interface name 'tunl0' to 'internet0': File exists
[ 15.183313] systemd-udevd[2822]: Error changing net interface name 'ip_vti0' to 'internet0': File exists
[ 86.582327] systemd-udevd[6545]: Error changing net interface name 'tun0' to 'internet0': File exists
[ 86.582350] systemd-udevd[6545]: could not rename interface '8' from 'tun0' to 'internet0': File exists
[ 86.594486] systemd-udevd[6545]: Process 'net.sh internet0 start' failed with exit code 1.
[ 86.760273] systemd-udevd[6577]: Error changing net interface name 'tun1' to 'internet0': Device or resource busy
[ 86.760322] systemd-udevd[6577]: could not rename interface '9' from 'tun1' to 'internet0': Device or resource busy
[ 86.773674] systemd-udevd[6577]: Process 'net.sh internet0 start' failed with exit code 1.
Code: Select all
# ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 73.XXX.XXX.XXX netmask 255.255.254.0 broadcast 255.255.255.255
inet6 fe80::21c:c0ff:fed6:fce2 prefixlen 64 scopeid 0x20<link>
ether 00:1c:c0:d6:XX:XX txqueuelen 1000 (Ethernet)
RX packets 4999 bytes 1927347 (1.8 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 5218 bytes 1018099 (994.2 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0Yes, as with most races, it is highly unlikely that you get in trouble. (That's why the race was not detected/cared about by ancient udev for years). However, it is a race, and whether you get bitten by it is a matter of luck. On some systems it might happen often and on other systems practically never.Anon-E-moose wrote:I swap my eth[01]names, with a udev mac rule. Kernel doesn't care.
Not only then. The scenarios you have drawn does not describe the race:krinn wrote:Still clash may appears if you lack a rule for a card
It's the whole discussion about devfs vs. udev: Make simple heuristic rules in kernel or arbitrarily configurable rules in userspace or some half-hearted compromise.Hu wrote:Could you cite these discussions?
Surprise, surprise, it is possible to shoot yourself in your foot if you want to.If other processes see the card come up, then yes, there is a race
Greetings Gentoo-ers.mv wrote:Yes, as with most races, it is highly unlikely that you get in trouble. (That's why the race was not detected/cared about by ancient udev for years). However, it is a race, and whether you get bitten by it is a matter of luck. On some systems it might happen often and on other systems practically never.Anon-E-moose wrote:I swap my eth[01]names, with a udev mac rule. Kernel doesn't care.Not only then. The scenarios you have drawn does not describe the race:krinn wrote:Still clash may appears if you lack a rule for a card
1. kernel sees eth0 which udev is supposed to rename to eth1.
2. before udev can do the renaming, kernel announces eth1.
3. The attempt of udev to rename to eth1 fails.
Code: Select all
[Wed Sep 11 17:43:12 2019] udevd[58]: starting version 181
[Wed Sep 11 17:43:15 2019] udevd[176]: starting version 181
[Wed Sep 11 17:43:16 2019] udevd[181]: renamed network interface eth0 to rename2
[Wed Sep 11 17:43:16 2019] udevd[184]: renamed network interface eth1 to eth0
[Wed Sep 11 17:43:16 2019] udevd[181]: renamed network interface rename2 to eth1Code: Select all
[ 12.605789] udevd[711]: starting version 3.2.5
[ 12.675801] udevd[712]: starting eudev-3.2.5
[ 15.262743] udevd[743]: Error changing net interface name eth0 to eth1: File exists
[ 15.262810] udevd[743]: could not rename interface '2' from 'eth0' to 'eth1': File exists
[ 15.320907] udevd[746]: Error changing net interface name eth1 to eth0: File exists
[ 15.320982] udevd[746]: could not rename interface '3' from 'eth1' to 'eth0': File existsSorry for digging it up – I've really been wrestling with this issue (which should be a complete *non*-issue for over a day now, and this thread came up as the most enlightened/relevant conversation.krinn wrote: Another possible scenario might be that the renaming happens between the kernel determining the new name eth1 and creating the device (I am not sure whether some preemptive model allows this; I am also not sure what the kernel does in this case; in any case, I wouldn't want to risk.)
Code: Select all
modprobe e1000
service net.eth1 start
Code: Select all
$ cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="a1:b3:c1:00:ba:6c", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"
# PCI device 0x10ec:0x8168 (r8169)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="09:64:6e:87:a3:cd", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"That would be too late in the process for me, as the local scripts start after firewall, et al.Tony0945 wrote:Just left the intel driver out of conf.d/modules then loaded it in /etc/local.d/000.start. IIRC, /etc/init.d/net.eth1 was already waiting.
If that doesn't work, try:in 000.startCode: Select all
modprobe e1000 service net.eth1 start
Since both of your NIC's use the same driver, use (e)udev rules based on MAC address.
BTW: I tried Eth0 and Eth1. Didn't work, appears the capital letters aren't legal.
I think you can use nic0, nic1 . I know lan0, lan1 works.

I've heard of name space collision, but never personally seen it. I would try it and see if it works rather than basing it on someone elses opinion.Drag0nFly wrote:Which udev variant (and version) are you using? Renaming interfaces based on mac addr (to eth*) does not work with the later udev versions due to namespaceAnon-E-moose wrote:I have 2 network cards in my box, both 8169, I set names by mac addr.
collision.
Code: Select all
$ grep -i eth /var/log/dmesg
[ 1.337698] r8169 0000:03:00.0 eth0: RTL8168e/8111e, a1:f6:c1:00:ba:6c, XID 2c2, IRQ 64
[ 1.337700] r8169 0000:03:00.0 eth0: jumbo features [frames: 9200 bytes, tx checksumming: ko]
[ 1.342232] r8169 0000:0a:00.0 eth1: RTL8168f/8111f, 18:63:6e:87:a3:cd, XID 480, IRQ 65
[ 1.342234] r8169 0000:0a:00.0 eth1: jumbo features [frames: 9200 bytes, tx checksumming: ko]
[ 1.413800] r8169 0000:03:00.0 eth126: renamed from eth0
[ 1.420245] r8169 0000:0a:00.0 eth125: renamed from eth1
[ 1.420247] udevd[1964]: renamed network interface eth0 to eth126
[ 1.428244] udevd[1972]: renamed network interface eth1 to eth125
[ 1.428245] r8169 0000:03:00.0 eth1: renamed from eth126
[ 1.436306] r8169 0000:0a:00.0 eth0: renamed from eth125
[ 1.436314] udevd[1964]: renamed network interface eth126 to eth1
[ 1.446230] udevd[1972]: renamed network interface eth125 to eth0There seems to be some misunderstanding, *I am* renaming the network interfaces via /etc/udev/rules.d, based on mac address, exactly as you are.Anon-E-moose wrote:I've heard of name space collision, but never personally seen it. I would try it and see if it works rather than basing it on someone elses opinion.Drag0nFly wrote:Which udev variant (and version) are you using? Renaming interfaces based on mac addr (to eth*) does not work with the later udev versions due to namespaceAnon-E-moose wrote:I have 2 network cards in my box, both 8169, I set names by mac addr.
collision.
You can also use another name rather the eth*. I just had everything on my old system set to speak to eth0 so I kept it (too lazy to change)
But if I had to do it over, I'd probably pick nic0, nic1, etc instead of eth*
I use an older version of eudev. And like Tony mentioned earlier, my network driver is module based rather than built in.


Is that the way the kernel works or does it keep track of the last name used (internally)? I don't know I've never looked at that portion of the kernel code, thus my question.udev is preempted. The kernel activates two more network interfaces, naming them eth0 (because that is free again) and eth1 (next in sequence).
This seems to be mostly theoretical. On all my systems either at work or at home; be it clients or servers with two or more NICs; many in riser cages, I've never seen network interfaces being activated immediately after udevd is invoked. They are consistently activated early during boot unless one has tweaked either initrd or blacklisted network modules, to be manually inserted later with the local.d approach mentioned earlier in the thread. But maybe I am the odd man out(?)Hu wrote:If I recall correctly, upstream udev declared that renaming an interface to a kernel name was an unsupported configuration and demanded that users not do that. I vaguely recall there may have been a version that artificially failed at renaming to a kernel-style name, just to be very pointed about how unsupported it was. Although mostly theoretical, there is a race condition even in the version that danced through the extra name to make your configuration work. Suppose the following sequence of events:The only safe approaches are (1) don't rename cards at all, or (2) don't rename a card to a name that may get created as a result of an external event.
- No network cards exist, because no kernel drivers for the installed cards are active.
- The kernel activates an interface, and names it eth0.
- udev notices this and renames it to rename0, in preparation to become eth1.
- udev is preempted. The kernel activates two more network interfaces, naming them eth0 (because that is free again) and eth1 (next in sequence).
- udev resumes executing. udev tries to rename rename0 to eth1 per your rule. This fails, because a new card took that name in the interim. Due to event ordering, udev has not yet renamed the new eth1 out of the way to make room for rename0.
Code: Select all
MSI ~ # equery d udev
* These packages depend on udev:
app-emulation/virtualbox-6.0.12 (udev ? >=virtual/udev-171)
net-print/hplip-3.18.12 (kernel_linux ? virtual/udev)
sys-apps/hwids-20190316 (udev ? virtual/udev)
sys-block/gparted-0.33.0 (hfs ? virtual/udev)
sys-fs/udev-init-scripts-27-r1 (>=virtual/udev-180)
virtual/dev-manager-0-r2 (virtual/udev)
MSI ~ # equery d udev-init-scripts
* These packages depend on udev-init-scripts:
sys-fs/eudev-1.10-r3 (openrc ? >=sys-fs/udev-init-scripts-26)
It does not sound to me like you were encountering the race condition, rather that you had the kernel simply switch the interfaces around, which is why I use the rules in /etc/udev/rules.d/10-network.rules to rewrite in the first place. It would be catastrophic if the power went out, and it booted in reverse order, as this has consistently happened with me on the other side of the planet. (and yet, the box has always recovered thanks to the mac address lock)Tony0945 wrote:DragOnFly,
The race condition is real. More than ten years ago I had a Tyan mobo with two built in NIC's. They mostly came up in a predictable order, but about one time in ten to 15 (i.e. once in two weeks), they would be reversed. This occurred with Windows also. With Windows (Win2k at that time), I could just reach over and pull the ethernet plug and plug it in the other slot. Linux, I would reboot usually getting the right one. I think we had hal instead of udev at that time.
Eventually, I configured both eth0 and eth1 and connected them to the four port switch to my wireless bridge. Obviously, that works for only the most primitive ethernet work, but I tell the story to show that the race is real, but mostly predictable and existed on Windows as well.
The module loading delay trick was used on a different machine two years ago. I used eudev-1.10, the same as Anon-a-Moose.
Today, I have the same eudev installed to satisfy portage requirements for other packages but never launch the service. I use mdev as a hotplug agent and that suffices for mounting USB sticks. That brings up the question of whether udev is really needed by those other packages.
I can certainly believe that. I was thinking of manually compiling it after I checked if the renaming section was similar (or identical) to recent udev versions.Tony0945 wrote:Code: Select all
MSI ~ # equery d udev * These packages depend on udev: app-emulation/virtualbox-6.0.12 (udev ? >=virtual/udev-171) net-print/hplip-3.18.12 (kernel_linux ? virtual/udev) sys-apps/hwids-20190316 (udev ? virtual/udev) sys-block/gparted-0.33.0 (hfs ? virtual/udev) sys-fs/udev-init-scripts-27-r1 (>=virtual/udev-180) virtual/dev-manager-0-r2 (virtual/udev) MSI ~ # equery d udev-init-scripts * These packages depend on udev-init-scripts: sys-fs/eudev-1.10-r3 (openrc ? >=sys-fs/udev-init-scripts-26)
(e)udev has become a hodge-podge of diverse code thrown together with no apparent design process. Indeed, I recently discovered that although udevd.c, the actual netlink socket daemon is in the package but never compiled! From talk on the internet, it appears that instead of using a well-designed kernel mechanism, so brain-dead hacker decided to just have a loop that sleeps and wakes up and asks "did anything happen?" scouring the whole device tree repeatedly, a "design" that makes me want to vomit.