From af15e6508783bdde23d3fc6282954601253eff45 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 12 Mar 2026 22:08:25 +0100 Subject: [PATCH 1/2] package/netd: ensure /etc/net.d exists at boot Before netd starts confd might want to create .conf file for it to run, so we sort of depend on /etc/net.d existing at boot. Signed-off-by: Joachim Wiberg --- package/netd/netd.mk | 4 ++++ package/netd/tmpfiles.conf | 1 + 2 files changed, 5 insertions(+) create mode 100644 package/netd/tmpfiles.conf diff --git a/package/netd/netd.mk b/package/netd/netd.mk index 8a658af0f..bd5e23f4a 100644 --- a/package/netd/netd.mk +++ b/package/netd/netd.mk @@ -34,6 +34,10 @@ else NETD_CONF_OPTS += --without-frr endif +define NETD_INSTALL_EXTRA + cp $(NETD_PKGDIR)/tmpfiles.conf $(TARGET_DIR)/etc/tmpfiles.d/netd.conf +endef + NETD_TARGET_FINALIZE_HOOKS += NETD_INSTALL_EXTRA $(eval $(autotools-package)) diff --git a/package/netd/tmpfiles.conf b/package/netd/tmpfiles.conf new file mode 100644 index 000000000..f307dd06d --- /dev/null +++ b/package/netd/tmpfiles.conf @@ -0,0 +1 @@ +d /etc/net.d - - - From 3e762e6111636000d8804bfefc26e77c1290e0ee Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Thu, 12 Mar 2026 22:27:52 +0100 Subject: [PATCH 2/2] confd: Use ERRNO() instead of ERROR() after POSIX API failures Replace ERROR() with ERRNO() in all error paths following POSIX API calls (fopen, rename, realloc, fmkpath, etc.), removing redundant manual strerror(errno) formatting where present. Signed-off-by: Joachim Wiberg --- src/confd/src/dhcp-common.c | 2 +- src/confd/src/dhcp-server.c | 2 +- src/confd/src/firewall.c | 2 +- src/confd/src/hardware.c | 4 ++-- src/confd/src/if-wifi.c | 4 ++-- src/confd/src/ntp.c | 2 +- src/confd/src/routing.c | 6 +++--- src/confd/src/system.c | 4 ++-- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/confd/src/dhcp-common.c b/src/confd/src/dhcp-common.c index d13586f6b..3a96a9e07 100644 --- a/src/confd/src/dhcp-common.c +++ b/src/confd/src/dhcp-common.c @@ -170,7 +170,7 @@ char *dhcp_compose_options(struct lyd_node *cfg, const char *ifname, char **opti opts = realloc(*options, strlen(*options) + strlen(opt) + 1); if (!opts) { - ERROR("failed reallocating options: %s", strerror(errno)); + ERRNO("failed reallocating options"); free(*options); return NULL; } diff --git a/src/confd/src/dhcp-server.c b/src/confd/src/dhcp-server.c index beed35951..cdf641f35 100644 --- a/src/confd/src/dhcp-server.c +++ b/src/confd/src/dhcp-server.c @@ -195,7 +195,7 @@ static void add(const char *subnet, struct lyd_node *cfg) fp = fopenf("w", DNSMASQ_SUBNET_FMT, tag); if (!fp) { - ERROR("Failed creating dnsmasq conf for %s: %s", subnet, strerror(errno)); + ERRNO("Failed creating dnsmasq conf for %s", subnet); return; } diff --git a/src/confd/src/firewall.c b/src/confd/src/firewall.c index cad59551b..b6653d870 100644 --- a/src/confd/src/firewall.c +++ b/src/confd/src/firewall.c @@ -552,7 +552,7 @@ int firewall_change(sr_session_ctx_t *session, struct lyd_node *config, struct l fmkpath(0755, FIREWALLD_ZONES_DIR) || fmkpath(0755, FIREWALLD_SERVICES_DIR) || fmkpath(0755, FIREWALLD_POLICIES_DIR)) { - ERROR("Failed creating " FIREWALLD_DIR_NEXT " directory structure"); + ERRNO("Failed creating " FIREWALLD_DIR_NEXT " directory structure"); err = SR_ERR_SYS; goto done; } diff --git a/src/confd/src/hardware.c b/src/confd/src/hardware.c index 5e2b3a961..11fa7ed43 100644 --- a/src/confd/src/hardware.c +++ b/src/confd/src/hardware.c @@ -510,7 +510,7 @@ static int wifi_gen_aps_on_radio(const char *radio_name, struct lyd_node *cifs, hostapd = fopen(hostapd_conf, "w"); if (!hostapd) { - ERROR("Failed to create hostapd config: %s", hostapd_conf); + ERRNO("Failed to create hostapd config: %s", hostapd_conf); rc = SR_ERR_INTERNAL; goto cleanup; } @@ -759,7 +759,7 @@ int hardware_change(sr_session_ctx_t *session, struct lyd_node *config, struct l fp = fopen(GPSD_CONF_NEXT, "w"); if (!fp) { - ERROR("Could not open " GPSD_CONF_NEXT); + ERRNO("Could not open " GPSD_CONF_NEXT); return SR_ERR_INTERNAL; } int i; diff --git a/src/confd/src/if-wifi.c b/src/confd/src/if-wifi.c index 3f8b3c7b4..95ecae28e 100644 --- a/src/confd/src/if-wifi.c +++ b/src/confd/src/if-wifi.c @@ -274,7 +274,7 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net) iw = dagger_fopen_net_init(net, ifname, NETDAG_INIT_PRE, "wifi-iface.sh"); if (!iw) { - ERROR("Failed to open dagger file for WiFi interface creation"); + ERRNO("Failed to open dagger file for WiFi interface creation"); return SR_ERR_INTERNAL; } @@ -340,7 +340,7 @@ int wifi_del_iface(struct lyd_node *dif, struct dagger *net) iw = dagger_fopen_net_exit(net, ifname, NETDAG_EXIT_POST, "wifi-iface.sh"); if (!iw) { - ERROR("Failed to open dagger file for WiFi interface deletion"); + ERRNO("Failed to open dagger file for WiFi interface deletion"); return SR_ERR_INTERNAL; } diff --git a/src/confd/src/ntp.c b/src/confd/src/ntp.c index b50b57fb2..618de3393 100644 --- a/src/confd/src/ntp.c +++ b/src/confd/src/ntp.c @@ -61,7 +61,7 @@ static int change(sr_session_ctx_t *session, struct lyd_node *config, struct lyd fp = fopen(NTP_NEXT, "w"); if (!fp) { - ERROR("Failed creating %s: %s", NTP_NEXT, strerror(errno)); + ERRNO("Failed creating %s", NTP_NEXT); return SR_ERR_SYS; } diff --git a/src/confd/src/routing.c b/src/confd/src/routing.c index 1ef2a5f9e..8c01c9323 100644 --- a/src/confd/src/routing.c +++ b/src/confd/src/routing.c @@ -302,7 +302,7 @@ int parse_ospf(sr_session_ctx_t *session, struct lyd_node *ospf) fp = fopen(OSPFD_CONF_NEXT, "w"); if (!fp) { - ERROR("Failed to open %s", OSPFD_CONF_NEXT); + ERRNO("Failed to open %s", OSPFD_CONF_NEXT); return SR_ERR_INTERNAL; } @@ -450,7 +450,7 @@ static void frr_daemons_write(int ospfd, int ripd, int bfdd) fp = fopen(next, "w"); if (!fp) { - ERROR("Failed to open %s", next); + ERRNO("Failed to open %s", next); return; } @@ -493,7 +493,7 @@ static void frr_daemons_write(int ospfd, int ripd, int bfdd) fclose(fp); if (rename(next, FRR_DAEMONS)) - ERROR("Failed to rename %s to %s: %m", next, FRR_DAEMONS); + ERRNO("Failed to rename %s to %s", next, FRR_DAEMONS); } int routing_change(sr_session_ctx_t *session, struct lyd_node *config, struct lyd_node *diff, sr_event_t event, struct confd *confd) diff --git a/src/confd/src/system.c b/src/confd/src/system.c index 9af3327c9..b0b3701a1 100644 --- a/src/confd/src/system.c +++ b/src/confd/src/system.c @@ -476,7 +476,7 @@ static int change_dns(sr_session_ctx_t *session, struct lyd_node *config, struct fp = fopen(fn, "w"); if (!fp) { - ERROR("failed updating %s: %s", fn, strerror(errno)); + ERRNO("failed updating %s", fn); return SR_ERR_SYS; } @@ -1189,7 +1189,7 @@ static sr_error_t generate_auth_keys(sr_session_ctx_t *session, const char *xpat fp = fopenf("w", "/var/run/sshd/%s.keys", username); if (!fp) { - ERROR("failed opening user \"%s\" authorized_keys file: %s", username, strerror(errno)); + ERRNO("failed opening user \"%s\" authorized_keys file", username); continue; }