Skip to content

Add dmsystem service files so DHCP starts as a service - #2

Merged
JohnAmadis merged 3 commits into
mainfrom
claude/dhcp-service-file-3ycnkv
Sep 19, 2026
Merged

JohnAmadis merged 3 commits into
mainfrom
claude/dhcp-service-file-3ycnkv

Conversation

@JohnAmadis

@JohnAmadis JohnAmadis commented Sep 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a small tools/dhcpc Application-type module that calls dmdhcp_start(iface, ...) on one named interface and exits - the actual trigger that turns "dmdhcp is loaded" into "this interface has an address" (dmdhcp itself, unlike dmicmp, does nothing on its own once loaded - see docs/service.md).
  • dhcpc links dmdhcp_if directly, so loading it - by any means - loads and enables dmdhcp as its own module dependency automatically (the same way tools/ping in dmicmp pulls in dmicmp). There is no separate dhcp.ini unit - it would just be a redundant second way to reach the same load+enable dhcpc already causes.
  • Ship tools/dhcpc/configs/dhcp@.ini (per-interface unit template) and tools/dhcpc/configs/dhcp.rules ([class=netif] start=dhcp@%name) so every interface dmnetif reports gets a dhcp@<iface> instance automatically, the same per-interface-instance shape dmnet's networkd uses for its RX pump - installed alongside dmnet's own networkd.rules, both declaring [class=netif] and both firing from the same device event. This relies on choco-technologies/dmsystem#4 (merged) - libsystemd now fires every rule matching a class instead of only the first.
  • Add docs/service.md documenting the above, update docs/README.md/root README.md to link it, and wire tools/dhcpc into the build (CMakeLists.txt, dmdhcp.dmr, manifest.dmm), following the exact conventions dmicmp/tools/ping already established for a nested Application-type tool module.

Test plan

  • CI build (cmake --build .) succeeds for dmdhcp and the new dhcpc/test_dhcpc targets
  • ctest passes, including the new test_dhcpc steps (missing args, unknown interface, module unload, and a successful dmdhcp_start() against a fixture interface)
  • Manual: drop tools/dhcpc/configs/dhcp@.ini + dhcp.rules into a libsystemd units/rules directory alongside dmnet's networkd@.ini/networkd.rules and confirm both networkd@<iface> and dhcp@<iface> auto-start for a real interface

🤖 Generated with Claude Code

https://claude.ai/code/session_01Nobwf1PoG7dzKcwTWx5w5K

JohnAmadis and others added 3 commits September 19, 2026 20:46
dmdhcp is a Library-type module like dmicmp, so configs/dhcp.ini loads
and enables it via libsystemd's type=library, mirroring dmicmp's
configs/icmp.ini.

Unlike dmicmp, dmdhcp does not do anything useful merely by being
loaded - dmdhcp_start() still needs to be called per interface. Add a
small tools/dhcpc application module (the same per-interface-instance
shape dmnet's networkd uses) plus a dhcp@.ini unit template so an
integrator can enable DHCP on whichever specific interfaces need it,
without auto-wiring into dmnet's own netif device rule (which would
either silently lose the RX pump or the DHCP trigger, since libsystemd
only honors the first rules file that defines a given device class).
dmnetif.h #includes dmroute.h directly, so any target that includes it
needs dmroute's headers on its include path - the dhcpc module itself
already links dmroute for this reason, but its test target didn't.
dhcpc already links dmdhcp_if directly, so loading it (however it gets
started) loads and enables dmdhcp as its own module dependency - the
same way tools/ping pulls in dmicmp with no separate unit for it. A
standalone configs/dhcp.ini (type=library, exec=dmdhcp) was therefore
redundant: it offered a second way to reach the same load+enable dhcpc
already causes as a side effect.

Also add tools/dhcpc/configs/dhcp.rules ([class=netif] start=dhcp@%name),
now that libsystemd fires every rule matching a device class instead of
only the first (choco-technologies/dmsystem#4) - dhcp.rules and dmnet's
own networkd.rules can both declare [class=netif] and both fire from
the same dmnetif device event, so every interface gets a DHCP attempt
alongside its RX pump with no static per-interface unit file to
maintain. dhcp@.ini's after=/requires= on dhcp/networkd@%i is dropped
too: dhcpc only needs to call dmdhcp_start(), which retries DISCOVER on
its own timer regardless of whether the RX pump is up yet.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Nobwf1PoG7dzKcwTWx5w5K
@JohnAmadis
JohnAmadis merged commit df99a4b into main Sep 19, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants