[PATCH] Fix a channel-to-frequency transformation in ieee80211_chan_to_freq()
kkangshawn at gmail.com
Sun Feb 19 07:34:00 PST 2017
>> - int freq;
>> + if (country_match(us_op_class_cc, country))
> In addition, this is whitespace damaged (tabs converted to a single
> space), so I cannot apply it.
At first, I am very sorry about the whitespace. I should have rather attached
the patch file than copy-and-paste the contents. I used to upload through
git send-email but it is blocked by gmail now. Please kindly use attached
file for the patch work.
> Does this fix something externally observable? It looks like the current
> design of the function uses the global table as a backup path on
> purpose. As such, I would rather not modify this unless there is a
> clearly identifiable misbehavior and/or no chances of breaking some
> existing use cases.
The externally observable malfunction is the set provided in the patch as
an example. As you know well, the US regulatory does not allow ch 12
and 13 so this function shall return -1 if the country code is explicitly
given as 'US' just like that -1 is returned for channel 14 when CC is in the
set of 'us' or 'eu'. However, it currently returns 2467 or 2472 for the input
12 or 13 + US so that it looks those channels are allowed. The header
comments says the return must be -1 if the specified channel is unknown.
Since the channel 12, 13 are unknown in US, it shall return -1.
As well as it shouldn't use global table as a backup path because, as
stated in a doxygen format description, the function uses global op_class
only if the country code is unknown. In above case it specifies the known
country code - US so it should not use global op_class.
* ieee80211_chan_to_freq - Convert channel info to frequency
* @country: Country code, if known; otherwise, global operating class is used
* @op_class: Operating class
* @chan: Channel number
* Returns: Frequency in MHz or -1 if the specified channel is unknown
FYI, I am making an API utiliizing this function. If this function
values for the channels not allowed in the region, I have to add check routine
for channels' validity which is major advantage of using this function. I'd very
appreciate if you could kindly take your precious time for a careful review.
More information about the Hostap