























Hi!
The attached patch adds three ubus methods to dnsmasq: add_lease, delete_lease and get_leases. These are the ubus equivalent of the existing dbus AddDhcpLease/DeleteDhcpLease, plus get_leases which has no dbus counterpart.
The use case is HA DHCP on OpenWrt: when a dnsmasq instance creates or removes a lease, an external daemon replicates it to peer nodes via the new ubus methods, so that all instances share a consistent lease database.
The implementation follows the same internal APIs as the dbus path (lease4_allocate, lease_set_hwaddr, lease_set_expires, etc.) with a few improvements: hostname validation via legal_hostname(), IPv6 domain lookup with get_domain6(), and script-triggering flag suppression for injected leases (preventing dhcp-script ping-pong).
No extra per-lease storage is required. get_leases iterates the existing lease linked list on demand.
I am aware of the 2021 discussion around Eduardo Aguilar's lease method proposal. This takes a different approach: it hooks directly into the ubus method table (not log_packet()), stores no extra data, and mirrors the existing dbus design rather than introducing a new one.
The patch is tested on an OpenWrt HA cluster. If there is interest, I also have a self-contained contrib daemon (contrib/lease-sync/) that uses these methods, which I could submit separately.
N.B. This work has been performed using Claude Code, among other tools.
Pierre Gaufillet
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。