From da80127ef0574eea4749d11610a174d59a09cab3 Mon Sep 17 00:00:00 2001 From: Joachim Wiberg Date: Fri, 23 Jan 2026 18:49:51 +0100 Subject: [PATCH] confd: use dummy interface in lieu of missing radios If we time out waiting for a wifi dongle, or onboard chipset, instead of causing fatal error in dagger and b0rking startup, we cheat and create a dummy interface. Also, fix bug in HEAD, the condition was == wifi_ap but the comment said "if not station or scanning mode". Since wpa_supplicant is for station mode (not AP), the cleanup should happen when != wifi_ap. Signed-off-by: Joachim Wiberg --- src/confd/src/if-wifi.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/src/confd/src/if-wifi.c b/src/confd/src/if-wifi.c index f6f54a88..84081f12 100644 --- a/src/confd/src/if-wifi.c +++ b/src/confd/src/if-wifi.c @@ -203,6 +203,18 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net) fprintf(iw, " timeout=$((timeout - 1))\n"); fprintf(iw, "done\n"); } + + /* + * If radio doesn't exist, create a dummy interface as placeholder. This allows all + * downstream config (IP addresses, etc.) to work. User must reboot when radio becomes + * available. + */ + fprintf(iw, "if ! iw phy %s info >/dev/null 2>&1; then\n", radio); + fprintf(iw, " logger -t wifi \"%s: radio %s not available, creating dummy placeholder\"\n", ifname, radio); + fprintf(iw, " ip link add %s type dummy\n", ifname); + fprintf(iw, " exit 0\n"); + fprintf(iw, "fi\n\n"); + switch(mode) { case wifi_station: fprintf(iw, "iw phy %s interface add %s type managed\n", radio, ifname); @@ -241,16 +253,15 @@ int wifi_del_iface(struct lyd_node *dif, struct dagger *net) } fprintf(iw, "# Generated by Infix confd - WiFi Interface Deletion\n"); - fprintf(iw, "ip link set %s down\n", ifname); /* Required to change modes. */ - fprintf(iw, "iw dev %s disconnect\n", ifname); - fprintf(iw, "iw dev %s del\n", ifname); + fprintf(iw, "ip link set %s down\n", ifname); + fprintf(iw, "iw dev %s disconnect 2>/dev/null\n", ifname); + fprintf(iw, "iw dev %s del 2>/dev/null || ip link del %s 2>/dev/null || true\n", ifname, ifname); wifi = lydx_get_child(dif, "wifi"); - if (wifi && wifi_get_mode(wifi) == wifi_ap) { /* if not station or scanning mode */ + if (wifi && wifi_get_mode(wifi) != wifi_ap) { erasef(WPA_SUPPLICANT_CONF, ifname); fprintf(iw, "initctl -bfq disable wifi@%s\n", ifname); } - fclose(iw); return SR_ERR_OK;