Hello,
I have a question related to systemd-networkd DHCP server. I am currently
using the systemd v232 on a iMX6 based system where
network is configured to provide DHCP server functionality. This is my
configuration file:
[Match]
Name=eneport2
[Network]
DHCPServer=yes
LinkLocalAddressing=no
IPv6AcceptRouterAdvertisements=no
[Address]
Address=192.168.252.1/24
Broadcast=192.168.252.255
[DHCPServer]
PoolOffset=4
PoolSize=249
DefaultLeaseTimeSec=30s
Problem:
I noticed that randomly the DHCP server stops serving DHCP requests.
Tests:
- Sniffing the packets I can see devices requesting DHCP but there is no reply
for these:
tcpdump -i eneport2 port 67 or port 68 -e -n
....
01:50:33.993302 00:40:97:10:91:3b > 00:40:97:29:04:c2, ethertype IPv4 (0x0800),
length 590: 192.168.252.108.68 > 192.168.252.1.67: BOOTP/DHCP, Request from
00:40:97:10:91:3b, length 548
01:53:52.054527 00:00:a1:06:dd:5f > 00:40:97:29:04:c2, ethertype IPv4 (0x0800),
length 590: 192.168.252.171.68 > 192.168.252.1.67: BOOTP/DHCP, Request from
00:00:a1:06:dd:5f, length 548
02:07:24.460286 00:40:97:10:91:3b > 00:40:97:29:04:c2, ethertype IPv4 (0x0800),
length 590: 192.168.252.108.68 > 192.168.252.1.67: BOOTP/DHCP, Request from
00:40:97:10:91:3b, length 548
02:15:49.687499 00:40:97:10:91:3b > 00:40:97:29:04:c2, ethertype IPv4 (0x0800),
length 590: 192.168.252.108.68 > 192.168.252.1.67: BOOTP/DHCP, Request from
00:40:97:10:91:3b, length 548
...
- Also checking that systemd-networkd is up and running using: `systemctl
status systemd-networkd`.
- Restarting the system-networkd: `system restart systemd-networkd` fixed the
issue.
Analysis:
Checking the code I saw that DHCP server it is using a sd-event loop to handle
the DHCP messages:
File: sd-dhcpc-server.c
...
r = sd_event_add_io(server->event, &server->receive_message,
server->fd, EPOLLIN,
server_receive_message, server);
...
Checking the documentation it looks that sd_event will disable the event loop
once the handler will return a negative error:
Documentation:
(https://www.freedesktop.org/software/systemd/man/sd_event_add_io.html)
"If the handler function returns a negative error code, it will be disabled
after the invocation, even if the SD_EVENT_ON mode was requested before."
Having this situation the DHCP server will stop handling DHCP request and as
far as I see it's not visible at the user level or systemd-networkd will not be
restarted.
This are some steps where I was able to reproduce the situation:
I was able to simulate this by just manually changing the ip address of the
ethernet device providing DHCP server and back to the one configured as DHCP
server.
1. eneport2 configured with 192.168.252.1/24 and DHCP server enabled.
2. change the ip: ifconfig eneport2 x.x.x.x
3. change back the ip: ifconfig eneport2 192.168.252.1
4. The DHCP server it's not working anymore.
To me looks like an issue since we can end up losing the DHCP Server
functionality without able to recover (unless systemd-networkd is manually
restarted.)
Any thoughts? Or suggestions?
Should an issue be opened?
Regards,
Nandor
_______________________________________________
systemd-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/systemd-devel