diff options
author | Felix Fietkau <nbd@openwrt.org> | 2010-11-22 14:58:24 -0500 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-11-24 16:19:35 -0500 |
commit | dd5b4cc71cd09c33e1579cc6d5720656e94e52de (patch) | |
tree | 86a27c86480109d9b6bbedddc083095035fbef2d /net/wireless/nl80211.c | |
parent | 46090979a55a0dc2cdb3d939f94fa47742108194 (diff) |
cfg80211/mac80211: improve ad-hoc multicast rate handling
- store the multicast rate as an index instead of the rate value
(reduces cpu overhead in a hotpath)
- validate the rate values (must match a bitrate in at least one sband)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'net/wireless/nl80211.c')
-rw-r--r-- | net/wireless/nl80211.c | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index b15eb77195d8..8734efa663d1 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
@@ -3600,6 +3600,34 @@ static int nl80211_disassociate(struct sk_buff *skb, struct genl_info *info) | |||
3600 | local_state_change); | 3600 | local_state_change); |
3601 | } | 3601 | } |
3602 | 3602 | ||
3603 | static bool | ||
3604 | nl80211_parse_mcast_rate(struct cfg80211_registered_device *rdev, | ||
3605 | int mcast_rate[IEEE80211_NUM_BANDS], | ||
3606 | int rateval) | ||
3607 | { | ||
3608 | struct wiphy *wiphy = &rdev->wiphy; | ||
3609 | bool found = false; | ||
3610 | int band, i; | ||
3611 | |||
3612 | for (band = 0; band < IEEE80211_NUM_BANDS; band++) { | ||
3613 | struct ieee80211_supported_band *sband; | ||
3614 | |||
3615 | sband = wiphy->bands[band]; | ||
3616 | if (!sband) | ||
3617 | continue; | ||
3618 | |||
3619 | for (i = 0; i < sband->n_bitrates; i++) { | ||
3620 | if (sband->bitrates[i].bitrate == rateval) { | ||
3621 | mcast_rate[band] = i + 1; | ||
3622 | found = true; | ||
3623 | break; | ||
3624 | } | ||
3625 | } | ||
3626 | } | ||
3627 | |||
3628 | return found; | ||
3629 | } | ||
3630 | |||
3603 | static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | 3631 | static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) |
3604 | { | 3632 | { |
3605 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; | 3633 | struct cfg80211_registered_device *rdev = info->user_ptr[0]; |
@@ -3683,9 +3711,11 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) | |||
3683 | return -EINVAL; | 3711 | return -EINVAL; |
3684 | } | 3712 | } |
3685 | } | 3713 | } |
3686 | if (info->attrs[NL80211_ATTR_MCAST_RATE]) | 3714 | |
3687 | ibss.mcast_rate = | 3715 | if (info->attrs[NL80211_ATTR_MCAST_RATE] && |
3688 | nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]); | 3716 | !nl80211_parse_mcast_rate(rdev, ibss.mcast_rate, |
3717 | nla_get_u32(info->attrs[NL80211_ATTR_MCAST_RATE]))) | ||
3718 | return -EINVAL; | ||
3689 | 3719 | ||
3690 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { | 3720 | if (ibss.privacy && info->attrs[NL80211_ATTR_KEYS]) { |
3691 | connkeys = nl80211_parse_connkeys(rdev, | 3721 | connkeys = nl80211_parse_connkeys(rdev, |