mac80211: pass all probe request IEs to driver
Subsystems (2)
Johannes Berg
maintainerPATCH 1/1 mac80211: pass all probe request IEs to driver
Instead of just passing the cfg80211-requested IEs, pass the locally generated ones as well.
Signed-off-by Johannes Berg <[email protected]>
--- include/net/mac80211.h | 13 +++++--- net/mac80211/ieee80211_i.h | 6 +++ net/mac80211/main.c | 8 +---- net/mac80211/scan.c | 21 ++++++++++++- net/mac80211/util.c | 72 ++++++++++++++++++++++++++------------------- 5 files changed, 79 insertions(+), 41 deletions(-)
include/net/mac80211.h +8 -5
@@ -1330,11 +1330,14 @@ enum ieee80211_ampdu_mlme_action {* the scan state machine in stack. The scan must honour the channel * configuration done by the regulatory agent in the wiphy's * registered bands. The hardware (or the driver) needs to make sure -* that power save is disabled. When the scan finishes, -* ieee80211_scan_completed() must be called; note that it also must -* be called when the scan cannot finish because the hardware is -* turned off! Anything else is a bug! Returns a negative error code -* which will be seen in userspace. +* that power save is disabled. +* The @req ie/ie_len members are rewritten by mac80211 to contain the +* entire IEs after the SSID, so that drivers need not look at these +* at all but just send them after the SSID -- mac80211 includes the +* (extended) supported rates and HT information (where applicable). +* When the scan finishes, ieee80211_scan_completed() must be called; +* note that it also must be called when the scan cannot finish due to +* any error unless this callback returned a negative error code. * * @sw_scan_start: Notifier function that is called just before a software scan * is started. Can be NULL, if the driver doesn't need this notification.
net/mac80211/ieee80211_i.h +6 -0
@@ -51,6 +51,10 @@ struct ieee80211_local;* increased memory use (about 2 kB of RAM per entry). */ #define IEEE80211_FRAGMENT_MAX 4 +/* cfg80211 only supports 32 rates */ +#define MAC80211_PREQ_IE_LEN ( 2 + 32/* SSID */ \ + + 4 + 32 /* (ext) supp rates */) +/* * Time after which we ignore scan results and no longer report/use * them in any way.
@@ -1093,6 +1097,8 @@ void ieee80211_send_auth(struct ieee8021 u16 transaction, u16 auth_alg, u8 *extra, size_t extra_len, const u8 *bssid, int encrypt); +int ieee80211_build_preq_ies (struct ieee80211_local *local,u8 *buffer, +u8 *ie,size_t ie_len);void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst,u8 *ssid,size_t ssid_len,u8 *ie,size_t ie_len);
net/mac80211/util.c +43 -29
92 lines not on this page · raw message
net/mac80211/main.c +2 -6
@@ -728,12 +728,8 @@ struct ieee80211_hw *ieee80211_alloc_hw(if (!ops->hw_scan) {/* For hw_scan, driver needs to set these up. */ wiphy->max_scan_ssids =4 ; - -/* we support a maximum of 32 rates in cfg80211 */ - wiphy->max_scan_ie_len =IEEE80211_MAX_DATA_LEN - -2 -32 /* SSID */ - -4 -32 /* (ext) supp rates */ ; - + wiphy->max_scan_ie_len =IEEE80211_MAX_DATA_LEN - +MAC80211_PREQ_IE_LEN ; }/* Yes, putting cfg80211_bss into ieee80211_bss is a hack */
net/mac80211/scan.c +20 -1
@@ -286,6 +286,12 @@ void ieee80211_scan_completed(struct ieeif (WARN_ON (!local->scan_req))return ; +if (local->hw_scanning) { +kfree (local->scan_req->ie); + local->scan_req->ie =NULL ; + local->scan_req->ie_len =0 ; + } +if (local->scan_req != &local->int_scan_req)cfg80211_scan_done (local->scan_req, aborted); local->scan_req =NULL ;
@@ -456,12 +462,25 @@ int ieee80211_start_scan(struct ieee8021 }if (local->ops->hw_scan) { -int rc; +u8 *ies; +int rc, ielen; + + ies =kmalloc (MAC80211_PREQ_IE_LEN + req->ie_len,GFP_KERNEL ); +if (!ies) +return -ENOMEM ; + + ielen =ieee80211_build_preq_ies (local, ies, + req->ie, req->ie_len); + req->ie = ies; + req->ie_len = ielen; local->hw_scanning = true; rc =drv_hw_scan (local, req);if (rc) { local->hw_scanning = false; +kfree (ies); + req->ie_len =0 ; + req->ie =NULL ;return rc; } local->scan_sdata = scan_sdata;
Johannes Berg
maintainerPATCH v2 1/1 mac80211: pass all probe request IEs to driver
Instead of just passing the cfg80211-requested IEs, pass the locally generated ones as well.
Signed-off-by Johannes Berg <[email protected]>
---
v2: * assume wiphy->max_scan_ie_len contains the limit *including*
the IEs mac80211 passes (since the driver cannot know how long those will be) and adjust the driver's limit accordingly
* keep track of original IEs and hand back the pristine cfg80211 request structure
* mark the IE pointer const in the request struct
include/net/cfg80211.h | 2 - include/net/mac80211.h | 13 ++++--- net/mac80211/ieee80211_i.h | 12 +++++-- net/mac80211/main.c | 16 +++++---- net/mac80211/scan.c | 23 +++++++++++++ net/mac80211/util.c | 76 ++++++++++++++++++++++++++------------------- net/wireless/nl80211.c | 3 + 7 files changed, 98 insertions(+), 47 deletions(-)
include/net/mac80211.h +8 -5
@@ -1330,11 +1330,14 @@ enum ieee80211_ampdu_mlme_action {* the scan state machine in stack. The scan must honour the channel * configuration done by the regulatory agent in the wiphy's * registered bands. The hardware (or the driver) needs to make sure -* that power save is disabled. When the scan finishes, -* ieee80211_scan_completed() must be called; note that it also must -* be called when the scan cannot finish because the hardware is -* turned off! Anything else is a bug! Returns a negative error code -* which will be seen in userspace. +* that power save is disabled. +* The @req ie/ie_len members are rewritten by mac80211 to contain the +* entire IEs after the SSID, so that drivers need not look at these +* at all but just send them after the SSID -- mac80211 includes the +* (extended) supported rates and HT information (where applicable). +* When the scan finishes, ieee80211_scan_completed() must be called; +* note that it also must be called when the scan cannot finish due to +* any error unless this callback returned a negative error code. * * @sw_scan_start: Notifier function that is called just before a software scan * is started. Can be NULL, if the driver doesn't need this notification.
net/mac80211/ieee80211_i.h +10 -2
@@ -51,6 +51,10 @@ struct ieee80211_local;* increased memory use (about 2 kB of RAM per entry). */ #define IEEE80211_FRAGMENT_MAX 4 +/* cfg80211 only supports 32 rates */ +#define MAC80211_PREQ_IE_LEN ( 2 + 32/* SSID */ \ + + 4 + 32 /* (ext) supp rates */) +/* * Time after which we ignore scan results and no longer report/use * them in any way.
@@ -671,6 +675,8 @@ struct ieee80211_local {struct cfg80211_scan_request int_scan_req;struct cfg80211_scan_request *scan_req;struct ieee80211_channel *scan_channel; +const u8 *orig_ies; +int orig_ies_len;int scan_channel_idx;enum {SCAN_SET_CHANNEL ,SCAN_SEND_PROBE } scan_state;
@@ -1093,9 +1099,11 @@ void ieee80211_send_auth(struct ieee8021 u16 transaction, u16 auth_alg, u8 *extra, size_t extra_len, const u8 *bssid, int encrypt); +int ieee80211_build_preq_ies (struct ieee80211_local *local,u8 *buffer, +const u8 *ie,size_t ie_len);void ieee80211_send_probe_req (struct ieee80211_sub_if_data *sdata,u8 *dst, -u8 *ssid,size_t ssid_len, -u8 *ie,size_t ie_len); +const u8 *ssid,size_t ssid_len, +const u8 *ie,size_t ie_len); void ieee80211_sta_def_wmm_params(struct ieee80211_sub_if_data *sdata, const size_t supp_rates_len,
net/mac80211/util.c +45 -31
94 lines not on this page · raw message
net/mac80211/main.c +10 -6
@@ -728,13 +728,17 @@ struct ieee80211_hw *ieee80211_alloc_hw(if (!ops->hw_scan) {/* For hw_scan, driver needs to set these up. */ wiphy->max_scan_ssids =4 ; - -/* we support a maximum of 32 rates in cfg80211 */ - wiphy->max_scan_ie_len =IEEE80211_MAX_DATA_LEN - -2 -32 /* SSID */ - -4 -32 /* (ext) supp rates */ ; - + wiphy->max_scan_ie_len =IEEE80211_MAX_DATA_LEN ; } +/* +* If the driver supports any scan IEs, then assume the +* limit includes the IEs mac80211 will add, otherwise +* leave it at zero and let the driver sort it out; we +* still pass our IEs to the driver but userspace will +* not be allowed to in that case. +*/ +if (wiphy->max_scan_ie_len) + wiphy->max_scan_ie_len -=MAC80211_PREQ_IE_LEN ;/* Yes, putting cfg80211_bss into ieee80211_bss is a hack */ wiphy->bss_priv_size = sizeof(struct ieee80211_bss) -
net/mac80211/scan.c +22 -1
@@ -286,6 +286,12 @@ void ieee80211_scan_completed(struct ieeif (WARN_ON (!local->scan_req))return ; +if (local->hw_scanning) { +kfree (local->scan_req->ie); + local->scan_req->ie = local->orig_ies; + local->scan_req->ie_len = local->orig_ies_len; + } +if (local->scan_req != &local->int_scan_req)cfg80211_scan_done (local->scan_req, aborted); local->scan_req =NULL ;
@@ -456,12 +462,27 @@ int ieee80211_start_scan(struct ieee8021 }if (local->ops->hw_scan) { -int rc; +u8 *ies; +int rc, ielen; + + ies =kmalloc (MAC80211_PREQ_IE_LEN + req->ie_len,GFP_KERNEL ); +if (!ies) +return -ENOMEM ; + + ielen =ieee80211_build_preq_ies (local, ies, + req->ie, req->ie_len); + local->orig_ies = req->ie; + local->orig_ies_len = req->ie_len; + req->ie = ies; + req->ie_len = ielen; local->hw_scanning = true; rc =drv_hw_scan (local, req);if (rc) { local->hw_scanning = false; +kfree (ies); + req->ie_len = local->orig_ies_len; + req->ie = local->orig_ies;return rc; } local->scan_sdata = scan_sdata;
include/net/cfg80211.h +1 -1
@@ -504,7 +504,7 @@ struct cfg80211_scan_request {int n_ssids;struct ieee80211_channel **channels;u32 n_channels; -u8 *ie; +const u8 *ie;size_t ie_len;/* internal */
net/wireless/nl80211.c +2 -1
@@ -2561,7 +2561,8 @@ static int nl80211_trigger_scan(struct sif (info->attrs[NL80211_ATTR_IE ]) { request->ie_len =nla_len (info->attrs[NL80211_ATTR_IE ]); -memcpy (request->ie,nla_data (info->attrs[NL80211_ATTR_IE ]), +memcpy ((void *)request->ie, +nla_data (info->attrs[NL80211_ATTR_IE ]), request->ie_len); }