Page MenuHomeFreeBSD

[net80211] Fix interrupted scan logic and ticks comparison
ClosedPublic

Authored by adrian on May 27 2020, 5:16 PM.

Details

Summary
  • The scan task refactoring stuff circa 2014-2016 broke the blocking task into a taskqueue with some async bits, but it apparently broke scans being interrupted by traffic.

    Notably - the new "field" SCAN_PAUSE sets both SCAN_INTERRUPT and SCAN_CANCEL, and a bunch of existing code was checking for SCAN_CANCEL only and breaking the scan. Unfortunately it was then (a) cancelling the scan entirely and (b) not notifying userland that scan was done.

    So:
    • Update the calls to scan_end() to only pass in 1 (saying the scan is complete) if SCAN_CANCEL is set WITHOUT SCAN_INTERRUPT. If both are set then yes, the scan is interrupted, but it isn't canceled - it's just paused.
    • Update the "did the scan flags change whilst the driver was called" logic to check for canceled scans, not interrupted scans.
    • the "scan done" logic now explicitly checks for either interrupted or completed scans. This accounts for the situation where a scan is being aborted via traffic but it ALSO happens to have finished (ie the last channel was checked.)

This doesn't ENTIRELY fix scanning as the resume function is broken
due to incorrect ticks math. Thus, the second half of this patch
changes the ieee80211_ticks_*() macros to use int instead of long,
matching the logic that the TCP code does with ticks and handles
wrapping / negative ticks values. If cast to long then the wrapping
math wouldn't work right (ie, if ticks was actually negative,
ie, after the system has been up for a while.)

This allows contbgscan() to correctly calculate if a scan should
continue based on ticks and ic_lastdata .

Test Plan
  • ath(4), AR9380, STA mode

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

adrian created this revision.May 27 2020, 5:16 PM
adrian requested review of this revision.May 27 2020, 5:17 PM
bz accepted this revision.May 27 2020, 5:28 PM
bz added a subscriber: bz.

Could make the flags bool instead of int but for the sake of minimal change for now, on a quick pass it looks ok.

This revision is now accepted and ready to land.May 27 2020, 5:28 PM
emaste added a subscriber: emaste.May 27 2020, 5:35 PM

Could make the flags bool instead of int

I'd argue for making that change here actually.

I'd like to land the MVP fix before I do a second pass to tidy this stuff up into separate flags..

This revision was automatically updated to reflect the committed changes.