From mboxrd@z Thu Jan 1 00:00:00 1970 From: Matthias Schwarzott Date: Wed, 14 Feb 2007 14:12:13 +0000 Subject: [PATCH] net-persistence fails when adding new NIC and still having / Message-Id: <200702141512.13643.zzam@gentoo.org> MIME-Version: 1 Content-Type: multipart/mixed; boundary="Boundary-00=_9ix0FDhfyEPOJH5" List-Id: To: linux-hotplug@vger.kernel.org --Boundary-00=_9ix0FDhfyEPOJH5 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi list! This time I have a quite ugly bug. For reference: http://bugs.gentoo.org/show_bug.cgi?id=166486 Short form: Adding a new NIC leaves a system which takes 30sec more on udevstart, and after that has network interfaces eth0, eth1 and eth1_rename or similar. Using udev-104 (with net-rename related patches from udev-105). Reproduce: 1. Have 1 or more NICs already in the system (here: eth0 eth1). 2. udev already has created 70-persistent-net.rules, setting names to: eth0 eth1 3. Now insert another NIC into the system and boot: 4. Then at boot for newest NIC write_net_rules get called. 5. write_net_rules detects that /etc/udev/rules.d/ is read only that point and decides to write to /dev/.udev/tmp-rules-*: RULES_FILE=/dev/.udev/tmp-rules--..... 6. Now problem is: When checking for already used names it does this first: [ -e $RULES_FILE ] || return Sadly $RULES_FILE does not exist at that point, thus it skips to also look into /etc/udev/rules.d/70-persistent-net.rules 7. Two possible cases: a) newest NIC gets eth2 from kernel. Not checking already used netif names does not harm and udev writes eth2 down to the file. b) newest NIC gets name already used (here: eth0) and other nics get higher numbers. Now missing check tells write_net_rules that eth0 is free for use => it writes a rule using it and also writes it to stdout for direct usage. 8. udev enters the netif rename code for all interfaces (at same time). a) In this case all interfaces get unique new names and it will work (with eth?_rename only being a tmp name for one loop or so). b) udev enters a loop in which two interfaces try to rename themselves to same name (here: eth0). The new NIC already has eth0 => stays so. The old NIC that has ever been eth0 (and at this boot is eth1) gets renamed to eth1_rename (for making place for real owner of eth1). But then renaming to eth0 must fail (name already used). This failing leads to a busy waiting loop for exactly 30sec. After that we have: eth0: new NIC that should be eth2 eth1: correct name assigned eth1_rename: nic that should be eth0 Deleting the (wrong) check from 6. solves this (Patch attached). It could also be replaced by a more versatile check but I think that is not necessary (somewhere integrated with read-only detection). Greetings Matthias -- Matthias Schwarzott (zzam) --Boundary-00=_9ix0FDhfyEPOJH5 Content-Type: text/x-diff; charset="utf-8"; name="udev-104-persistent-net-fix-name-dups.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="udev-104-persistent-net-fix-name-dups.patch" diff -ru udev-104-orig/extras/rule_generator/rule_generator.functions udev-104/extras/rule_generator/rule_generator.functions --- udev-104-orig/extras/rule_generator/rule_generator.functions 2007-01-15 14:56:11.000000000 +0100 +++ udev-104/extras/rule_generator/rule_generator.functions 2007-02-12 13:17:39.000000000 +0100 @@ -92,7 +92,6 @@ local linkre="$2" local match="$3" - [ -e $RULES_FILE ] || return local search='.*[[:space:],]'"$key"'"\('"$linkre"'\)"[[:space:]]*\(,.*\|\\\|\)$' echo $(sed -n -e "${match}s/${search}/\1/p" $RO_RULES_FILE $RULES_FILE) } --Boundary-00=_9ix0FDhfyEPOJH5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------- 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 --Boundary-00=_9ix0FDhfyEPOJH5 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net Linux-hotplug-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel --Boundary-00=_9ix0FDhfyEPOJH5--