mac80211: don't try to do anything on unchanged genIE
Johannes Berg
maintainerPATCH 1/1 mac80211: don't try to do anything on unchanged genIE
When the genIE hasn't changed there's no reason to kick the state machine since it won't be able to do anything new -- doing this decreases the useless work we do for reassociating because if we do kick the state machine it will try to find a usable BSS but there might not be one because wpa_supplicant will only change the BSSID a little later.
In a sense this is a workaround for userspace behaviour, but on the other hand userspace cannot really keep track of what the kernel currently has for genIE since any process could have changed that while wpa_supplicant wasn't looking.
--- net/mac80211/mlme.c | 4 ++++ net/mac80211/wext.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +4 -0
@@ -2496,6 +2496,10 @@ int ieee80211_sta_set_extra_ie(struct ie {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; +if (len == ifmgd->extra_ie_len && + !memcmp (ifmgd->extra_ie, ie, len)) +return -EALREADY ; +kfree (ifmgd->extra_ie);if (len ==0 ) { ifmgd->extra_ie =NULL ;
net/mac80211/wext.c +3 -2
@@ -37,12 +37,13 @@ static int ieee80211_ioctl_siwgenie(struif (sdata->vif.type ==NL80211_IFTYPE_STATION ) {int ret =ieee80211_sta_set_extra_ie (sdata, extra, data->length); -if (ret) +if (ret && ret != -EALREADY )return ret; sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL ; sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME ; sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT ; -ieee80211_sta_req_auth (sdata); +if (ret != -EALREADY ) +ieee80211_sta_req_auth (sdata);return 0 ; }
Johannes Berg
maintainerQuoted 23 lines · Johannes Berg
When the genIE hasn't changed there's no reason to kick the state machine since it won't be able to do anything new -- doing this decreases the useless work we do for reassociating because if we do kick the state machine it will try to find a usable BSS but there might not be one because
wpa_supplicantwill only change the BSSID a little later.In a sense this is a workaround for userspace behaviour, but on the other hand userspace cannot really keep track of what the kernel currently has for genIE since any process could have changed that while
wpa_supplicantwasn't looking.Signed-off-by Johannes Berg <[email protected]>--- net/mac80211/mlme.c | 4 ++++ net/mac80211/wext.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-)
net/mac80211/mlme.c int ieee80211_sta_set_extra_ie(struct ie · line 2502
Quoted 7 lines
net/mac80211/mlme.c +4
-0@@ -2496,6 +2496,10 @@ int ieee80211_sta_set_extra_ie(struct ie {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; +if (len == ifmgd->extra_ie_len && + !memcmp (ifmgd->extra_ie, ie, len)) +return -EALREADY ; +
Oops, this is buggy when extra_ie is NULL.
johannes
Johannes Berg
maintainerPATCH v2 1/1 mac80211: don't try to do anything on unchanged genIE
In reply to Johannes BergWhen the genIE hasn't changed there's no reason to kick the state machine since it won't be able to do anything new -- doing this decreases the useless work we do for reassociating because if we do kick the state machine it will try to find a usable BSS but there might not be one because wpa_supplicant will only change the BSSID a little later.
In a sense this is a workaround for userspace behaviour, but on the other hand userspace cannot really keep track of what the kernel currently has for genIE since any process could have changed that while wpa_supplicant wasn't looking.
--- net/mac80211/mlme.c | 7 +++++++ net/mac80211/wext.c | 5 +++-- 2 files changed, 10 insertions(+), 2 deletions(-)
net/mac80211/mlme.c +7 -0
@@ -2496,6 +2496,13 @@ int ieee80211_sta_set_extra_ie(struct ie {struct ieee80211_if_managed *ifmgd = &sdata->u.mgd; +if (len ==0 && ifmgd->extra_ie_len ==0 ) +return -EALREADY ; + +if (len == ifmgd->extra_ie_len && ifmgd->extra_ie && +memcmp (ifmgd->extra_ie, ie, len) ==0 ) +return -EALREADY ; +kfree (ifmgd->extra_ie);if (len ==0 ) { ifmgd->extra_ie =NULL ;
net/mac80211/wext.c +3 -2
@@ -37,12 +37,13 @@ static int ieee80211_ioctl_siwgenie(struif (sdata->vif.type ==NL80211_IFTYPE_STATION ) {int ret =ieee80211_sta_set_extra_ie (sdata, extra, data->length); -if (ret) +if (ret && ret != -EALREADY )return ret; sdata->u.mgd.flags &= ~IEEE80211_STA_AUTO_BSSID_SEL ; sdata->u.mgd.flags &= ~IEEE80211_STA_EXT_SME ; sdata->u.mgd.flags &= ~IEEE80211_STA_CONTROL_PORT ; -ieee80211_sta_req_auth (sdata); +if (ret != -EALREADY ) +ieee80211_sta_req_auth (sdata);return 0 ; }