Commit d45c4172 authored by Emmanuel Grumbach's avatar Emmanuel Grumbach Committed by Johannes Berg

mac82011: use frame control to differentiate probe resp/beacon

The probe response/beacon management frame RX code passes a
bool parameter to differentiate beacons and probe responses.
This is useless since we have the frame and can thus use its
frame control field. Moreover it is buggy since there is one
call to ieee80211_rx_bss_info with a beacon frame that is
indicated as a probe response, which is also fixed by using
the frame control field, so do that.
Signed-off-by: default avatarEmmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cc3983d8
...@@ -425,11 +425,9 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata, ...@@ -425,11 +425,9 @@ static void ieee80211_rx_mgmt_auth_ibss(struct ieee80211_sub_if_data *sdata,
} }
static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, struct ieee80211_mgmt *mgmt, size_t len,
size_t len,
struct ieee80211_rx_status *rx_status, struct ieee80211_rx_status *rx_status,
struct ieee802_11_elems *elems, struct ieee802_11_elems *elems)
bool beacon)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int freq; int freq;
...@@ -530,7 +528,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -530,7 +528,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
} }
bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
channel, beacon); channel);
if (!bss) if (!bss)
return; return;
...@@ -877,14 +875,21 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata, ...@@ -877,14 +875,21 @@ static void ieee80211_rx_mgmt_probe_req(struct ieee80211_sub_if_data *sdata,
ieee80211_tx_skb(sdata, skb); ieee80211_tx_skb(sdata, skb);
} }
static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, static
struct ieee80211_mgmt *mgmt, void ieee80211_rx_mgmt_probe_beacon(struct ieee80211_sub_if_data *sdata,
size_t len, struct ieee80211_mgmt *mgmt, size_t len,
struct ieee80211_rx_status *rx_status) struct ieee80211_rx_status *rx_status)
{ {
size_t baselen; size_t baselen;
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
BUILD_BUG_ON(offsetof(typeof(mgmt->u.probe_resp), variable) !=
offsetof(typeof(mgmt->u.beacon), variable));
/*
* either beacon or probe_resp but the variable field is at the
* same offset
*/
baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt; baselen = (u8 *) mgmt->u.probe_resp.variable - (u8 *) mgmt;
if (baselen > len) if (baselen > len)
return; return;
...@@ -892,25 +897,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ...@@ -892,25 +897,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
&elems); &elems);
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
}
static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt,
size_t len,
struct ieee80211_rx_status *rx_status)
{
size_t baselen;
struct ieee802_11_elems elems;
/* Process beacon from the current BSS */
baselen = (u8 *) mgmt->u.beacon.variable - (u8 *) mgmt;
if (baselen > len)
return;
ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, true);
} }
void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
...@@ -934,12 +921,9 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata, ...@@ -934,12 +921,9 @@ void ieee80211_ibss_rx_queued_mgmt(struct ieee80211_sub_if_data *sdata,
ieee80211_rx_mgmt_probe_req(sdata, skb); ieee80211_rx_mgmt_probe_req(sdata, skb);
break; break;
case IEEE80211_STYPE_PROBE_RESP: case IEEE80211_STYPE_PROBE_RESP:
ieee80211_rx_mgmt_probe_resp(sdata, mgmt, skb->len,
rx_status);
break;
case IEEE80211_STYPE_BEACON: case IEEE80211_STYPE_BEACON:
ieee80211_rx_mgmt_beacon(sdata, mgmt, skb->len, ieee80211_rx_mgmt_probe_beacon(sdata, mgmt, skb->len,
rx_status); rx_status);
break; break;
case IEEE80211_STYPE_AUTH: case IEEE80211_STYPE_AUTH:
ieee80211_rx_mgmt_auth_ibss(sdata, mgmt, skb->len); ieee80211_rx_mgmt_auth_ibss(sdata, mgmt, skb->len);
......
...@@ -1346,8 +1346,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local, ...@@ -1346,8 +1346,7 @@ ieee80211_bss_info_update(struct ieee80211_local *local,
struct ieee80211_mgmt *mgmt, struct ieee80211_mgmt *mgmt,
size_t len, size_t len,
struct ieee802_11_elems *elems, struct ieee802_11_elems *elems,
struct ieee80211_channel *channel, struct ieee80211_channel *channel);
bool beacon);
void ieee80211_rx_bss_put(struct ieee80211_local *local, void ieee80211_rx_bss_put(struct ieee80211_local *local,
struct ieee80211_bss *bss); struct ieee80211_bss *bss);
......
...@@ -2369,8 +2369,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata, ...@@ -2369,8 +2369,7 @@ ieee80211_rx_mgmt_assoc_resp(struct ieee80211_sub_if_data *sdata,
static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
struct ieee80211_mgmt *mgmt, size_t len, struct ieee80211_mgmt *mgmt, size_t len,
struct ieee80211_rx_status *rx_status, struct ieee80211_rx_status *rx_status,
struct ieee802_11_elems *elems, struct ieee802_11_elems *elems)
bool beacon)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int freq; int freq;
...@@ -2404,7 +2403,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -2404,7 +2403,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
return; return;
bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems, bss = ieee80211_bss_info_update(local, rx_status, mgmt, len, elems,
channel, beacon); channel);
if (bss) if (bss)
ieee80211_rx_bss_put(local, bss); ieee80211_rx_bss_put(local, bss);
...@@ -2447,7 +2446,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ...@@ -2447,7 +2446,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen, ieee802_11_parse_elems(mgmt->u.probe_resp.variable, len - baselen,
&elems); &elems);
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, false); ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
if (ifmgd->associated && if (ifmgd->associated &&
ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid)) ether_addr_equal(mgmt->bssid, ifmgd->associated->bssid))
...@@ -2528,8 +2527,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -2528,8 +2527,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
ieee802_11_parse_elems(mgmt->u.beacon.variable, ieee802_11_parse_elems(mgmt->u.beacon.variable,
len - baselen, &elems); len - baselen, &elems);
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
false);
ifmgd->assoc_data->have_beacon = true; ifmgd->assoc_data->have_beacon = true;
ifmgd->assoc_data->sent_assoc = false; ifmgd->assoc_data->sent_assoc = false;
/* continue assoc process */ /* continue assoc process */
...@@ -2682,8 +2680,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -2682,8 +2680,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
ifmgd->beacon_crc = ncrc; ifmgd->beacon_crc = ncrc;
ifmgd->beacon_crc_valid = true; ifmgd->beacon_crc_valid = true;
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
true);
if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param, if (ieee80211_sta_wmm_params(local, sdata, elems.wmm_param,
elems.wmm_param_len)) elems.wmm_param_len))
......
...@@ -65,12 +65,11 @@ static bool is_uapsd_supported(struct ieee802_11_elems *elems) ...@@ -65,12 +65,11 @@ static bool is_uapsd_supported(struct ieee802_11_elems *elems)
struct ieee80211_bss * struct ieee80211_bss *
ieee80211_bss_info_update(struct ieee80211_local *local, ieee80211_bss_info_update(struct ieee80211_local *local,
struct ieee80211_rx_status *rx_status, struct ieee80211_rx_status *rx_status,
struct ieee80211_mgmt *mgmt, struct ieee80211_mgmt *mgmt, size_t len,
size_t len,
struct ieee802_11_elems *elems, struct ieee802_11_elems *elems,
struct ieee80211_channel *channel, struct ieee80211_channel *channel)
bool beacon)
{ {
bool beacon = ieee80211_is_beacon(mgmt->frame_control);
struct cfg80211_bss *cbss; struct cfg80211_bss *cbss;
struct ieee80211_bss *bss; struct ieee80211_bss *bss;
int clen, srlen; int clen, srlen;
...@@ -203,7 +202,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb) ...@@ -203,7 +202,7 @@ void ieee80211_scan_rx(struct ieee80211_local *local, struct sk_buff *skb)
bss = ieee80211_bss_info_update(local, rx_status, bss = ieee80211_bss_info_update(local, rx_status,
mgmt, skb->len, &elems, mgmt, skb->len, &elems,
channel, beacon); channel);
if (bss) if (bss)
ieee80211_rx_bss_put(local, bss); ieee80211_rx_bss_put(local, bss);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment