diff options
author | Luis R. Rodriguez <lrodriguez@atheros.com> | 2009-01-07 20:43:36 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2009-01-16 17:08:24 -0500 |
commit | 0c7dc45d21de6ae212b5ccb7cdff5beff795ccf0 (patch) | |
tree | d8b8f72105da3cd3dc07e9499ddc0da7a61d75f6 /net/wireless/reg.c | |
parent | a92a3ce72483d7f0902dff8a3be8cdcee215a37c (diff) |
cfg80211: Fix regression with 11d on bands
This fixes a regression on disallowing bands introduced with the new
802.11d support. The issue is that IEEE-802.11 allows APs to send
a subset of what a country regulatory domain defines. This was clarified
in this document:
http://tinyurl.com/11d-clarification
As such it is possible, and this is what is done in practice, that a
single band 2.4 GHz AP will only send 2.4 GHz band regulatory information
through the 802.11 country information element and then the current
intersection with what CRDA provided yields a regulatory domain with
no 5 GHz information -- even though that country may actually allow
5 GHz operation. We correct this by only applying the intersection rules
on a channel if the the intersection yields a regulatory rule on the
same band the channel is on.
Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r-- | net/wireless/reg.c | 82 |
1 files changed, 79 insertions, 3 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index af805b0e1579..5f6d20d98eeb 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -421,6 +421,31 @@ static u32 freq_max_bandwidth(const struct ieee80211_freq_range *freq_range, | |||
421 | return 0; | 421 | return 0; |
422 | } | 422 | } |
423 | 423 | ||
424 | /** | ||
425 | * freq_in_rule_band - tells us if a frequency is in a frequency band | ||
426 | * @freq_range: frequency rule we want to query | ||
427 | * @freq_khz: frequency we are inquiring about | ||
428 | * | ||
429 | * This lets us know if a specific frequency rule is or is not relevant to | ||
430 | * a specific frequency's band. Bands are device specific and artificial | ||
431 | * definitions (the "2.4 GHz band" and the "5 GHz band"), however it is | ||
432 | * safe for now to assume that a frequency rule should not be part of a | ||
433 | * frequency's band if the start freq or end freq are off by more than 2 GHz. | ||
434 | * This resolution can be lowered and should be considered as we add | ||
435 | * regulatory rule support for other "bands". | ||
436 | **/ | ||
437 | static bool freq_in_rule_band(const struct ieee80211_freq_range *freq_range, | ||
438 | u32 freq_khz) | ||
439 | { | ||
440 | #define ONE_GHZ_IN_KHZ 1000000 | ||
441 | if (abs(freq_khz - freq_range->start_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) | ||
442 | return true; | ||
443 | if (abs(freq_khz - freq_range->end_freq_khz) <= (2 * ONE_GHZ_IN_KHZ)) | ||
444 | return true; | ||
445 | return false; | ||
446 | #undef ONE_GHZ_IN_KHZ | ||
447 | } | ||
448 | |||
424 | /* Converts a country IE to a regulatory domain. A regulatory domain | 449 | /* Converts a country IE to a regulatory domain. A regulatory domain |
425 | * structure has a lot of information which the IE doesn't yet have, | 450 | * structure has a lot of information which the IE doesn't yet have, |
426 | * so for the other values we use upper max values as we will intersect | 451 | * so for the other values we use upper max values as we will intersect |
@@ -748,12 +773,23 @@ static u32 map_regdom_flags(u32 rd_flags) | |||
748 | * this value to the maximum allowed bandwidth. | 773 | * this value to the maximum allowed bandwidth. |
749 | * @reg_rule: the regulatory rule which we have for this frequency | 774 | * @reg_rule: the regulatory rule which we have for this frequency |
750 | * | 775 | * |
751 | * Use this function to get the regulatory rule for a specific frequency. | 776 | * Use this function to get the regulatory rule for a specific frequency on |
777 | * a given wireless device. If the device has a specific regulatory domain | ||
778 | * it wants to follow we respect that unless a country IE has been received | ||
779 | * and processed already. | ||
780 | * | ||
781 | * Returns 0 if it was able to find a valid regulatory rule which does | ||
782 | * apply to the given center_freq otherwise it returns non-zero. It will | ||
783 | * also return -ERANGE if we determine the given center_freq does not even have | ||
784 | * a regulatory rule for a frequency range in the center_freq's band. See | ||
785 | * freq_in_rule_band() for our current definition of a band -- this is purely | ||
786 | * subjective and right now its 802.11 specific. | ||
752 | */ | 787 | */ |
753 | static int freq_reg_info(u32 center_freq, u32 *bandwidth, | 788 | static int freq_reg_info(u32 center_freq, u32 *bandwidth, |
754 | const struct ieee80211_reg_rule **reg_rule) | 789 | const struct ieee80211_reg_rule **reg_rule) |
755 | { | 790 | { |
756 | int i; | 791 | int i; |
792 | bool band_rule_found = false; | ||
757 | u32 max_bandwidth = 0; | 793 | u32 max_bandwidth = 0; |
758 | 794 | ||
759 | if (!cfg80211_regdomain) | 795 | if (!cfg80211_regdomain) |
@@ -767,7 +803,15 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth, | |||
767 | rr = &cfg80211_regdomain->reg_rules[i]; | 803 | rr = &cfg80211_regdomain->reg_rules[i]; |
768 | fr = &rr->freq_range; | 804 | fr = &rr->freq_range; |
769 | pr = &rr->power_rule; | 805 | pr = &rr->power_rule; |
806 | |||
807 | /* We only need to know if one frequency rule was | ||
808 | * was in center_freq's band, that's enough, so lets | ||
809 | * not overwrite it once found */ | ||
810 | if (!band_rule_found) | ||
811 | band_rule_found = freq_in_rule_band(fr, center_freq); | ||
812 | |||
770 | max_bandwidth = freq_max_bandwidth(fr, center_freq); | 813 | max_bandwidth = freq_max_bandwidth(fr, center_freq); |
814 | |||
771 | if (max_bandwidth && *bandwidth <= max_bandwidth) { | 815 | if (max_bandwidth && *bandwidth <= max_bandwidth) { |
772 | *reg_rule = rr; | 816 | *reg_rule = rr; |
773 | *bandwidth = max_bandwidth; | 817 | *bandwidth = max_bandwidth; |
@@ -775,6 +819,9 @@ static int freq_reg_info(u32 center_freq, u32 *bandwidth, | |||
775 | } | 819 | } |
776 | } | 820 | } |
777 | 821 | ||
822 | if (!band_rule_found) | ||
823 | return -ERANGE; | ||
824 | |||
778 | return !max_bandwidth; | 825 | return !max_bandwidth; |
779 | } | 826 | } |
780 | 827 | ||
@@ -799,8 +846,37 @@ static void handle_channel(struct wiphy *wiphy, enum ieee80211_band band, | |||
799 | &max_bandwidth, ®_rule); | 846 | &max_bandwidth, ®_rule); |
800 | 847 | ||
801 | if (r) { | 848 | if (r) { |
802 | flags |= IEEE80211_CHAN_DISABLED; | 849 | /* This means no regulatory rule was found in the country IE |
803 | chan->flags = flags; | 850 | * with a frequency range on the center_freq's band, since |
851 | * IEEE-802.11 allows for a country IE to have a subset of the | ||
852 | * regulatory information provided in a country we ignore | ||
853 | * disabling the channel unless at least one reg rule was | ||
854 | * found on the center_freq's band. For details see this | ||
855 | * clarification: | ||
856 | * | ||
857 | * http://tinyurl.com/11d-clarification | ||
858 | */ | ||
859 | if (r == -ERANGE && | ||
860 | last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) { | ||
861 | #ifdef CONFIG_CFG80211_REG_DEBUG | ||
862 | printk(KERN_DEBUG "cfg80211: Leaving channel %d MHz " | ||
863 | "intact on %s - no rule found in band on " | ||
864 | "Country IE\n", | ||
865 | chan->center_freq, wiphy_name(wiphy)); | ||
866 | #endif | ||
867 | } else { | ||
868 | /* In this case we know the country IE has at least one reg rule | ||
869 | * for the band so we respect its band definitions */ | ||
870 | #ifdef CONFIG_CFG80211_REG_DEBUG | ||
871 | if (last_request->initiator == REGDOM_SET_BY_COUNTRY_IE) | ||
872 | printk(KERN_DEBUG "cfg80211: Disabling " | ||
873 | "channel %d MHz on %s due to " | ||
874 | "Country IE\n", | ||
875 | chan->center_freq, wiphy_name(wiphy)); | ||
876 | #endif | ||
877 | flags |= IEEE80211_CHAN_DISABLED; | ||
878 | chan->flags = flags; | ||
879 | } | ||
804 | return; | 880 | return; |
805 | } | 881 | } |
806 | 882 | ||