Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ All notable changes to the project are documented in this file.
- Changing the mode of a Wi-Fi interface, e.g., from station to mesh
point, made the whole configuration change fail to apply, although
the commit was reported as successful
- #1393: a radio can hold more than one Wi-Fi station interface as long
as only one of them is enabled. The others keep their settings, e.g.,
for another network, and are switched to with the `enabled` flag
- NanoPi R2S: the LAN port got a random MAC address on every boot
- `show interface` was slow, in particular on devices with a modem
- The octet counters of an interface stopped counting after a while,
Expand Down
8 changes: 5 additions & 3 deletions doc/wifi.md
Original file line number Diff line number Diff line change
Expand Up @@ -583,9 +583,11 @@ You can verify the configuration with `show hardware radio0` to see
radio settings, and `show interface` to see all active AP interfaces.

> [!NOTE]
> A radio hosts any number of access points but only one station, and
> the station follows its access point's channel, see [Current
> Limitations](#current-limitations).
> A radio hosts any number of access points but only one enabled
> station. More stations can be configured on it as long as they are
> disabled, e.g., to keep the settings for other networks and switch
> with the `enabled` flag. The station follows its access point's
> channel, see [Current Limitations](#current-limitations).

## Fast Roaming Between Access Points

Expand Down
35 changes: 27 additions & 8 deletions src/confd/src/if-wifi.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,29 @@ int wifi_mode_changed(struct lyd_node *wifi)
return 0;
}

/*
* The mode's wpa_supplicant runs only while the interface is enabled,
* another station on the radio may be the enabled one. A running
* instance keeps stale driver state on a recreated netdev, so restart.
*/
static void wifi_gen_service(FILE *fp, const char *svc, const char *ifname,
struct lyd_node *cif, bool restart)
{
if (!lydx_is_enabled(cif, "enabled")) {
fprintf(fp, "initctl -bfq disable %s@%s\n", svc, ifname);
fprintf(fp, "initctl -bnq stop %s:%s\n", svc, ifname);
fprintf(fp, "if pid=$(cat " WPA_SUPPLICANT_PID " 2>/dev/null); then\n"
"\ttimeout 5 sh -c \"while kill -0 $pid 2>/dev/null; do sleep 0.1; done\"\n"
"fi\n", ifname);
return;
}

fprintf(fp, "initctl -bfq enable %s@%s\n", svc, ifname);
fprintf(fp, "initctl -bfq touch %s@%s\n", svc, ifname);
if (restart)
fprintf(fp, "initctl -bnq restart %s:%s\n", svc, ifname);
}

/*
* A changed wpa_supplicant config only takes effect when the daemon
* reloads it, so nudge the service whenever the wifi subtree changed.
Expand All @@ -196,7 +219,7 @@ static int wifi_gen_reload(struct lyd_node *dif, struct lyd_node *cif, struct da
const char *svc;
FILE *fp;

if (!lydx_get_child(dif, "wifi"))
if (!lydx_get_child(dif, "wifi") && !lydx_get_child(dif, "enabled"))
return SR_ERR_OK;

switch (wifi_get_mode(cif)) {
Expand All @@ -216,7 +239,7 @@ static int wifi_gen_reload(struct lyd_node *dif, struct lyd_node *cif, struct da
if (!fp)
return SR_ERR_INTERNAL;

fprintf(fp, "initctl -bfq touch %s@%s\n", svc, ifname);
wifi_gen_service(fp, svc, ifname, cif, false);
fclose(fp);

return SR_ERR_OK;
Expand Down Expand Up @@ -712,9 +735,7 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net)
if (!station)
break; /* No mode yet, the netdev is created but idle */
wifi_gen_station(cif);
fprintf(iw, "initctl -bfq enable station@%s\n", ifname);
fprintf(iw, "initctl -bfq touch station@%s\n", ifname);
fprintf(iw, "initctl -bnq restart station:%s\n", ifname);
wifi_gen_service(iw, "station", ifname, cif, true);
break;
}
case wifi_wds: {
Expand All @@ -732,9 +753,7 @@ int wifi_add_iface(struct lyd_node *cif, struct dagger *net)
case wifi_mesh:
fprintf(iw, "iw phy %s interface add %s type mesh%s\n", radio, ifname, addr);
wifi_gen_mesh(cif);
fprintf(iw, "initctl -bfq enable mesh@%s\n", ifname);
fprintf(iw, "initctl -bfq touch mesh@%s\n", ifname);
fprintf(iw, "initctl -bnq restart mesh:%s\n", ifname);
wifi_gen_service(iw, "mesh", ifname, cif, true);
break;
default:
ERROR("WiFi mode %d unknown", mode);
Expand Down
11 changes: 9 additions & 2 deletions src/confd/yang/confd/infix-if-wifi.yang
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ submodule infix-if-wifi {
- Security: WPA2/WPA3 with keystore integration
- Operational state: Connection status, RSSI, client lists";

revision 2026-11-02 {
description
"A radio may hold several station or mesh point interfaces as long
as only one of them is enabled.";
reference "internal";
}

revision 2026-10-06 {
description
"Access point and mesh point require the box-wide Wi-Fi country code,
Expand Down Expand Up @@ -163,8 +170,8 @@ submodule infix-if-wifi {
must "derived-from-or-self(/iehw:hardware/iehw:component[iehw:name=current()]/iehw:class, 'ih:wifi')" {
error-message "Referenced hardware component must be a Wi-Fi radio (class 'ih:wifi')";
}
must "count(/if:interfaces/if:interface[wifi/radio = current()][not(wifi/access-point)][not(wifi/wds-link)]) <= 1" {
error-message "Only one station interface is allowed per radio";
must "count(/if:interfaces/if:interface[wifi/radio = current()][not(wifi/access-point)][not(wifi/wds-link)][if:enabled = 'true']) <= 1" {
error-message "Only one enabled station interface is allowed per radio";
}

description
Expand Down