summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHauke Mehrtens2026-05-23 12:16:45 +0000
committerHauke Mehrtens2026-06-18 00:35:01 +0000
commit1c461b0c1dc5edccca42efbf76fc633143ff3bba (patch)
tree72686268abda1c88aa539aea4509ce9cea17aa61
parent14a85c979dd336c7267e0a2cb0826c23325f7274 (diff)
downloadodhcpd-1c461b0c1dc5edccca42efbf76fc633143ff3bba.tar.gz
ubus: drop spurious ntohl() of DHCPv4 lease IAID
struct dhcpv4_lease::iaid is stored in host byte order: dhcpv4_lease() calls ntohl() on the IAID read from the DHCP client-id (RFC4361) before saving it via dhcpv4_alloc_lease(). The ubus ipv4leases dump then ran ntohl() on it a second time, byte-swapping it on little-endian hosts so consumers got the wire-order IAID instead of the host-order one. The dhcp.lease4 event broadcast (ubus_bcast_dhcpv4_event) already exposed lease->iaid without the extra conversion, so the two ubus surfaces disagreed. Drop the extra ntohl() so ipv4leases matches the event broadcast and the value matches what find_lease_by_duid_iaid() compares against. DHCPv6 leases are unchanged: a->iaid there really is in network byte order and the ntohl() in handle_dhcpv6_leases() is correct. Assisted-by: Claude:claude-opus-4-7 Link: https://github.com/openwrt/odhcpd/pull/401 Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de> (cherry picked from commit a6fe4633bb69b4476697e9047bd48c1d26d4b3ca)
-rw-r--r--src/ubus.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/ubus.c b/src/ubus.c
index d492fcd..d6b3c0a 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -52,7 +52,7 @@ static int handle_dhcpv4_leases(struct ubus_context *ctx, _o_unused struct ubus_
buf = blobmsg_alloc_string_buffer(&b, "duid", DUID_HEXSTRLEN + 1);
odhcpd_hexlify(buf, c->duid, c->duid_len);
blobmsg_add_string_buffer(&b);
- blobmsg_add_u32(&b, "iaid", ntohl(c->iaid));
+ blobmsg_add_u32(&b, "iaid", c->iaid);
}
blobmsg_add_string(&b, "hostname", (c->hostname) ? c->hostname : "");