提交 9859b81e 编写于 作者: R Ron Rindjunsky 提交者: John W. Linville

mac80211: add direct probe before association

This patch adds a direct probe request as first step in the association
flow if data we have is not up to date. Motivation of this step is to make
sure that the bss information we have is correct, since last scan could
have been done a while ago, and beacons do not fully answer this need as
there are potential differences between them and probe responses (e.g.
WMM parameter element)
Signed-off-by: NRon Rindjunsky <ron.rindjunsky@intel.com>
Signed-off-by: NTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: NJohn W. Linville <linville@tuxdriver.com>
上级 32ddf071
...@@ -100,7 +100,7 @@ struct ieee80211_sta_bss { ...@@ -100,7 +100,7 @@ struct ieee80211_sta_bss {
u64 timestamp; u64 timestamp;
int beacon_int; int beacon_int;
bool probe_resp; unsigned long last_probe_resp;
unsigned long last_update; unsigned long last_update;
/* during assocation, we save an ERP value from a probe response so /* during assocation, we save an ERP value from a probe response so
...@@ -294,12 +294,14 @@ struct mesh_config { ...@@ -294,12 +294,14 @@ struct mesh_config {
#define IEEE80211_STA_PRIVACY_INVOKED BIT(13) #define IEEE80211_STA_PRIVACY_INVOKED BIT(13)
/* flags for MLME request*/ /* flags for MLME request*/
#define IEEE80211_STA_REQ_SCAN 0 #define IEEE80211_STA_REQ_SCAN 0
#define IEEE80211_STA_REQ_AUTH 1 #define IEEE80211_STA_REQ_DIRECT_PROBE 1
#define IEEE80211_STA_REQ_RUN 2 #define IEEE80211_STA_REQ_AUTH 2
#define IEEE80211_STA_REQ_RUN 3
/* flags used for setting mlme state */ /* flags used for setting mlme state */
enum ieee80211_sta_mlme_state { enum ieee80211_sta_mlme_state {
IEEE80211_STA_MLME_DISABLED, IEEE80211_STA_MLME_DISABLED,
IEEE80211_STA_MLME_DIRECT_PROBE,
IEEE80211_STA_MLME_AUTHENTICATE, IEEE80211_STA_MLME_AUTHENTICATE,
IEEE80211_STA_MLME_ASSOCIATE, IEEE80211_STA_MLME_ASSOCIATE,
IEEE80211_STA_MLME_ASSOCIATED, IEEE80211_STA_MLME_ASSOCIATED,
...@@ -362,6 +364,7 @@ struct ieee80211_if_sta { ...@@ -362,6 +364,7 @@ struct ieee80211_if_sta {
struct sk_buff_head skb_queue; struct sk_buff_head skb_queue;
int assoc_scan_tries; /* number of scans done pre-association */ int assoc_scan_tries; /* number of scans done pre-association */
int direct_probe_tries; /* retries for direct probes */
int auth_tries; /* retries for auth req */ int auth_tries; /* retries for auth req */
int assoc_tries; /* retries for assoc req */ int assoc_tries; /* retries for assoc req */
......
...@@ -595,8 +595,10 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata, ...@@ -595,8 +595,10 @@ static void ieee80211_set_associated(struct ieee80211_sub_if_data *sdata,
static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata, static void ieee80211_set_disassoc(struct ieee80211_sub_if_data *sdata,
struct ieee80211_if_sta *ifsta, int deauth) struct ieee80211_if_sta *ifsta, int deauth)
{ {
if (deauth) if (deauth) {
ifsta->direct_probe_tries = 0;
ifsta->auth_tries = 0; ifsta->auth_tries = 0;
}
ifsta->assoc_scan_tries = 0; ifsta->assoc_scan_tries = 0;
ifsta->assoc_tries = 0; ifsta->assoc_tries = 0;
ieee80211_set_associated(sdata, ifsta, 0); ieee80211_set_associated(sdata, ifsta, 0);
...@@ -654,6 +656,36 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata, ...@@ -654,6 +656,36 @@ static void ieee80211_send_auth(struct ieee80211_sub_if_data *sdata,
ieee80211_sta_tx(sdata, skb, encrypt); ieee80211_sta_tx(sdata, skb, encrypt);
} }
static void ieee80211_direct_probe(struct ieee80211_sub_if_data *sdata,
struct ieee80211_if_sta *ifsta)
{
DECLARE_MAC_BUF(mac);
ifsta->direct_probe_tries++;
if (ifsta->direct_probe_tries > IEEE80211_AUTH_MAX_TRIES) {
printk(KERN_DEBUG "%s: direct probe to AP %s timed out\n",
sdata->dev->name, print_mac(mac, ifsta->bssid));
ifsta->state = IEEE80211_STA_MLME_DISABLED;
return;
}
printk(KERN_DEBUG "%s: direct probe to AP %s try %d\n",
sdata->dev->name, print_mac(mac, ifsta->bssid),
ifsta->direct_probe_tries);
ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE;
set_bit(IEEE80211_STA_REQ_DIRECT_PROBE, &ifsta->request);
/* Direct probe is sent to broadcast address as some APs
* will not answer to direct packet in unassociated state.
*/
ieee80211_send_probe_req(sdata, NULL,
ifsta->ssid, ifsta->ssid_len);
mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT);
}
static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata, static void ieee80211_authenticate(struct ieee80211_sub_if_data *sdata,
struct ieee80211_if_sta *ifsta) struct ieee80211_if_sta *ifsta)
...@@ -1947,7 +1979,7 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata, ...@@ -1947,7 +1979,7 @@ static void ieee80211_rx_mgmt_deauth(struct ieee80211_sub_if_data *sdata,
if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE || if (ifsta->state == IEEE80211_STA_MLME_AUTHENTICATE ||
ifsta->state == IEEE80211_STA_MLME_ASSOCIATE || ifsta->state == IEEE80211_STA_MLME_ASSOCIATE ||
ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) { ifsta->state == IEEE80211_STA_MLME_ASSOCIATED) {
ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE; ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE;
mod_timer(&ifsta->timer, jiffies + mod_timer(&ifsta->timer, jiffies +
IEEE80211_RETRY_AUTH_INTERVAL); IEEE80211_RETRY_AUTH_INTERVAL);
} }
...@@ -2540,8 +2572,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -2540,8 +2572,7 @@ 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)
int beacon)
{ {
struct ieee80211_local *local = sdata->local; struct ieee80211_local *local = sdata->local;
int freq, clen; int freq, clen;
...@@ -2549,6 +2580,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -2549,6 +2580,7 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
struct sta_info *sta; struct sta_info *sta;
u64 beacon_timestamp, rx_timestamp; u64 beacon_timestamp, rx_timestamp;
struct ieee80211_channel *channel; struct ieee80211_channel *channel;
bool beacon = ieee80211_is_beacon(mgmt->frame_control);
DECLARE_MAC_BUF(mac); DECLARE_MAC_BUF(mac);
DECLARE_MAC_BUF(mac2); DECLARE_MAC_BUF(mac2);
...@@ -2705,15 +2737,14 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata, ...@@ -2705,15 +2737,14 @@ static void ieee80211_rx_bss_info(struct ieee80211_sub_if_data *sdata,
bss->signal = rx_status->signal; bss->signal = rx_status->signal;
bss->noise = rx_status->noise; bss->noise = rx_status->noise;
bss->qual = rx_status->qual; bss->qual = rx_status->qual;
if (!beacon && !bss->probe_resp) if (!beacon)
bss->probe_resp = true; bss->last_probe_resp = jiffies;
/* /*
* In STA mode, the remaining parameters should not be overridden * In STA mode, the remaining parameters should not be overridden
* by beacons because they're not necessarily accurate there. * by beacons because they're not necessarily accurate there.
*/ */
if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS && if (sdata->vif.type != IEEE80211_IF_TYPE_IBSS &&
bss->probe_resp && beacon) { bss->last_probe_resp && beacon) {
ieee80211_rx_bss_put(local, bss); ieee80211_rx_bss_put(local, bss);
return; return;
} }
...@@ -2868,6 +2899,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ...@@ -2868,6 +2899,7 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata,
{ {
size_t baselen; size_t baselen;
struct ieee802_11_elems elems; struct ieee802_11_elems elems;
struct ieee80211_if_sta *ifsta = &sdata->u.sta;
if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN)) if (memcmp(mgmt->da, sdata->dev->dev_addr, ETH_ALEN))
return; /* ignore ProbeResp to foreign address */ return; /* ignore ProbeResp to foreign address */
...@@ -2879,7 +2911,15 @@ static void ieee80211_rx_mgmt_probe_resp(struct ieee80211_sub_if_data *sdata, ...@@ -2879,7 +2911,15 @@ 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, 0); ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
/* direct probe may be part of the association flow */
if (test_and_clear_bit(IEEE80211_STA_REQ_DIRECT_PROBE,
&ifsta->request)) {
printk(KERN_DEBUG "%s direct probe responded\n",
sdata->dev->name);
ieee80211_authenticate(sdata, ifsta);
}
} }
...@@ -2902,7 +2942,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata, ...@@ -2902,7 +2942,7 @@ static void ieee80211_rx_mgmt_beacon(struct ieee80211_sub_if_data *sdata,
ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems); ieee802_11_parse_elems(mgmt->u.beacon.variable, len - baselen, &elems);
ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems, 1); ieee80211_rx_bss_info(sdata, mgmt, len, rx_status, &elems);
if (sdata->vif.type != IEEE80211_IF_TYPE_STA) if (sdata->vif.type != IEEE80211_IF_TYPE_STA)
return; return;
...@@ -3329,7 +3369,8 @@ void ieee80211_sta_work(struct work_struct *work) ...@@ -3329,7 +3369,8 @@ void ieee80211_sta_work(struct work_struct *work)
mesh_path_start_discovery(sdata); mesh_path_start_discovery(sdata);
#endif #endif
if (ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE && if (ifsta->state != IEEE80211_STA_MLME_DIRECT_PROBE &&
ifsta->state != IEEE80211_STA_MLME_AUTHENTICATE &&
ifsta->state != IEEE80211_STA_MLME_ASSOCIATE && ifsta->state != IEEE80211_STA_MLME_ASSOCIATE &&
test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) { test_and_clear_bit(IEEE80211_STA_REQ_SCAN, &ifsta->request)) {
if (ifsta->scan_ssid_len) if (ifsta->scan_ssid_len)
...@@ -3349,6 +3390,9 @@ void ieee80211_sta_work(struct work_struct *work) ...@@ -3349,6 +3390,9 @@ void ieee80211_sta_work(struct work_struct *work)
switch (ifsta->state) { switch (ifsta->state) {
case IEEE80211_STA_MLME_DISABLED: case IEEE80211_STA_MLME_DISABLED:
break; break;
case IEEE80211_STA_MLME_DIRECT_PROBE:
ieee80211_direct_probe(sdata, ifsta);
break;
case IEEE80211_STA_MLME_AUTHENTICATE: case IEEE80211_STA_MLME_AUTHENTICATE:
ieee80211_authenticate(sdata, ifsta); ieee80211_authenticate(sdata, ifsta);
break; break;
...@@ -3408,6 +3452,7 @@ static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata, ...@@ -3408,6 +3452,7 @@ static void ieee80211_sta_reset_auth(struct ieee80211_sub_if_data *sdata,
ifsta->auth_transaction = -1; ifsta->auth_transaction = -1;
ifsta->flags &= ~IEEE80211_STA_ASSOCIATED; ifsta->flags &= ~IEEE80211_STA_ASSOCIATED;
ifsta->assoc_scan_tries = 0; ifsta->assoc_scan_tries = 0;
ifsta->direct_probe_tries = 0;
ifsta->auth_tries = 0; ifsta->auth_tries = 0;
ifsta->assoc_tries = 0; ifsta->assoc_tries = 0;
netif_carrier_off(sdata->dev); netif_carrier_off(sdata->dev);
...@@ -3509,8 +3554,18 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata, ...@@ -3509,8 +3554,18 @@ static int ieee80211_sta_config_auth(struct ieee80211_sub_if_data *sdata,
selected->ssid_len); selected->ssid_len);
ieee80211_sta_set_bssid(sdata, selected->bssid); ieee80211_sta_set_bssid(sdata, selected->bssid);
ieee80211_sta_def_wmm_params(sdata, selected, 0); ieee80211_sta_def_wmm_params(sdata, selected, 0);
/* Send out direct probe if no probe resp was received or
* the one we have is outdated
*/
if (!selected->last_probe_resp ||
time_after(jiffies, selected->last_probe_resp
+ IEEE80211_SCAN_RESULT_EXPIRE))
ifsta->state = IEEE80211_STA_MLME_DIRECT_PROBE;
else
ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE;
ieee80211_rx_bss_put(local, selected); ieee80211_rx_bss_put(local, selected);
ifsta->state = IEEE80211_STA_MLME_AUTHENTICATE;
ieee80211_sta_reset_auth(sdata, ifsta); ieee80211_sta_reset_auth(sdata, ifsta);
return 0; return 0;
} else { } else {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册