Bug 83542 - systemd-networkd: DHCP server is stopped on "lost carrier" but never restarted on "gained carrier" (systemd 216)
Summary: systemd-networkd: DHCP server is stopped on "lost carrier" but never restarte...
Status: RESOLVED FIXED
Alias: None
Product: systemd
Classification: Unclassified
Component: general (show other bugs)
Version: unspecified
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Tom Gundersen
QA Contact: systemd-bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-09-05 17:40 UTC by david
Modified: 2014-10-27 11:03 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments

Description david 2014-09-05 17:40:29 UTC
When a device configured with DHCPServer=yes loses carrier, networkd stops its DHCP server. But when the carrier re-appears later on, the server is not restarted.

My use case is a bridge I use to connect virtual machines to; the bridge is NAT-ed to the outside and the host interface is *not* connected to it; veth and tap devices are added and removed as needed.

First virtual machine to start gets its address successfully. After the last machine is shut down, the bridge has no ports and networkd stops the DHCP server. When a new machine is started after that, the bridge gets a carrier again, but networkd doesn't restart DHCP server, so that and subsequent machines can't acquire a lease.


$ cat /etc/systemd/network/br0.netdev
[NetDev]
Name=br0
Kind=bridge

$ cat /etc/systemd/network/br0.network
[Match]
Name=br0
[Network]
Address=10.10.10.1/24
DHCPServer=yes


This behaviour follows from the state machine in networkd-link.c. It looks like it could be fixed by moving set-up calls to sd_dhcp_*() from link_enter_configure() to link_acquire_conf() to regain symmetry between setup that happens on carrier_gained and teardown on carrier_lost, but I'm not confident enough in my understanding of the state machine invariants to patch it myself.
Comment 1 Timo Derstappen 2014-09-23 10:38:21 UTC
I've got the same situation with a DHCP server on a bridge and nspawn containers with veths and networkd DHCP clients. When the last container is removed the DHCP server stops. 

My current workaround is to restart networkd on the host before I start the first container.
Comment 2 Tom Gundersen 2014-10-27 11:03:53 UTC
Thanks for the report. This should be fixed in git now. Please reopen if you still experience problems.


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.