1
1

wifi-scripts: iwinfo scan() must not abort the interpreter on failure

Replace exit(1) on every failure path with return null so callers that
iterate over multiple radios can collect results from the radios that
did succeed instead of aborting on the first one that refuses an
off-channel scan.

Route diagnostics to stderr via warn() so stdout stays clean for
callers parsing JSON output, and include the device name in each
message to disambiguate per-radio failures.

Signed-off-by: John Crispin <john@phrozen.org>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
This commit is contained in:
John Crispin 2026-04-14 13:30:41 +02:00 committed by Felix Fietkau
parent cb7414055c
commit 0c2fb39c5a

View File

@ -577,23 +577,24 @@ export function scan(dev) {
scan_ssids: [ '' ], scan_ssids: [ '' ],
}; };
let res = nl80211.request(nl80211.const.NL80211_CMD_TRIGGER_SCAN, 0, params); nl80211.request(nl80211.const.NL80211_CMD_TRIGGER_SCAN, 0, params);
if (res === false) { let err = nl80211.error();
printf("Unable to trigger scan: " + nl80211.error() + "\n"); if (err) {
exit(1); warn("Unable to trigger scan on " + dev + ": " + err + "\n");
return null;
} }
res = nl80211.waitfor([ let res = nl80211.waitfor([
nl80211.const.NL80211_CMD_NEW_SCAN_RESULTS, nl80211.const.NL80211_CMD_NEW_SCAN_RESULTS,
nl80211.const.NL80211_CMD_SCAN_ABORTED nl80211.const.NL80211_CMD_SCAN_ABORTED
], 5000); ], 5000);
if (!res) { if (!res) {
printf("Netlink error while awaiting scan results: " + nl80211.error() + "\n"); warn("Netlink error while awaiting scan results on " + dev + ": " + nl80211.error() + "\n");
exit(1); return null;
} else if (res.cmd == nl80211.const.NL80211_CMD_SCAN_ABORTED) { } else if (res.cmd == nl80211.const.NL80211_CMD_SCAN_ABORTED) {
printf("Scan aborted by kernel\n"); warn("Scan aborted by kernel on " + dev + "\n");
exit(1); return null;
} }
let scan = nl80211.request(nl80211.const.NL80211_CMD_GET_SCAN, nl80211.const.NLM_F_DUMP, { dev }); let scan = nl80211.request(nl80211.const.NL80211_CMD_GET_SCAN, nl80211.const.NLM_F_DUMP, { dev });