diff options
-rw-r--r-- | package/network/services/hostapd/files/common.uc | 7 | ||||
-rw-r--r-- | package/network/services/hostapd/files/wdev.uc | 6 | ||||
-rw-r--r-- | package/network/services/hostapd/files/wpa_supplicant.uc | 3 |
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; } |