[systemd-devel] Bug? Ordering services on device aliases

Dave Reisner d at falconindy.com
Mon Jun 25 13:23:13 PDT 2012


The premise is fairly simple, given the below unit:

  [Unit]
  Description=dhcpcd on %I
  Wants=network.target
  Before=network.target
  After=sys-subsystem-net-devices-%i.device
  BindTo=sys-subsystem-net-devices-%i.device

  [Service]
  Type=forking
  PIDFile=/run/dhcpcd-%I.pid
  ExecStart=/sbin/dhcpcd -A -q -w %I
  ExecStop=/sbin/dhcpcd -k %I

  [Install]
  Alias=multi-user.target.wants/dhcpcd at eth0.service

All I'm interested in is making sure that the device is available before
starting dhcpcd for an interface. However, when I enable this unit, the
device alias is inactive after booting:

  $ systemctl -t device --full --all --no-pager | grep net
  sys-devices-pci0000:00-0000:00:03.0-virtio0-net-eth0.device loaded active
  sys-subsystem-net-devices-eth0.device                       loaded inactive

The device node itself looks just fine, according to udev:

  $ udevadm info -q property /devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
  DEVPATH=/devices/pci0000:00/0000:00:03.0/virtio0/net/eth0
  ID_BUS=pci
  ID_MODEL_FROM_DATABASE=Virtio network device
  ID_MODEL_ID=/sys/devices/pci0000:00/0000:00:03.0/virtio0
  ID_VENDOR_FROM_DATABASE=Red Hat, Inc
  ID_VENDOR_ID=0x1af4
  IFINDEX=2
  INTERFACE=eth0
  SUBSYSTEM=net
  SYSTEMD_ALIAS=/sys/subsystem/net/devices/eth0
  TAGS=:systemd:
  USEC_INITIALIZED=95201

Meanwhile, this of course means that dhcpcd at eth0.service is sitting
idle:

  $ systemctl status dhcpcd at eth0.service
  dhcpcd at eth0.service - dhcpcd on eth0
      Loaded: loaded (/etc/systemd/system/dhcpcd at .service; enabled)
      Active: inactive (dead)
      CGroup: name=systemd:/system/dhcpcd at .service/eth0

As soon as I reboot without the After=/BindTo= ordering on dhcpcd at .service,
the alias shows as active:

  $ systemctl status sys-subsystem-net-devices-eth0.device
  sys-devices-pci0000:00-0000:00:03.0-virtio0-net-eth0.device - Virtio network device
      Loaded: loaded
      Active: active (plugged) since Mon, 25 Jun 2012 16:16:52 -0400; 46s ago
      Device: /sys/devices/pci0000:00/0000:00:03.0/virtio0/net/eth0

Were device aliases not intended to be used this way? If not, what's the
purpose? How can I order a network service against a device to ensure
it's started properly?

Relevant: https://bugs.archlinux.org/task/30235

Cheers,
Dave



More information about the systemd-devel mailing list