hostapd: fix unused device removal on DBDC devices
authorFelix Fietkau <nbd@nbd.name>
Thu, 3 Aug 2023 16:47:15 +0000 (18:47 +0200)
committerFelix Fietkau <nbd@nbd.name>
Thu, 3 Aug 2023 16:51:00 +0000 (18:51 +0200)
Check the phy before removing unrelated netdevs on the same hw device

Reported-by: Hartmut Birr <e9hack@gmail.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
package/network/services/hostapd/files/wdev.uc

index 9701af125aa904d71054c7327a28444ad582159f..896f5261fb978290eb00d4afb5390bdf2e32a3cb 100644 (file)
@@ -1,7 +1,7 @@
 #!/usr/bin/env ucode
 'use strict';
 import { vlist_new, is_equal, wdev_create, wdev_remove } from "/usr/share/hostap/common.uc";
-import { readfile, writefile, basename, glob } from "fs";
+import { readfile, writefile, basename, readlink, glob } from "fs";
 
 let keep_devices = {};
 let phy = shift(ARGV);
@@ -106,6 +106,9 @@ function add_existing(phy, config)
                if (config[wdev])
                        continue;
 
+               if (basename(readlink(`/sys/class/net/${wdev}/phy80211`)) != phy)
+                       continue;
+
                if (trim(readfile(`/sys/class/net/${wdev}/operstate`)) == "down")
                        config[wdev] = {};
        }