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. Browsable code: https://github.com/pgaufillet/dnsmasq/tree/submission/lease-sync-patches, and for information https://github.com/pgaufillet/openwrt-ha-feed N.B. This work has been performed using Claude Code, among other tools. Pierre Gaufillet |
0001-Add-ubus-methods-for-DHCP-lease-management.patch
Description: Binary data
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Dnsmasq-discuss mailing list [email protected] https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
