Commit a3ce17d1 authored by Chaitanya Tata's avatar Chaitanya Tata Committed by Johannes Berg

cfg80211: Handle bss expiry during connection

If the BSS is expired during connection, the connect result will
trigger a kernel warning. Ideally cfg80211 should hold the BSS
before the connection is attempted, but as the BSSID is not known
in case of auth/assoc MLME offload (connect op) it doesn't.

For those drivers without the connect op cfg80211 holds down the
reference so it wil not be removed from list.

Fix this by removing the warning and silently adding the BSS back to
the bss list which is return by the driver (with proper BSSID set) or
in case the BSS is already added use that.

The requirements for drivers are documented in the API's.
Signed-off-by: default avatarChaitanya Tata <chaitanya.tata@bluwireless.co.uk>
[formatting fixes, keep old timestamp]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent cec4f328
...@@ -6231,8 +6231,11 @@ struct cfg80211_fils_resp_params { ...@@ -6231,8 +6231,11 @@ struct cfg80211_fils_resp_params {
* case. * case.
* @bssid: The BSSID of the AP (may be %NULL) * @bssid: The BSSID of the AP (may be %NULL)
* @bss: Entry of bss to which STA got connected to, can be obtained through * @bss: Entry of bss to which STA got connected to, can be obtained through
* cfg80211_get_bss() (may be %NULL). Only one parameter among @bssid and * cfg80211_get_bss() (may be %NULL). But it is recommended to store the
* @bss needs to be specified. * bss from the connect_request and hold a reference to it and return
* through this param to avoid a warning if the bss is expired during the
* connection, esp. for those drivers implementing connect op.
* Only one parameter among @bssid and @bss needs to be specified.
* @req_ie: Association request IEs (may be %NULL) * @req_ie: Association request IEs (may be %NULL)
* @req_ie_len: Association request IEs length * @req_ie_len: Association request IEs length
* @resp_ie: Association response IEs (may be %NULL) * @resp_ie: Association response IEs (may be %NULL)
...@@ -6280,8 +6283,12 @@ void cfg80211_connect_done(struct net_device *dev, ...@@ -6280,8 +6283,12 @@ void cfg80211_connect_done(struct net_device *dev,
* *
* @dev: network device * @dev: network device
* @bssid: the BSSID of the AP * @bssid: the BSSID of the AP
* @bss: entry of bss to which STA got connected to, can be obtained * @bss: Entry of bss to which STA got connected to, can be obtained through
* through cfg80211_get_bss (may be %NULL) * cfg80211_get_bss() (may be %NULL). But it is recommended to store the
* bss from the connect_request and hold a reference to it and return
* through this param to avoid a warning if the bss is expired during the
* connection, esp. for those drivers implementing connect op.
* Only one parameter among @bssid and @bss needs to be specified.
* @req_ie: association request IEs (maybe be %NULL) * @req_ie: association request IEs (maybe be %NULL)
* @req_ie_len: association request IEs length * @req_ie_len: association request IEs length
* @resp_ie: association response IEs (may be %NULL) * @resp_ie: association response IEs (may be %NULL)
......
...@@ -531,6 +531,10 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev, ...@@ -531,6 +531,10 @@ void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
void cfg80211_stop_nan(struct cfg80211_registered_device *rdev, void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev); struct wireless_dev *wdev);
struct cfg80211_internal_bss *
cfg80211_bss_update(struct cfg80211_registered_device *rdev,
struct cfg80211_internal_bss *tmp,
bool signal_valid, unsigned long ts);
#ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS #ifdef CONFIG_CFG80211_DEVELOPER_WARNINGS
#define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond) #define CFG80211_DEV_WARN_ON(cond) WARN_ON(cond)
#else #else
......
...@@ -1092,17 +1092,17 @@ struct cfg80211_non_tx_bss { ...@@ -1092,17 +1092,17 @@ struct cfg80211_non_tx_bss {
}; };
/* Returned bss is reference counted and must be cleaned up appropriately. */ /* Returned bss is reference counted and must be cleaned up appropriately. */
static struct cfg80211_internal_bss * struct cfg80211_internal_bss *
cfg80211_bss_update(struct cfg80211_registered_device *rdev, cfg80211_bss_update(struct cfg80211_registered_device *rdev,
struct cfg80211_internal_bss *tmp, struct cfg80211_internal_bss *tmp,
bool signal_valid) bool signal_valid, unsigned long ts)
{ {
struct cfg80211_internal_bss *found = NULL; struct cfg80211_internal_bss *found = NULL;
if (WARN_ON(!tmp->pub.channel)) if (WARN_ON(!tmp->pub.channel))
return NULL; return NULL;
tmp->ts = jiffies; tmp->ts = ts;
spin_lock_bh(&rdev->bss_lock); spin_lock_bh(&rdev->bss_lock);
...@@ -1425,7 +1425,8 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy, ...@@ -1425,7 +1425,8 @@ cfg80211_inform_single_bss_data(struct wiphy *wiphy,
signal_valid = abs(data->chan->center_freq - channel->center_freq) <= signal_valid = abs(data->chan->center_freq - channel->center_freq) <=
wiphy->max_adj_channel_rssi_comp; wiphy->max_adj_channel_rssi_comp;
res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid); res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid,
jiffies);
if (!res) if (!res)
return NULL; return NULL;
...@@ -1842,7 +1843,8 @@ cfg80211_inform_single_bss_frame_data(struct wiphy *wiphy, ...@@ -1842,7 +1843,8 @@ cfg80211_inform_single_bss_frame_data(struct wiphy *wiphy,
signal_valid = abs(data->chan->center_freq - channel->center_freq) <= signal_valid = abs(data->chan->center_freq - channel->center_freq) <=
wiphy->max_adj_channel_rssi_comp; wiphy->max_adj_channel_rssi_comp;
res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid); res = cfg80211_bss_update(wiphy_to_rdev(wiphy), &tmp, signal_valid,
jiffies);
if (!res) if (!res)
return NULL; return NULL;
......
...@@ -796,12 +796,36 @@ void cfg80211_connect_done(struct net_device *dev, ...@@ -796,12 +796,36 @@ void cfg80211_connect_done(struct net_device *dev,
u8 *next; u8 *next;
if (params->bss) { if (params->bss) {
/* Make sure the bss entry provided by the driver is valid. */
struct cfg80211_internal_bss *ibss = bss_from_pub(params->bss); struct cfg80211_internal_bss *ibss = bss_from_pub(params->bss);
if (WARN_ON(list_empty(&ibss->list))) { if (list_empty(&ibss->list)) {
cfg80211_put_bss(wdev->wiphy, params->bss); struct cfg80211_bss *found = NULL, *tmp = params->bss;
return;
found = cfg80211_get_bss(wdev->wiphy, NULL,
params->bss->bssid,
wdev->ssid, wdev->ssid_len,
wdev->conn_bss_type,
IEEE80211_PRIVACY_ANY);
if (found) {
/* The same BSS is already updated so use it
* instead, as it has latest info.
*/
params->bss = found;
} else {
/* Update with BSS provided by driver, it will
* be freshly added and ref cnted, we can free
* the old one.
*
* signal_valid can be false, as we are not
* expecting the BSS to be found.
*
* keep the old timestamp to avoid confusion
*/
cfg80211_bss_update(rdev, ibss, false,
ibss->ts);
}
cfg80211_put_bss(wdev->wiphy, tmp);
} }
} }
......
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