aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFelix Fietkau <nbd@nbd.name>2023-11-08 11:20:41 +0100
committerFelix Fietkau <nbd@nbd.name>2023-11-08 12:47:46 +0100
commit6de0e0d01aeafc1903396cf3265b5a444d132a8a (patch)
treedcb1c8bda1d0b7983c5375284725a149859404ca
parentbbfb920e99672564ea244769e6636fab65511703 (diff)
downloadupstream-6de0e0d01aeafc1903396cf3265b5a444d132a8a.tar.gz
upstream-6de0e0d01aeafc1903396cf3265b5a444d132a8a.tar.bz2
upstream-6de0e0d01aeafc1903396cf3265b5a444d132a8a.zip
hostapd: use rtnl to set up interfaces
In wpa_supplicant, set up wlan interfaces before adding them Signed-off-by: Felix Fietkau <nbd@nbd.name> (cherry picked from commit c2a30b6e01aa756cd7d50c578ab4344c725ecc59)
-rw-r--r--package/network/services/hostapd/files/common.uc7
-rw-r--r--package/network/services/hostapd/files/wdev.uc6
-rw-r--r--package/network/services/hostapd/files/wpa_supplicant.uc3
3 files changed, 11 insertions, 5 deletions
diff --git a/package/network/services/hostapd/files/common.uc b/package/network/services/hostapd/files/common.uc
index 8399d3ff96..4c33779af9 100644
--- a/package/network/services/hostapd/files/common.uc
+++ b/package/network/services/hostapd/files/common.uc
@@ -144,6 +144,11 @@ function wdev_set_mesh_params(name, data)
return nl80211.error();
}
+function wdev_set_up(name, up)
+{
+ rtnl.request(rtnl.const.RTM_SETLINK, 0, { dev: name, change: 1, flags: up ? 1 : 0 });
+}
+
function phy_sysfs_file(phy, name)
{
return trim(readfile(`/sys/class/ieee80211/${phy}/${name}`));
@@ -365,4 +370,4 @@ function vlist_new(cb) {
}, vlist_proto);
}
-export { wdev_remove, wdev_create, wdev_set_mesh_params, is_equal, vlist_new, phy_is_fullmac, phy_open };
+export { wdev_remove, wdev_create, wdev_set_mesh_params, wdev_set_up, is_equal, vlist_new, phy_is_fullmac, phy_open };
diff --git a/package/network/services/hostapd/files/wdev.uc b/package/network/services/hostapd/files/wdev.uc
index 800bb32d24..ff4d629fd6 100644
--- a/package/network/services/hostapd/files/wdev.uc
+++ b/package/network/services/hostapd/files/wdev.uc
@@ -1,6 +1,6 @@
#!/usr/bin/env ucode
'use strict';
-import { vlist_new, is_equal, wdev_create, wdev_set_mesh_params, wdev_remove, phy_open } from "/usr/share/hostap/common.uc";
+import { vlist_new, is_equal, wdev_create, wdev_set_mesh_params, wdev_remove, wdev_set_up, phy_open } from "/usr/share/hostap/common.uc";
import { readfile, writefile, basename, readlink, glob } from "fs";
let libubus = require("ubus");
@@ -22,7 +22,7 @@ function iface_start(wdev)
let ifname = wdev.ifname;
if (readfile(`/sys/class/net/${ifname}/ifindex`)) {
- system([ "ip", "link", "set", "dev", ifname, "down" ]);
+ wdev_set_up(ifname, false);
wdev_remove(ifname);
}
let wdev_config = {};
@@ -31,7 +31,7 @@ function iface_start(wdev)
if (!wdev_config.macaddr && wdev.mode != "monitor")
wdev_config.macaddr = phydev.macaddr_next();
wdev_create(phy, ifname, wdev_config);
- system([ "ip", "link", "set", "dev", ifname, "up" ]);
+ wdev_set_up(ifname, true);
if (wdev.freq)
system(`iw dev ${ifname} set freq ${wdev.freq} ${wdev.htmode}`);
if (wdev.mode == "adhoc") {
diff --git a/package/network/services/hostapd/files/wpa_supplicant.uc b/package/network/services/hostapd/files/wpa_supplicant.uc
index c3fd73dfee..d624f27cdd 100644
--- a/package/network/services/hostapd/files/wpa_supplicant.uc
+++ b/package/network/services/hostapd/files/wpa_supplicant.uc
@@ -1,6 +1,6 @@
let libubus = require("ubus");
import { open, readfile } from "fs";
-import { wdev_create, wdev_set_mesh_params, wdev_remove, is_equal, vlist_new, phy_open } from "common";
+import { wdev_create, wdev_set_mesh_params, wdev_remove, is_equal, wdev_set_up, vlist_new, phy_open } from "common";
let ubus = libubus.connect();
@@ -40,6 +40,7 @@ function iface_start(phydev, iface, macaddr_list)
let ret = wdev_create(phy, ifname, wdev_config);
if (ret)
wpas.printf(`Failed to create device ${ifname}: ${ret}`);
+ wdev_set_up(ifname, true);
wpas.add_iface(iface.config);
iface.running = true;
}