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 <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg
2026-01-25 11:15:44 +01:00
parent 480447c8f2
commit da80127ef0
+16 -5
View File
@@ -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;