add action uses wrong interface name in 85-ifupdown.rules

Bug #38787 reported by Jürgen Kreileder
26
Affects Status Importance Assigned to Milestone
udev (Ubuntu)
Fix Released
High
Scott James Remnant (Canonical)

Bug Description

When network interfaces get renamed via 25-iftab.rules and /etc/iftab, the add action in 85-ifupdown.rules uses the wrong interface name.

In the attached log, 'eth0' gets renamed to 'wifi', but ifup gets called for 'eth0' instead of 'wifi'.

Revision history for this message
Jürgen Kreileder (jk) wrote : udev.log

udev debug log

Revision history for this message
Jürgen Kreileder (jk) wrote : work-around

I'm using this work-around for now but I wonder why the rule doesn't see the correct INTERFACE value (the setenv in udev_add.c seems to be OK).

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Definitely a major bug, however I'm sure this would have appeared earlier if it was breaking for everyone. Will test it here to see whether I can confirm.

Changed in udev:
assignee: nobody → keybuk
Revision history for this message
Jürgen Kreileder (jk) wrote :

udevmonitor shows that INTERFACE indeed gets set correctly but the rule nevertheless gets the wrong value:

UEVENT[1144694030.924086] add@/class/net/eth0
ACTION=add
DEVPATH=/class/net/eth0
SUBSYSTEM=net
SEQNUM=933
PHYSDEVPATH=/devices/pci0000:00/0000:00:1e.0/0000:03:03.0
PHYSDEVBUS=pci
PHYSDEVDRIVER=ipw2200
INTERFACE=eth0

UDEV [1144694030.937425] add@/class/net/eth0
UDEV_LOG=7
ACTION=add
DEVPATH=/class/net/wifi
SUBSYSTEM=net
SEQNUM=933
PHYSDEVPATH=/devices/pci0000:00/0000:00:1e.0/0000:03:03.0
PHYSDEVBUS=pci
PHYSDEVDRIVER=ipw2200
INTERFACE=wifi
UDEVD_EVENT=1

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

I can confirm this here, debugging now.

Changed in udev:
status: Unconfirmed → Confirmed
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Key points from debug log (which isn't the same as what you attached above, which was just an info log)

apply_format: will substitute format name 'env'
get_format_attribute: attribute='INTERFACE', str=''
apply_format: format=14, string='/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto ', tail='',
class_dev=0x80631d0, sysfs_dev=0x8064c10
apply_format: substitute env 'INTERFACE=eth0'
udev_rules_get_name: add run '/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto eth0'
name_list_add: adding '/sbin/start-stop-daemon --start --background --pidfile /var/run/network/bogus --startas /sbin/ifup -- --allow auto eth0'
udev_rules_iter_next: current=289188

So getenv("INTERFACE") is definitely returning "eth0" at that point.

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

And I've checked the renaming code, getenv("INTERFACE") definitely returns "test" at that point!

The problem appears to be that the value in the rule is expanded before the interface is actually renamed.

Revision history for this message
Jürgen Kreileder (jk) wrote :

The reason why this doen't bite many people is that 85-ifupdown.rules just tries to bring up interfaces which are marked 'auto', those are if-uped by /etc/init.d/networking anyhow.

I was trying to use a similar rule for starting ifplugd when I noticed this problem (no 'auto' interfaces).

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Aha!

And this finally explains the strange symptoms where an interface sometimes would get brought up by "ifup -a" when it should have been brought up by udev.

Excellent.

The bug is simply that the NAME bit of the rule is applied after the run list has been created; the easiest solution to this is implementing a $name expansion that doesn't rely on the environment being modified.

udev fix being uploaded now, ifupdown in a few minutes time.

Changed in udev:
status: Confirmed → Fix Released
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Actually, I just realised the fix isn't that simple as we need to deal with enumeration of devices.

I'll have to find a way to delay the format application until after the NAME rule has been applied.

Changed in udev:
status: Fix Released → In Progress
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

This was fixed in upstream, but after they reworked udevd to remove libsysfs; I've rewritten that patch and it seems to fix the problem here.

Changed in udev:
status: In Progress → Fix Committed
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Uploaded to dapper, please try 0ubuntu25

Changed in udev:
status: Fix Committed → Fix Released
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Note that no ifupdown change is needed with the udev patch I've uploaded.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Bug attachments

Remote bug watches

Bug watches keep track of this bug in other bug trackers.