Commit 9d308429 authored by Johannes Berg's avatar Johannes Berg Committed by John W. Linville

cfg80211: clear WEXT SSID when clearing IBSS

When we leave an IBSS, we should clear the SSID and not just the
BSSID, but since WEXT allows configuring while the interface is
down we must not clear it when leaving due to taking the iface
down, so some complications are needed.
Signed-off-by: default avatarJohannes Berg <johannes@sipsolutions.net>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent b9a5f8ca
...@@ -464,7 +464,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb, ...@@ -464,7 +464,7 @@ static int cfg80211_netdev_notifier_call(struct notifier_block * nb,
break; break;
if (!dev->ieee80211_ptr->ssid_len) if (!dev->ieee80211_ptr->ssid_len)
break; break;
cfg80211_leave_ibss(rdev, dev); cfg80211_leave_ibss(rdev, dev, true);
break; break;
case NETDEV_UP: case NETDEV_UP:
#ifdef CONFIG_WIRELESS_EXT #ifdef CONFIG_WIRELESS_EXT
......
...@@ -147,8 +147,8 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev, ...@@ -147,8 +147,8 @@ void cfg80211_bss_age(struct cfg80211_registered_device *dev,
int cfg80211_join_ibss(struct cfg80211_registered_device *rdev, int cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
struct net_device *dev, struct net_device *dev,
struct cfg80211_ibss_params *params); struct cfg80211_ibss_params *params);
void cfg80211_clear_ibss(struct net_device *dev); void cfg80211_clear_ibss(struct net_device *dev, bool nowext);
int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
struct net_device *dev); struct net_device *dev, bool nowext);
#endif /* __NET_WIRELESS_CORE_H */ #endif /* __NET_WIRELESS_CORE_H */
...@@ -76,7 +76,7 @@ int cfg80211_join_ibss(struct cfg80211_registered_device *rdev, ...@@ -76,7 +76,7 @@ int cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
return 0; return 0;
} }
void cfg80211_clear_ibss(struct net_device *dev) void cfg80211_clear_ibss(struct net_device *dev, bool nowext)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
...@@ -88,10 +88,14 @@ void cfg80211_clear_ibss(struct net_device *dev) ...@@ -88,10 +88,14 @@ void cfg80211_clear_ibss(struct net_device *dev)
wdev->current_bss = NULL; wdev->current_bss = NULL;
wdev->ssid_len = 0; wdev->ssid_len = 0;
memset(wdev->bssid, 0, ETH_ALEN); memset(wdev->bssid, 0, ETH_ALEN);
#ifdef CONFIG_WIRELESS_EXT
if (!nowext)
wdev->wext.ssid_len = 0;
#endif
} }
int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
struct net_device *dev) struct net_device *dev, bool nowext)
{ {
int err; int err;
...@@ -100,7 +104,7 @@ int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, ...@@ -100,7 +104,7 @@ int cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
if (err) if (err)
return err; return err;
cfg80211_clear_ibss(dev); cfg80211_clear_ibss(dev, nowext);
return 0; return 0;
} }
...@@ -179,7 +183,8 @@ int cfg80211_ibss_wext_siwfreq(struct net_device *dev, ...@@ -179,7 +183,8 @@ int cfg80211_ibss_wext_siwfreq(struct net_device *dev,
return 0; return 0;
if (wdev->ssid_len) { if (wdev->ssid_len) {
err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy), dev); err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
dev, true);
if (err) if (err)
return err; return err;
} }
...@@ -241,7 +246,8 @@ int cfg80211_ibss_wext_siwessid(struct net_device *dev, ...@@ -241,7 +246,8 @@ int cfg80211_ibss_wext_siwessid(struct net_device *dev,
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (wdev->ssid_len) { if (wdev->ssid_len) {
err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy), dev); err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
dev, true);
if (err) if (err)
return err; return err;
} }
...@@ -275,7 +281,7 @@ int cfg80211_ibss_wext_giwessid(struct net_device *dev, ...@@ -275,7 +281,7 @@ int cfg80211_ibss_wext_giwessid(struct net_device *dev,
data->flags = 1; data->flags = 1;
data->length = wdev->ssid_len; data->length = wdev->ssid_len;
memcpy(ssid, wdev->ssid, data->length); memcpy(ssid, wdev->ssid, data->length);
} else if (wdev->wext.ssid) { } else if (wdev->wext.ssid && wdev->wext.ssid_len) {
data->flags = 1; data->flags = 1;
data->length = wdev->wext.ssid_len; data->length = wdev->wext.ssid_len;
memcpy(ssid, wdev->wext.ssid, data->length); memcpy(ssid, wdev->wext.ssid, data->length);
...@@ -318,7 +324,8 @@ int cfg80211_ibss_wext_siwap(struct net_device *dev, ...@@ -318,7 +324,8 @@ int cfg80211_ibss_wext_siwap(struct net_device *dev,
return 0; return 0;
if (wdev->ssid_len) { if (wdev->ssid_len) {
err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy), dev); err = cfg80211_leave_ibss(wiphy_to_dev(wdev->wiphy),
dev, true);
if (err) if (err)
return err; return err;
} }
......
...@@ -833,7 +833,7 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info) ...@@ -833,7 +833,7 @@ static int nl80211_set_interface(struct sk_buff *skb, struct genl_info *info)
if (dev && !err && (ntype != otype)) { if (dev && !err && (ntype != otype)) {
if (otype == NL80211_IFTYPE_ADHOC) if (otype == NL80211_IFTYPE_ADHOC)
cfg80211_clear_ibss(dev); cfg80211_clear_ibss(dev, false);
} }
unlock: unlock:
...@@ -3249,7 +3249,7 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info) ...@@ -3249,7 +3249,7 @@ static int nl80211_leave_ibss(struct sk_buff *skb, struct genl_info *info)
goto out; goto out;
} }
err = cfg80211_leave_ibss(drv, dev); err = cfg80211_leave_ibss(drv, dev, false);
out: out:
cfg80211_put_dev(drv); cfg80211_put_dev(drv);
......
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