You are not logged in.

#1 2013-06-07 09:23:29

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 232

Netctl doesn't work in LXC (Linux containers) due to udev dependency

I have just rebuilt a container so it has all the latest stuff. I did it to take on board the sbin shift. Now its network doesn't work.

When trying to start a simple static configuration, netctl (actually, systemd) borks becuase a dependency on "sys-subsystem-net-devices-eth0.device" isn't met.

Jun 07 10:09:48 xxxx systemd[1]: Expecting device sys-subsystem-net-devices-
-- Subject: Unit sys-subsystem-net-devices-eth0.device has begun with start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit sys-subsystem-net-devices-eth0.device has begun starting up.
Jun 07 10:11:18 xxxx systemd[1]: Job sys-subsystem-net-devices-eth0.device/s
Jun 07 10:11:18 xxxx systemd[1]: Timed out waiting for device sys-subsystem-
-- Subject: Unit sys-subsystem-net-devices-eth0.device has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02c
-- 
-- Unit sys-subsystem-net-devices-eth0.device has failed.
-- 
-- The result is timeout.
Jun 07 10:11:18 xxxx systemd[1]: Dependency failed for Network (Static Host)
-- Subject: Unit netctl@static.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- Documentation: http://www.freedesktop.org/wiki/Software/systemd/catalog/be02c
-- 
-- Unit netctl@static.service has failed.
-- 
-- The result is dependency.

I think this happens because the dependency is a udev device and udev does not run inside lxc and, therefore, the device doesn't exist.

I can prove the network stack is ok by manually starting the network

ip addr add 10.0.1.2/8 dev eth0
ip route add default via 10.0.0.138
echo "nameserver 10.0.0.138" > /etc/resolv.conf

This all worked fine with netcfg. I am not sure what to do now - any advice appreciated ...

Offline

#2 2013-06-07 18:35:03

teateawhy
Member
From: GER
Registered: 2012-03-05
Posts: 1,138
Website

Re: Netctl doesn't work in LXC (Linux containers) due to udev dependency

You can edit the service file and remove the udev dependencies here:

BindsTo=sys-subsystem-net-devices-net0.device
After=sys-subsystem-net-devices-net0.device

This might fail if the hardware is not ready yet. I guess that is not a problem in LXC, because the LXC host has already set up the hardware?

Offline

#3 2013-06-08 11:02:23

starfry
Member
From: Surrey, UK
Registered: 2010-08-18
Posts: 232

Re: Netctl doesn't work in LXC (Linux containers) due to udev dependency

Thanks @teateawhy for pointing that out. I was thinking along the same lines and I now have it working. Just editing the unit file is, however, not enough because netctl writes (and can overwrite) this file. I patched netctl to detect lxc and to not add the dependencies to the unit if running in LXC. This works.

A secondary problem is that the interface is already up when LXC starts and netctl refuses to start a profile that uses an interface that is already up. This one was solved by adding an entry "ForceConnect=yes"  to the netctl profile. This option wasn't documented on the man page for netctl.profile but I quickly discovered it by looking at the code for "/usr/lib/network/network" - this is what the systemd unit calls to start/stop the netctl profile.

I have raised a bug report for this and supplied my patch.

Offline

Board footer

Powered by FluxBB