linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Schwarzott <zzam@gentoo.org>
To: linux-hotplug@vger.kernel.org
Subject: [PATCH] net-persistence fails when adding new NIC and still having /
Date: Wed, 14 Feb 2007 14:12:13 +0000	[thread overview]
Message-ID: <200702141512.13643.zzam@gentoo.org> (raw)

[-- Attachment #1: Type: text/plain, Size: 2354 bytes --]

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)

[-- Attachment #2: udev-104-persistent-net-fix-name-dups.patch --]
[-- Type: text/x-diff, Size: 573 bytes --]

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)
 }

[-- Attachment #3: Type: text/plain, Size: 345 bytes --]

-------------------------------------------------------------------------
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

[-- Attachment #4: Type: text/plain, Size: 226 bytes --]

_______________________________________________
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

             reply	other threads:[~2007-02-14 14:12 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-02-14 14:12 Matthias Schwarzott [this message]
2007-02-19 12:16 ` [PATCH] net-persistence fails when adding new NIC and still Matthias Schwarzott
2007-02-26 11:02 ` Matthias Schwarzott
2007-02-26 11:26 ` Marco d'Itri
2007-02-26 14:11 ` Kay Sievers
2007-02-26 14:17 ` Marco d'Itri
2007-02-26 17:16 ` Kay Sievers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200702141512.13643.zzam@gentoo.org \
    --to=zzam@gentoo.org \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).