Bug 52580 - device alias doesn't work in BindTo/After
Summary: device alias doesn't work in BindTo/After
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86 (IA32) Linux (All)
: medium normal
Assignee: systemd-bugs
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-27 09:59 UTC by rodrigo
Modified: 2012-10-21 13:09 UTC (History)
7 users (show)

See Also:
i915 platform:
i915 features:


Attachments

Description rodrigo 2012-07-27 09:59:29 UTC
Hi!

I've been trying to write a unit template to configure the network (systemd version: 187):

File: net-static@.service

[Unit]
Description=Static interface
Wants=network.target
Before=network.target
#BindTo=sys-subsystem-net-devices-%i.device
#After=sys-subsystem-net-devices-%i.device

[Service]
...


Now, if I uncomment any of the lines that make a reference to the device alias, then the alias itself disappears!

When I say that the alias disappears, I mean that it is no longer an alias of the real device, instead it looks like systemd believes it is a proper unit in its own, and I can see it in the output of `systemctl --all`: loaded inactive dead, without meaningful description.

If the BindTo is uncommented, that means that this unit cannot start: it tries to start the sys-subsystem-net-devices-eth0.device unit, and it times out.

If only the After is uncommented, then this unit is started anyway.

However, if I write the BindTo/After using the full name of the device (BindTo=sys-devices-pci0000:00-0000:00:03.0-net-eth0.device) then it works as expected). But that's not so useful, because I'm writing a template so I really need to use the alias.

Is my unit expected to work or am I totally misunderstanding aliases?

Regards
-- 
Rodrigo
Comment 1 Dave Reisner 2012-09-09 17:26:36 UTC
Yeah, this is definitely a bug -- it breaks ordering for DHCP clients and wpa_supplicant. The only workaround I know of at the moment is to explicitly load the module in /etc/modules-load.d to give the interface a better chance of existing when your unit runs.

I reported this a while ago, as well:

http://lists.freedesktop.org/archives/systemd-devel/2012-July/005847.html

It's still valid in 189.
Comment 2 Markus Uhr 2012-10-02 07:39:16 UTC
This bug also affects me. In my case, it's a USB-to-Ethernet adaptor that gets different USB addresses assigned by the kernel (usb7-7\x2d3-7\x2d3:1.0 or usb3-3\x2d3-3\x2d3:1.0). Since I can't use the device alias, as a work-around, I have to rewrite my service file upon every second reboot.

Fixing this bug would be greatly appreciated.

Markus
Comment 3 Eelco Dolstra 2012-10-15 14:56:56 UTC
I've posted a patch on the systemd-devel list that should fix this problem:

http://lists.freedesktop.org/archives/systemd-devel/2012-October/006872.html
Comment 4 Dave Reisner 2012-10-21 13:09:47 UTC
Thanks Eelco, I pulled your patch for inclusion in the next release.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.