Bug 202502

Summary: [net80211] [patch]: check and reset (if necessary) currently selected channel before device initialization
Product: Base System Reporter: Andriy Voskoboinyk <avos>
Component: wirelessAssignee: freebsd-wireless (Nobody) <wireless>
Status: Closed FIXED    
Severity: Affects Only Me CC: adrian
Priority: --- Keywords: patch
Version: CURRENT   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
Fix the issue and remove workaround from the wpi driver none

Description Andriy Voskoboinyk freebsd_committer freebsd_triage 2015-08-19 23:38:57 UTC
Created attachment 160122 [details]
Fix the issue and remove workaround from the wpi driver

In case, when interface is recreated (create -> destroy -> create), some values (like ic->ic_curchan) are left unchanged and may be incompatible with new mode.

As an example:
1) ifconfig wlan0 create wlandev <dev> wlanmode ahdemo channel <some NOADHOC channel>
2) ifconfig wlan0 destroy
3) ifconfig wlan0 create wlandev <dev> wlanmode ibss ssid ssid
4) ifconfig wlan0 up

may result in incorrect ic->ic_curchan value passed into driver and may lead to crash (for example, wpi firmware throws an error here).

This patch adds a check into ieee80211_start_locked() and resets ic->ic_curchan to &ic->ic_channels[0] when the channel is incompatible with current mode.
Comment 1 commit-hook freebsd_committer freebsd_triage 2015-08-23 01:18:48 UTC
A commit references this bug:

Author: adrian
Date: Sun Aug 23 01:17:53 UTC 2015
New revision: 287029
URL: https://svnweb.freebsd.org/changeset/base/287029

Log:
  Reset the channel to the first available channel if the interface
  is configured on a channel that isn't valid in the new operating mode.

  This isn't strictly true - it should find the first channel that is
  available for the given operating mode.

  However, I think defaulting to the first channel is fine - it's typically
  available for all modes.

  If someone would like to correctly implement this feature - try to
  find a channel that is valid for the given operating mode and error
  out if we can't find one.

  This prevents various NICs (eg wpi(4)) from throwing a firmware error.

  Tested:

  * ath(4), STA/AP mode
  * iwn(4), STA/adhoc mode

  PR:		kern/202502
  Submitted by:	Andriy Voskoboinyk <s3erios@gmail.com>

Changes:
  head/sys/net80211/ieee80211_proto.c