summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman2025-12-13 15:07:41 +0000
committerÁlvaro Fernández Rojas2025-12-14 07:50:58 +0000
commit6b88c314a59ed9e69c872512a036a592c56730b7 (patch)
treec67cd8ea04a94a2a79f96d429417280dcb2f36d0
parentcf51aeb93220672d54d0d0f3707710bf544801e2 (diff)
downloadodhcpd-6b88c314a59ed9e69c872512a036a592c56730b7.tar.gz
statefiles: don't consider no hostname as broken
Commit e568bde changed the OAF_BROKEN_HOSTNAME flag to a boolean, but at the same time changed the semantics slightly so that no hostname was also considered broken (rather, no hostname means it's neither valid nor invalid). So, add a simple fix for this. Closes: https://github.com/openwrt/odhcpd/issues/350 Signed-off-by: David Härdeman <david@hardeman.nu> Link: https://github.com/openwrt/odhcpd/pull/351 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
-rw-r--r--src/statefiles.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/statefiles.c b/src/statefiles.c
index 558b012..05c9663 100644
--- a/src/statefiles.c
+++ b/src/statefiles.c
@@ -488,7 +488,7 @@ static void statefiles_write_state6(struct write_ctxt *ctxt, struct dhcpv6_lease
fprintf(ctxt->fp,
"# %s %s %x %s%s %" PRId64 " %" PRIx64 " %" PRIu8,
ctxt->iface->ifname, duidbuf, ntohl(lease->iaid),
- lease->hostname_valid ? "" : "broken\\x20",
+ lease->hostname && !lease->hostname_valid ? "broken\\x20": "",
lease->hostname ? lease->hostname : "-",
(lease->valid_until > ctxt->now ?
(int64_t)(lease->valid_until - ctxt->now + ctxt->wall_time) :
@@ -524,7 +524,7 @@ static void statefiles_write_state4(struct write_ctxt *ctxt, struct dhcpv4_lease
"# %s %s ipv4 %s%s %" PRId64 " %x 32 %s/32\n",
ctxt->iface->ifname,
ether_ntoa((struct ether_addr *)lease->hwaddr),
- lease->hostname_valid ? "" : "broken\\x20",
+ lease->hostname && !lease->hostname_valid ? "broken\\x20" : "",
lease->hostname ? lease->hostname : "-",
(lease->valid_until > ctxt->now ?
(int64_t)(lease->valid_until - ctxt->now + ctxt->wall_time) :