Signed-off-by: Mohamed Abbas diff --git a/net/d80211/ieee80211_ioctl.c b/net/d80211/ieee80211_ioctl.c index 3ffdc5c..9bd385b 100644 --- a/net/d80211/ieee80211_ioctl.c +++ b/net/d80211/ieee80211_ioctl.c @@ -1852,6 +1852,29 @@ static int ieee80211_ioctl_giwmode(struc return 0; } +#define IEEE80211_AUTH_TIMEOUT (HZ / 5) +#define IEEE80211_AUTH_MAX_TRIES 3 +#define IEEE80211_ASSOC_TIMEOUT (HZ / 5) +#define IEEE80211_ASSOC_MAX_TRIES 3 + +void ieee80211_reset_tries(struct net_device *dev, + struct ieee80211_if_sta *ifsta, + int was_scanning) +{ + + if ((ifsta->state == IEEE80211_AUTHENTICATE) && + (ifsta->auth_tries > IEEE80211_AUTH_MAX_TRIES)) { + ifsta->auth_tries = 0; + ifsta->auth_transaction = -1; + mod_timer(&ifsta->timer, jiffies + IEEE80211_AUTH_TIMEOUT); + } else if ((ifsta->assoc_tries > IEEE80211_ASSOC_MAX_TRIES) && + (ifsta->state == IEEE80211_ASSOCIATE)) { + ifsta->assoc_tries = 0; + mod_timer(&ifsta->timer, jiffies + IEEE80211_ASSOC_TIMEOUT); + } if (ifsta->state == IEEE80211_IBSS_SEARCH && was_scanning) + mod_timer(&ifsta->timer, jiffies + 2 * HZ); + return; +} int ieee80211_ioctl_siwfreq(struct net_device *dev, struct iw_request_info *info, @@ -1898,8 +1921,23 @@ int ieee80211_ioctl_siwfreq(struct net_d } if (set) { + struct ieee80211_sub_if_data *sdata; + struct ieee80211_if_sta *ifsta; + int ret; + int was_scanning; + + sdata = IEEE80211_DEV_TO_SUB_IF(dev); + ifsta = &sdata->u.sta; + + was_scanning = local->sta_scanning; local->sta_scanning = 0; /* Abort possible scan */ - return ieee80211_hw_config(dev); + + ret = ieee80211_hw_config(dev); + + if (!ret) + ieee80211_reset_tries(dev, ifsta, was_scanning); + + return ret; } return -EINVAL; diff --git a/net/d80211/ieee80211_sta.c b/net/d80211/ieee80211_sta.c index e94cb4d..6a3011c 100644 --- a/net/d80211/ieee80211_sta.c +++ b/net/d80211/ieee80211_sta.c @@ -2346,7 +2346,7 @@ int ieee80211_sta_set_ssid(struct net_de return ieee80211_sta_find_ibss(dev, ifsta); } - if (ifsta->bssid_set && ifsta->state != IEEE80211_AUTHENTICATE) + if (ifsta->bssid_set ) ieee80211_sta_new_auth(dev, ifsta); return 0;