Commit f8d16d3e authored by Denis Kenzior's avatar Denis Kenzior Committed by Johannes Berg

nl80211: Add SOCKET_OWNER support to JOIN_IBSS

Signed-off-by: default avatarDenis Kenzior <denkenz@gmail.com>
[johannes: fix race with wdev lock/unlock by just acquiring once]
Signed-off-by: default avatarJohannes Berg <johannes.berg@intel.com>
parent 37b1c004
...@@ -1962,6 +1962,8 @@ enum nl80211_commands { ...@@ -1962,6 +1962,8 @@ enum nl80211_commands {
* multicast group. * multicast group.
* If set during %NL80211_CMD_ASSOCIATE or %NL80211_CMD_CONNECT the * If set during %NL80211_CMD_ASSOCIATE or %NL80211_CMD_CONNECT the
* station will deauthenticate when the socket is closed. * station will deauthenticate when the socket is closed.
* If set during %NL80211_CMD_JOIN_IBSS the IBSS will be automatically
* torn down when the socket is closed.
* *
* @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is * @NL80211_ATTR_TDLS_INITIATOR: flag attribute indicating the current end is
* the TDLS link initiator. * the TDLS link initiator.
......
...@@ -282,7 +282,7 @@ void cfg80211_bss_age(struct cfg80211_registered_device *rdev, ...@@ -282,7 +282,7 @@ void cfg80211_bss_age(struct cfg80211_registered_device *rdev,
unsigned long age_secs); unsigned long age_secs);
/* IBSS */ /* IBSS */
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,
struct cfg80211_cached_keys *connkeys); struct cfg80211_cached_keys *connkeys);
......
...@@ -84,7 +84,7 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid, ...@@ -84,7 +84,7 @@ void cfg80211_ibss_joined(struct net_device *dev, const u8 *bssid,
} }
EXPORT_SYMBOL(cfg80211_ibss_joined); EXPORT_SYMBOL(cfg80211_ibss_joined);
static 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,
struct cfg80211_cached_keys *connkeys) struct cfg80211_cached_keys *connkeys)
...@@ -92,6 +92,7 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, ...@@ -92,6 +92,7 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
int err; int err;
ASSERT_RTNL();
ASSERT_WDEV_LOCK(wdev); ASSERT_WDEV_LOCK(wdev);
if (wdev->ssid_len) if (wdev->ssid_len)
...@@ -146,23 +147,6 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev, ...@@ -146,23 +147,6 @@ static int __cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
return 0; return 0;
} }
int cfg80211_join_ibss(struct cfg80211_registered_device *rdev,
struct net_device *dev,
struct cfg80211_ibss_params *params,
struct cfg80211_cached_keys *connkeys)
{
struct wireless_dev *wdev = dev->ieee80211_ptr;
int err;
ASSERT_RTNL();
wdev_lock(wdev);
err = __cfg80211_join_ibss(rdev, dev, params, connkeys);
wdev_unlock(wdev);
return err;
}
static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext) static void __cfg80211_clear_ibss(struct net_device *dev, bool nowext)
{ {
struct wireless_dev *wdev = dev->ieee80211_ptr; struct wireless_dev *wdev = dev->ieee80211_ptr;
...@@ -224,6 +208,7 @@ int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev, ...@@ -224,6 +208,7 @@ int __cfg80211_leave_ibss(struct cfg80211_registered_device *rdev,
if (err) if (err)
return err; return err;
wdev->conn_owner_nlportid = 0;
__cfg80211_clear_ibss(dev, nowext); __cfg80211_clear_ibss(dev, nowext);
return 0; return 0;
......
...@@ -8679,9 +8679,14 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info) ...@@ -8679,9 +8679,14 @@ static int nl80211_join_ibss(struct sk_buff *skb, struct genl_info *info)
ibss.userspace_handles_dfs = ibss.userspace_handles_dfs =
nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]); nla_get_flag(info->attrs[NL80211_ATTR_HANDLE_DFS]);
err = cfg80211_join_ibss(rdev, dev, &ibss, connkeys); wdev_lock(dev->ieee80211_ptr);
err = __cfg80211_join_ibss(rdev, dev, &ibss, connkeys);
if (err) if (err)
kzfree(connkeys); kzfree(connkeys);
else if (info->attrs[NL80211_ATTR_SOCKET_OWNER])
dev->ieee80211_ptr->conn_owner_nlportid = info->snd_portid;
wdev_unlock(dev->ieee80211_ptr);
return err; return err;
} }
......
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