summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Härdeman2025-12-09 09:11:08 +0000
committerÁlvaro Fernández Rojas2025-12-10 05:36:39 +0000
commitca00527e5fc3d8d2b8c1a60fbeb6a25e2bf68674 (patch)
treee820791d7a969372c8d38eecb90b40bfd923d929
parent24b70c5c2ff06a021e079e9f157cba6165aeab8a (diff)
statefiles: don't write empty hosts files
This is mostly cosmetic, skip writing out hosts files for interfaces where it makes little sense to do so (i.e. where the hosts file will anyway be empty). Closes: https://github.com/openwrt/odhcpd/issues/338 Signed-off-by: David Härdeman <david@hardeman.nu> Link: https://github.com/openwrt/odhcpd/pull/342 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
-rw-r--r--src/statefiles.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/statefiles.c b/src/statefiles.c
index 0ce2a2e..558b012 100644
--- a/src/statefiles.c
+++ b/src/statefiles.c
@@ -415,7 +415,15 @@ static void statefiles_write_hosts(time_t now)
return;
avl_for_each_element(&interfaces, ctxt.iface, avl) {
+ if (ctxt.iface->ignore)
+ continue;
+
+ if (ctxt.iface->dhcpv4 != MODE_SERVER && ctxt.iface->dhcpv6 != MODE_SERVER)
+ continue;
+
ctxt.fp = statefiles_open_tmp_file(config.dhcp_hostsdir_fd);
+ if (!ctxt.fp)
+ continue;
if (ctxt.iface->dhcpv6 == MODE_SERVER) {
struct dhcpv6_lease *lease;
@@ -534,6 +542,7 @@ static bool statefiles_write_state(time_t now)
};
uint8_t newmd5[16];
+ /* Return value unchecked, continue in order to get the md5 */
ctxt.fp = statefiles_open_tmp_file(config.dhcp_statedir_fd);
md5_begin(&ctxt.md5);