Bryan Kadzban wrote: > Bruce Dubbs wrote: >> Armin K. wrote: >>> Bruce, some guy came on the irc saying that network rules creation >>> does not work in systemd extracted udev. >>> >>> <Zenther> working my way through the cvs book and get to 7.2.1. >>> Creating stable names for network interfaces and I am getting a >>> cat: /etc/udev/rules.d/70-persistent-net.rules: No such file or >>> directory. Above that I see it list out my eth0 and wlan0. >>> >>> Can you check and/or confirm that? >> >> >> I can confirm that in chroot. I think he is referring to section >> 7.5. That needs to be changed. The 'udevadm test' command no longer >> runs aux programs, e.g. /lib/udev/write_net_rules. >> >> However, the first time the system is booted, udevd will run the >> rules and the 70-persistent-net.rules file will be written at that >> time. > > Well, they finally killed it. > > ARRRRG. > > Unfortunately for the case where pregenerating the rules files is > required, "at first boot" is way too late to generate the file. The NIC > needs to have a stable name assigned before the networking stuff gets > configured, so that at first boot, the NICs are configured correctly. > > Obviously it only matters on a multi-NIC machine, and only really when > the configuration is different per NIC. > > Since the Debian-package udev maintainer is the one who said he'd be > continuing this (since Debian has exactly the same problem on users' > server installations), I wonder if Debian has added patches to fix it > up, or is generating the config in some other way. > > ...doing a bunch of thinking here... > > Do we want to just bite the bullet and change the networking config to > use MAC- or path-based IDs instead of NIC names? E.g. change the > /etc/sysconfig/ifconfig.eth0 filename (and directory, if a directory is > used) to either /etc/sysconfig/ifconfig.mac.xx:xx:xx:xx:xx:xx, or > /etc/sysconfig/ifconfig.path.pci-foo-bar-usb-baz-whatever (whatever > path_id prints out), then use udevadm to find the NIC device's name? > > With a couple changes to the udev rules (add an IMPORT{builtin}=path_id, > and copy attrs{address} off to some environment variable), all the > required info should be in the udev database, meaning something like > this might work: > > <read file or directory name into $NIC_ID or whatever> > TYPE=`echo $NIC_ID | cut -d. -f2` # either mac or path > ID=`echo $NIC_ID | cut -d. -f2-` > if [ "$TYPE" = "path" ] ; then > for i in /sys/class/net/* ; do > if [ "$(udevadm info --query env --path $i \ > | grep ID_PATH)" = "$ID" ] ; then > INTERFACE=${i##/sys/class/net/} > fi > done > if [ -z "$INTERFACE" ] ; then > # whatever error handling > fi > else > for i in /sys/class/net/* ; do > if [ "$(udevadm info --query env --path $i \ > | grep ID_MAC)" = "$ID" ] ; then > INTERFACE=${i##/sys/class/net/} > fi > done > if [ -z "$INTERFACE" ] ; then > # whatever error handling > fi > fi > > Then run the script as before, since $INTERFACE is set. > > Alternately, that's a weird N-squared algorithm. Maybe it'd work better > to do something like:
The order of the algorithm, O(n), only matters for large values of n. A bubble sort is just fine for 4 items. Have you ever heard of a system with more than 4 NICs? I have thought of writing such a script to write the 70-persistent-net.rules file. I was still going to use the write_net_rules script. Your input gives me some ideas. I don't think we need to worry about lo, tunl, br, wlan, or sit interfaces. Only eth. I'll try to use your example above and come up with something later today. -- Bruce -- http://linuxfromscratch.org/mailman/listinfo/lfs-dev FAQ: http://www.linuxfromscratch.org/faq/ Unsubscribe: See the above information page