Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1 | /* |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 2 | * SME code for cfg80211 |
| 3 | * both driver SME event handling and the SME implementation |
| 4 | * (for nl80211's connect() and wext) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 5 | * |
| 6 | * Copyright 2009 Johannes Berg <johannes@sipsolutions.net> |
| 7 | * Copyright (C) 2009 Intel Corporation. All rights reserved. |
| 8 | */ |
| 9 | |
| 10 | #include <linux/etherdevice.h> |
| 11 | #include <linux/if_arp.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 12 | #include <linux/slab.h> |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 13 | #include <linux/workqueue.h> |
Johannes Berg | a9a1162 | 2009-07-27 12:01:53 +0200 | [diff] [blame] | 14 | #include <linux/wireless.h> |
Paul Gortmaker | bc3b2d7 | 2011-07-15 11:47:34 -0400 | [diff] [blame] | 15 | #include <linux/export.h> |
Johannes Berg | a9a1162 | 2009-07-27 12:01:53 +0200 | [diff] [blame] | 16 | #include <net/iw_handler.h> |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 17 | #include <net/cfg80211.h> |
| 18 | #include <net/rtnetlink.h> |
| 19 | #include "nl80211.h" |
Luis R. Rodriguez | 8b19e6c | 2009-07-30 17:38:09 -0700 | [diff] [blame] | 20 | #include "reg.h" |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 21 | #include "rdev-ops.h" |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 22 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 23 | /* |
| 24 | * Software SME in cfg80211, using auth/assoc/deauth calls to the |
| 25 | * driver. This is is for implementing nl80211's connect/disconnect |
| 26 | * and wireless extensions (if configured.) |
| 27 | */ |
| 28 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 29 | struct cfg80211_conn { |
| 30 | struct cfg80211_connect_params params; |
| 31 | /* these are sub-states of the _CONNECTING sme_state */ |
| 32 | enum { |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 33 | CFG80211_CONN_SCANNING, |
| 34 | CFG80211_CONN_SCAN_AGAIN, |
| 35 | CFG80211_CONN_AUTHENTICATE_NEXT, |
| 36 | CFG80211_CONN_AUTHENTICATING, |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 37 | CFG80211_CONN_AUTH_FAILED, |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 38 | CFG80211_CONN_ASSOCIATE_NEXT, |
| 39 | CFG80211_CONN_ASSOCIATING, |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 40 | CFG80211_CONN_ASSOC_FAILED, |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 41 | CFG80211_CONN_DEAUTH, |
| 42 | CFG80211_CONN_CONNECTED, |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 43 | } state; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 44 | u8 bssid[ETH_ALEN], prev_bssid[ETH_ALEN]; |
Johannes Berg | 46b9d18 | 2015-03-31 16:09:13 +0200 | [diff] [blame] | 45 | const u8 *ie; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 46 | size_t ie_len; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 47 | bool auto_auth, prev_bssid_valid; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 48 | }; |
| 49 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 50 | static void cfg80211_sme_free(struct wireless_dev *wdev) |
Luis R. Rodriguez | 09d989d | 2010-01-29 19:58:57 -0500 | [diff] [blame] | 51 | { |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 52 | if (!wdev->conn) |
| 53 | return; |
Luis R. Rodriguez | 09d989d | 2010-01-29 19:58:57 -0500 | [diff] [blame] | 54 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 55 | kfree(wdev->conn->ie); |
| 56 | kfree(wdev->conn); |
| 57 | wdev->conn = NULL; |
Luis R. Rodriguez | 09d989d | 2010-01-29 19:58:57 -0500 | [diff] [blame] | 58 | } |
| 59 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 60 | static int cfg80211_conn_scan(struct wireless_dev *wdev) |
| 61 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 62 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 63 | struct cfg80211_scan_request *request; |
| 64 | int n_channels, err; |
| 65 | |
| 66 | ASSERT_RTNL(); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 67 | ASSERT_WDEV_LOCK(wdev); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 68 | |
Johannes Berg | f9d15d1 | 2014-01-22 11:14:19 +0200 | [diff] [blame] | 69 | if (rdev->scan_req || rdev->scan_msg) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 70 | return -EBUSY; |
| 71 | |
Ilan Peer | bdfbec2 | 2014-01-09 11:37:23 +0200 | [diff] [blame] | 72 | if (wdev->conn->params.channel) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 73 | n_channels = 1; |
Ilan Peer | bdfbec2 | 2014-01-09 11:37:23 +0200 | [diff] [blame] | 74 | else |
| 75 | n_channels = ieee80211_get_num_supported_channels(wdev->wiphy); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 76 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 77 | request = kzalloc(sizeof(*request) + sizeof(request->ssids[0]) + |
| 78 | sizeof(request->channels[0]) * n_channels, |
| 79 | GFP_KERNEL); |
| 80 | if (!request) |
| 81 | return -ENOMEM; |
| 82 | |
Karl Beldan | 2a84ee8 | 2014-10-07 11:42:18 +0200 | [diff] [blame] | 83 | if (wdev->conn->params.channel) { |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 84 | enum nl80211_band band = wdev->conn->params.channel->band; |
Karl Beldan | 2a84ee8 | 2014-10-07 11:42:18 +0200 | [diff] [blame] | 85 | struct ieee80211_supported_band *sband = |
| 86 | wdev->wiphy->bands[band]; |
| 87 | |
| 88 | if (!sband) { |
| 89 | kfree(request); |
| 90 | return -EINVAL; |
| 91 | } |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 92 | request->channels[0] = wdev->conn->params.channel; |
Karl Beldan | 2a84ee8 | 2014-10-07 11:42:18 +0200 | [diff] [blame] | 93 | request->rates[band] = (1 << sband->n_bitrates) - 1; |
| 94 | } else { |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 95 | int i = 0, j; |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 96 | enum nl80211_band band; |
Rajkumar Manoharan | e308150 | 2011-09-15 17:40:50 +0530 | [diff] [blame] | 97 | struct ieee80211_supported_band *bands; |
| 98 | struct ieee80211_channel *channel; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 99 | |
Johannes Berg | 57fbcce | 2016-04-12 15:56:15 +0200 | [diff] [blame] | 100 | for (band = 0; band < NUM_NL80211_BANDS; band++) { |
Rajkumar Manoharan | e308150 | 2011-09-15 17:40:50 +0530 | [diff] [blame] | 101 | bands = wdev->wiphy->bands[band]; |
| 102 | if (!bands) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 103 | continue; |
Rajkumar Manoharan | e308150 | 2011-09-15 17:40:50 +0530 | [diff] [blame] | 104 | for (j = 0; j < bands->n_channels; j++) { |
| 105 | channel = &bands->channels[j]; |
| 106 | if (channel->flags & IEEE80211_CHAN_DISABLED) |
| 107 | continue; |
| 108 | request->channels[i++] = channel; |
| 109 | } |
| 110 | request->rates[band] = (1 << bands->n_bitrates) - 1; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 111 | } |
Rajkumar Manoharan | e308150 | 2011-09-15 17:40:50 +0530 | [diff] [blame] | 112 | n_channels = i; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 113 | } |
| 114 | request->n_channels = n_channels; |
Johannes Berg | 5ba6353 | 2009-08-07 17:54:07 +0200 | [diff] [blame] | 115 | request->ssids = (void *)&request->channels[n_channels]; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 116 | request->n_ssids = 1; |
| 117 | |
| 118 | memcpy(request->ssids[0].ssid, wdev->conn->params.ssid, |
| 119 | wdev->conn->params.ssid_len); |
| 120 | request->ssids[0].ssid_len = wdev->conn->params.ssid_len; |
| 121 | |
Jouni Malinen | 818965d | 2016-02-26 22:12:47 +0200 | [diff] [blame] | 122 | eth_broadcast_addr(request->bssid); |
| 123 | |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 124 | request->wdev = wdev; |
Johannes Berg | 79c97e9 | 2009-07-07 03:56:12 +0200 | [diff] [blame] | 125 | request->wiphy = &rdev->wiphy; |
Sam Leffler | 15d6030 | 2012-10-11 21:03:34 -0700 | [diff] [blame] | 126 | request->scan_start = jiffies; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 127 | |
Johannes Berg | 79c97e9 | 2009-07-07 03:56:12 +0200 | [diff] [blame] | 128 | rdev->scan_req = request; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 129 | |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 130 | err = rdev_scan(rdev, request); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 131 | if (!err) { |
| 132 | wdev->conn->state = CFG80211_CONN_SCANNING; |
Johannes Berg | fd01428 | 2012-06-18 19:17:03 +0200 | [diff] [blame] | 133 | nl80211_send_scan_start(rdev, wdev); |
Johannes Berg | 463d018 | 2009-07-14 00:33:35 +0200 | [diff] [blame] | 134 | dev_hold(wdev->netdev); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 135 | } else { |
Johannes Berg | 79c97e9 | 2009-07-07 03:56:12 +0200 | [diff] [blame] | 136 | rdev->scan_req = NULL; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 137 | kfree(request); |
| 138 | } |
| 139 | return err; |
| 140 | } |
| 141 | |
| 142 | static int cfg80211_conn_do_work(struct wireless_dev *wdev) |
| 143 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 144 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 145 | struct cfg80211_connect_params *params; |
Johannes Berg | f62fab7 | 2013-02-21 20:09:09 +0100 | [diff] [blame] | 146 | struct cfg80211_assoc_request req = {}; |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 147 | int err; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 148 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 149 | ASSERT_WDEV_LOCK(wdev); |
| 150 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 151 | if (!wdev->conn) |
| 152 | return 0; |
| 153 | |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 154 | params = &wdev->conn->params; |
| 155 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 156 | switch (wdev->conn->state) { |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 157 | case CFG80211_CONN_SCANNING: |
| 158 | /* didn't find it during scan ... */ |
| 159 | return -ENOENT; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 160 | case CFG80211_CONN_SCAN_AGAIN: |
| 161 | return cfg80211_conn_scan(wdev); |
| 162 | case CFG80211_CONN_AUTHENTICATE_NEXT: |
Johannes Berg | 2fd0511 | 2014-04-29 17:52:36 +0200 | [diff] [blame] | 163 | if (WARN_ON(!rdev->ops->auth)) |
| 164 | return -EOPNOTSUPP; |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 165 | wdev->conn->state = CFG80211_CONN_AUTHENTICATING; |
Johannes Berg | 91bf9b2 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 166 | return cfg80211_mlme_auth(rdev, wdev->netdev, |
| 167 | params->channel, params->auth_type, |
| 168 | params->bssid, |
| 169 | params->ssid, params->ssid_len, |
| 170 | NULL, 0, |
| 171 | params->key, params->key_len, |
| 172 | params->key_idx, NULL, 0); |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 173 | case CFG80211_CONN_AUTH_FAILED: |
| 174 | return -ENOTCONN; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 175 | case CFG80211_CONN_ASSOCIATE_NEXT: |
Johannes Berg | 2fd0511 | 2014-04-29 17:52:36 +0200 | [diff] [blame] | 176 | if (WARN_ON(!rdev->ops->assoc)) |
| 177 | return -EOPNOTSUPP; |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 178 | wdev->conn->state = CFG80211_CONN_ASSOCIATING; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 179 | if (wdev->conn->prev_bssid_valid) |
Johannes Berg | f62fab7 | 2013-02-21 20:09:09 +0100 | [diff] [blame] | 180 | req.prev_bssid = wdev->conn->prev_bssid; |
| 181 | req.ie = params->ie; |
| 182 | req.ie_len = params->ie_len; |
| 183 | req.use_mfp = params->mfp != NL80211_MFP_NO; |
| 184 | req.crypto = params->crypto; |
| 185 | req.flags = params->flags; |
| 186 | req.ht_capa = params->ht_capa; |
| 187 | req.ht_capa_mask = params->ht_capa_mask; |
| 188 | req.vht_capa = params->vht_capa; |
| 189 | req.vht_capa_mask = params->vht_capa_mask; |
| 190 | |
Johannes Berg | 91bf9b2 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 191 | err = cfg80211_mlme_assoc(rdev, wdev->netdev, params->channel, |
| 192 | params->bssid, params->ssid, |
| 193 | params->ssid_len, &req); |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 194 | if (err) |
Johannes Berg | 91bf9b2 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 195 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, |
| 196 | NULL, 0, |
| 197 | WLAN_REASON_DEAUTH_LEAVING, |
| 198 | false); |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 199 | return err; |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 200 | case CFG80211_CONN_ASSOC_FAILED: |
| 201 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, |
| 202 | NULL, 0, |
| 203 | WLAN_REASON_DEAUTH_LEAVING, false); |
| 204 | return -ENOTCONN; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 205 | case CFG80211_CONN_DEAUTH: |
Johannes Berg | 91bf9b2 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 206 | cfg80211_mlme_deauth(rdev, wdev->netdev, params->bssid, |
| 207 | NULL, 0, |
| 208 | WLAN_REASON_DEAUTH_LEAVING, false); |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 209 | /* free directly, disconnected event already sent */ |
| 210 | cfg80211_sme_free(wdev); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 211 | return 0; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 212 | default: |
| 213 | return 0; |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | void cfg80211_conn_work(struct work_struct *work) |
| 218 | { |
Johannes Berg | 79c97e9 | 2009-07-07 03:56:12 +0200 | [diff] [blame] | 219 | struct cfg80211_registered_device *rdev = |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 220 | container_of(work, struct cfg80211_registered_device, conn_work); |
| 221 | struct wireless_dev *wdev; |
Johannes Berg | 7400f42 | 2009-10-31 07:40:37 +0100 | [diff] [blame] | 222 | u8 bssid_buf[ETH_ALEN], *bssid = NULL; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 223 | |
| 224 | rtnl_lock(); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 225 | |
Johannes Berg | 53873f1 | 2016-05-03 16:52:04 +0300 | [diff] [blame] | 226 | list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { |
Johannes Berg | c815797 | 2013-05-23 18:10:21 +0200 | [diff] [blame] | 227 | if (!wdev->netdev) |
| 228 | continue; |
| 229 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 230 | wdev_lock(wdev); |
| 231 | if (!netif_running(wdev->netdev)) { |
| 232 | wdev_unlock(wdev); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 233 | continue; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 234 | } |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 235 | if (!wdev->conn || |
| 236 | wdev->conn->state == CFG80211_CONN_CONNECTED) { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 237 | wdev_unlock(wdev); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 238 | continue; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 239 | } |
Johannes Berg | 7400f42 | 2009-10-31 07:40:37 +0100 | [diff] [blame] | 240 | if (wdev->conn->params.bssid) { |
| 241 | memcpy(bssid_buf, wdev->conn->params.bssid, ETH_ALEN); |
| 242 | bssid = bssid_buf; |
| 243 | } |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 244 | if (cfg80211_conn_do_work(wdev)) { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 245 | __cfg80211_connect_result( |
Johannes Berg | 7d930bc | 2009-10-20 15:08:53 +0900 | [diff] [blame] | 246 | wdev->netdev, bssid, |
Jouni Malinen | bf1ecd2 | 2016-05-31 00:16:50 +0300 | [diff] [blame] | 247 | NULL, 0, NULL, 0, -1, false, NULL); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 248 | } |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 249 | wdev_unlock(wdev); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 250 | } |
| 251 | |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 252 | rtnl_unlock(); |
| 253 | } |
| 254 | |
Ben Greear | 0e3a39b | 2013-06-19 14:06:27 -0700 | [diff] [blame] | 255 | /* Returned bss is reference counted and must be cleaned up appropriately. */ |
Johannes Berg | bbac31f | 2009-09-16 09:04:26 -0700 | [diff] [blame] | 256 | static struct cfg80211_bss *cfg80211_get_conn_bss(struct wireless_dev *wdev) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 257 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 258 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 259 | struct cfg80211_bss *bss; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 260 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 261 | ASSERT_WDEV_LOCK(wdev); |
| 262 | |
Jouni Malinen | ed9d010 | 2011-05-16 19:40:15 +0300 | [diff] [blame] | 263 | bss = cfg80211_get_bss(wdev->wiphy, wdev->conn->params.channel, |
| 264 | wdev->conn->params.bssid, |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 265 | wdev->conn->params.ssid, |
| 266 | wdev->conn->params.ssid_len, |
Lior David | 34d5051 | 2016-01-28 10:58:25 +0200 | [diff] [blame] | 267 | wdev->conn_bss_type, |
Dedy Lansky | 6eb1813 | 2015-02-08 15:52:03 +0200 | [diff] [blame] | 268 | IEEE80211_PRIVACY(wdev->conn->params.privacy)); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 269 | if (!bss) |
Johannes Berg | bbac31f | 2009-09-16 09:04:26 -0700 | [diff] [blame] | 270 | return NULL; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 271 | |
| 272 | memcpy(wdev->conn->bssid, bss->bssid, ETH_ALEN); |
| 273 | wdev->conn->params.bssid = wdev->conn->bssid; |
| 274 | wdev->conn->params.channel = bss->channel; |
| 275 | wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; |
Johannes Berg | 79c97e9 | 2009-07-07 03:56:12 +0200 | [diff] [blame] | 276 | schedule_work(&rdev->conn_work); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 277 | |
Johannes Berg | bbac31f | 2009-09-16 09:04:26 -0700 | [diff] [blame] | 278 | return bss; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 279 | } |
| 280 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 281 | static void __cfg80211_sme_scan_done(struct net_device *dev) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 282 | { |
| 283 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 284 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | bbac31f | 2009-09-16 09:04:26 -0700 | [diff] [blame] | 285 | struct cfg80211_bss *bss; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 286 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 287 | ASSERT_WDEV_LOCK(wdev); |
| 288 | |
Zhu Yi | d4b1a68 | 2009-07-16 17:34:14 +0800 | [diff] [blame] | 289 | if (!wdev->conn) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 290 | return; |
| 291 | |
| 292 | if (wdev->conn->state != CFG80211_CONN_SCANNING && |
| 293 | wdev->conn->state != CFG80211_CONN_SCAN_AGAIN) |
| 294 | return; |
| 295 | |
Johannes Berg | bbac31f | 2009-09-16 09:04:26 -0700 | [diff] [blame] | 296 | bss = cfg80211_get_conn_bss(wdev); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 297 | if (bss) |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 298 | cfg80211_put_bss(&rdev->wiphy, bss); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 299 | else |
| 300 | schedule_work(&rdev->conn_work); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 301 | } |
| 302 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 303 | void cfg80211_sme_scan_done(struct net_device *dev) |
| 304 | { |
| 305 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
| 306 | |
| 307 | wdev_lock(wdev); |
| 308 | __cfg80211_sme_scan_done(dev); |
| 309 | wdev_unlock(wdev); |
| 310 | } |
| 311 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 312 | void cfg80211_sme_rx_auth(struct wireless_dev *wdev, const u8 *buf, size_t len) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 313 | { |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 314 | struct wiphy *wiphy = wdev->wiphy; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 315 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 316 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)buf; |
| 317 | u16 status_code = le16_to_cpu(mgmt->u.auth.status_code); |
| 318 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 319 | ASSERT_WDEV_LOCK(wdev); |
| 320 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 321 | if (!wdev->conn || wdev->conn->state == CFG80211_CONN_CONNECTED) |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 322 | return; |
| 323 | |
| 324 | if (status_code == WLAN_STATUS_NOT_SUPPORTED_AUTH_ALG && |
| 325 | wdev->conn->auto_auth && |
| 326 | wdev->conn->params.auth_type != NL80211_AUTHTYPE_NETWORK_EAP) { |
| 327 | /* select automatically between only open, shared, leap */ |
| 328 | switch (wdev->conn->params.auth_type) { |
| 329 | case NL80211_AUTHTYPE_OPEN_SYSTEM: |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 330 | if (wdev->connect_keys) |
| 331 | wdev->conn->params.auth_type = |
| 332 | NL80211_AUTHTYPE_SHARED_KEY; |
| 333 | else |
| 334 | wdev->conn->params.auth_type = |
| 335 | NL80211_AUTHTYPE_NETWORK_EAP; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 336 | break; |
| 337 | case NL80211_AUTHTYPE_SHARED_KEY: |
| 338 | wdev->conn->params.auth_type = |
| 339 | NL80211_AUTHTYPE_NETWORK_EAP; |
| 340 | break; |
| 341 | default: |
| 342 | /* huh? */ |
| 343 | wdev->conn->params.auth_type = |
| 344 | NL80211_AUTHTYPE_OPEN_SYSTEM; |
| 345 | break; |
| 346 | } |
| 347 | wdev->conn->state = CFG80211_CONN_AUTHENTICATE_NEXT; |
| 348 | schedule_work(&rdev->conn_work); |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 349 | } else if (status_code != WLAN_STATUS_SUCCESS) { |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 350 | __cfg80211_connect_result(wdev->netdev, mgmt->bssid, |
| 351 | NULL, 0, NULL, 0, |
Johannes Berg | df7fc0f | 2009-07-29 11:23:49 +0200 | [diff] [blame] | 352 | status_code, false, NULL); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 353 | } else if (wdev->conn->state == CFG80211_CONN_AUTHENTICATING) { |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 354 | wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT; |
| 355 | schedule_work(&rdev->conn_work); |
| 356 | } |
| 357 | } |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 358 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 359 | bool cfg80211_sme_rx_assoc_resp(struct wireless_dev *wdev, u16 status) |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 360 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 361 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 362 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 363 | if (!wdev->conn) |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 364 | return false; |
| 365 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 366 | if (status == WLAN_STATUS_SUCCESS) { |
| 367 | wdev->conn->state = CFG80211_CONN_CONNECTED; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 368 | return false; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 369 | } |
| 370 | |
| 371 | if (wdev->conn->prev_bssid_valid) { |
| 372 | /* |
| 373 | * Some stupid APs don't accept reassoc, so we |
| 374 | * need to fall back to trying regular assoc; |
| 375 | * return true so no event is sent to userspace. |
| 376 | */ |
| 377 | wdev->conn->prev_bssid_valid = false; |
| 378 | wdev->conn->state = CFG80211_CONN_ASSOCIATE_NEXT; |
| 379 | schedule_work(&rdev->conn_work); |
| 380 | return true; |
| 381 | } |
| 382 | |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 383 | wdev->conn->state = CFG80211_CONN_ASSOC_FAILED; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 384 | schedule_work(&rdev->conn_work); |
| 385 | return false; |
| 386 | } |
| 387 | |
| 388 | void cfg80211_sme_deauth(struct wireless_dev *wdev) |
| 389 | { |
| 390 | cfg80211_sme_free(wdev); |
| 391 | } |
| 392 | |
| 393 | void cfg80211_sme_auth_timeout(struct wireless_dev *wdev) |
| 394 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 395 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 396 | |
| 397 | if (!wdev->conn) |
| 398 | return; |
| 399 | |
| 400 | wdev->conn->state = CFG80211_CONN_AUTH_FAILED; |
| 401 | schedule_work(&rdev->conn_work); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 402 | } |
| 403 | |
| 404 | void cfg80211_sme_disassoc(struct wireless_dev *wdev) |
| 405 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 406 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 407 | |
| 408 | if (!wdev->conn) |
| 409 | return; |
| 410 | |
| 411 | wdev->conn->state = CFG80211_CONN_DEAUTH; |
| 412 | schedule_work(&rdev->conn_work); |
| 413 | } |
| 414 | |
| 415 | void cfg80211_sme_assoc_timeout(struct wireless_dev *wdev) |
| 416 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 417 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 923a0e7 | 2013-06-28 11:38:54 +0200 | [diff] [blame] | 418 | |
| 419 | if (!wdev->conn) |
| 420 | return; |
| 421 | |
| 422 | wdev->conn->state = CFG80211_CONN_ASSOC_FAILED; |
| 423 | schedule_work(&rdev->conn_work); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 424 | } |
| 425 | |
Johannes Berg | 46b9d18 | 2015-03-31 16:09:13 +0200 | [diff] [blame] | 426 | static int cfg80211_sme_get_conn_ies(struct wireless_dev *wdev, |
| 427 | const u8 *ies, size_t ies_len, |
| 428 | const u8 **out_ies, size_t *out_ies_len) |
| 429 | { |
| 430 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
| 431 | u8 *buf; |
| 432 | size_t offs; |
| 433 | |
| 434 | if (!rdev->wiphy.extended_capabilities_len || |
| 435 | (ies && cfg80211_find_ie(WLAN_EID_EXT_CAPABILITY, ies, ies_len))) { |
| 436 | *out_ies = kmemdup(ies, ies_len, GFP_KERNEL); |
| 437 | if (!*out_ies) |
| 438 | return -ENOMEM; |
| 439 | *out_ies_len = ies_len; |
| 440 | return 0; |
| 441 | } |
| 442 | |
| 443 | buf = kmalloc(ies_len + rdev->wiphy.extended_capabilities_len + 2, |
| 444 | GFP_KERNEL); |
| 445 | if (!buf) |
| 446 | return -ENOMEM; |
| 447 | |
| 448 | if (ies_len) { |
| 449 | static const u8 before_extcapa[] = { |
| 450 | /* not listing IEs expected to be created by driver */ |
| 451 | WLAN_EID_RSN, |
| 452 | WLAN_EID_QOS_CAPA, |
| 453 | WLAN_EID_RRM_ENABLED_CAPABILITIES, |
| 454 | WLAN_EID_MOBILITY_DOMAIN, |
| 455 | WLAN_EID_SUPPORTED_REGULATORY_CLASSES, |
| 456 | WLAN_EID_BSS_COEX_2040, |
| 457 | }; |
| 458 | |
| 459 | offs = ieee80211_ie_split(ies, ies_len, before_extcapa, |
| 460 | ARRAY_SIZE(before_extcapa), 0); |
| 461 | memcpy(buf, ies, offs); |
| 462 | /* leave a whole for extended capabilities IE */ |
| 463 | memcpy(buf + offs + rdev->wiphy.extended_capabilities_len + 2, |
| 464 | ies + offs, ies_len - offs); |
| 465 | } else { |
| 466 | offs = 0; |
| 467 | } |
| 468 | |
| 469 | /* place extended capabilities IE (with only driver capabilities) */ |
| 470 | buf[offs] = WLAN_EID_EXT_CAPABILITY; |
| 471 | buf[offs + 1] = rdev->wiphy.extended_capabilities_len; |
| 472 | memcpy(buf + offs + 2, |
| 473 | rdev->wiphy.extended_capabilities, |
| 474 | rdev->wiphy.extended_capabilities_len); |
| 475 | |
| 476 | *out_ies = buf; |
| 477 | *out_ies_len = ies_len + rdev->wiphy.extended_capabilities_len + 2; |
| 478 | |
| 479 | return 0; |
| 480 | } |
| 481 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 482 | static int cfg80211_sme_connect(struct wireless_dev *wdev, |
| 483 | struct cfg80211_connect_params *connect, |
| 484 | const u8 *prev_bssid) |
| 485 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 486 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 487 | struct cfg80211_bss *bss; |
| 488 | int err; |
| 489 | |
| 490 | if (!rdev->ops->auth || !rdev->ops->assoc) |
| 491 | return -EOPNOTSUPP; |
| 492 | |
Jouni Malinen | 4ce2bd9 | 2016-03-29 13:53:28 +0300 | [diff] [blame] | 493 | if (wdev->current_bss) { |
| 494 | if (!prev_bssid) |
| 495 | return -EALREADY; |
| 496 | if (prev_bssid && |
| 497 | !ether_addr_equal(prev_bssid, wdev->current_bss->pub.bssid)) |
| 498 | return -ENOTCONN; |
| 499 | cfg80211_unhold_bss(wdev->current_bss); |
| 500 | cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); |
| 501 | wdev->current_bss = NULL; |
| 502 | |
| 503 | cfg80211_sme_free(wdev); |
| 504 | } |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 505 | |
| 506 | if (WARN_ON(wdev->conn)) |
| 507 | return -EINPROGRESS; |
| 508 | |
| 509 | wdev->conn = kzalloc(sizeof(*wdev->conn), GFP_KERNEL); |
| 510 | if (!wdev->conn) |
| 511 | return -ENOMEM; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 512 | |
| 513 | /* |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 514 | * Copy all parameters, and treat explicitly IEs, BSSID, SSID. |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 515 | */ |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 516 | memcpy(&wdev->conn->params, connect, sizeof(*connect)); |
| 517 | if (connect->bssid) { |
| 518 | wdev->conn->params.bssid = wdev->conn->bssid; |
| 519 | memcpy(wdev->conn->bssid, connect->bssid, ETH_ALEN); |
| 520 | } |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 521 | |
Johannes Berg | 46b9d18 | 2015-03-31 16:09:13 +0200 | [diff] [blame] | 522 | if (cfg80211_sme_get_conn_ies(wdev, connect->ie, connect->ie_len, |
| 523 | &wdev->conn->ie, |
| 524 | &wdev->conn->params.ie_len)) { |
| 525 | kfree(wdev->conn); |
| 526 | wdev->conn = NULL; |
| 527 | return -ENOMEM; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 528 | } |
Johannes Berg | 46b9d18 | 2015-03-31 16:09:13 +0200 | [diff] [blame] | 529 | wdev->conn->params.ie = wdev->conn->ie; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 530 | |
| 531 | if (connect->auth_type == NL80211_AUTHTYPE_AUTOMATIC) { |
| 532 | wdev->conn->auto_auth = true; |
| 533 | /* start with open system ... should mostly work */ |
| 534 | wdev->conn->params.auth_type = |
| 535 | NL80211_AUTHTYPE_OPEN_SYSTEM; |
| 536 | } else { |
| 537 | wdev->conn->auto_auth = false; |
| 538 | } |
| 539 | |
| 540 | wdev->conn->params.ssid = wdev->ssid; |
Zhao, Gang | babd3a2 | 2014-03-19 23:02:21 +0800 | [diff] [blame] | 541 | wdev->conn->params.ssid_len = wdev->ssid_len; |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 542 | |
| 543 | /* see if we have the bss already */ |
| 544 | bss = cfg80211_get_conn_bss(wdev); |
| 545 | |
| 546 | if (prev_bssid) { |
| 547 | memcpy(wdev->conn->prev_bssid, prev_bssid, ETH_ALEN); |
| 548 | wdev->conn->prev_bssid_valid = true; |
| 549 | } |
| 550 | |
| 551 | /* we're good if we have a matching bss struct */ |
| 552 | if (bss) { |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 553 | err = cfg80211_conn_do_work(wdev); |
| 554 | cfg80211_put_bss(wdev->wiphy, bss); |
| 555 | } else { |
| 556 | /* otherwise we'll need to scan for the AP first */ |
| 557 | err = cfg80211_conn_scan(wdev); |
| 558 | |
| 559 | /* |
| 560 | * If we can't scan right now, then we need to scan again |
| 561 | * after the current scan finished, since the parameters |
| 562 | * changed (unless we find a good AP anyway). |
| 563 | */ |
| 564 | if (err == -EBUSY) { |
| 565 | err = 0; |
| 566 | wdev->conn->state = CFG80211_CONN_SCAN_AGAIN; |
| 567 | } |
| 568 | } |
| 569 | |
| 570 | if (err) |
| 571 | cfg80211_sme_free(wdev); |
| 572 | |
| 573 | return err; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 574 | } |
| 575 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 576 | static int cfg80211_sme_disconnect(struct wireless_dev *wdev, u16 reason) |
Johannes Berg | 7d930bc | 2009-10-20 15:08:53 +0900 | [diff] [blame] | 577 | { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 578 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 579 | int err; |
Johannes Berg | 7d930bc | 2009-10-20 15:08:53 +0900 | [diff] [blame] | 580 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 581 | if (!wdev->conn) |
| 582 | return 0; |
| 583 | |
| 584 | if (!rdev->ops->deauth) |
| 585 | return -EOPNOTSUPP; |
| 586 | |
| 587 | if (wdev->conn->state == CFG80211_CONN_SCANNING || |
| 588 | wdev->conn->state == CFG80211_CONN_SCAN_AGAIN) { |
| 589 | err = 0; |
| 590 | goto out; |
| 591 | } |
| 592 | |
| 593 | /* wdev->conn->params.bssid must be set if > SCANNING */ |
| 594 | err = cfg80211_mlme_deauth(rdev, wdev->netdev, |
| 595 | wdev->conn->params.bssid, |
| 596 | NULL, 0, reason, false); |
| 597 | out: |
| 598 | cfg80211_sme_free(wdev); |
| 599 | return err; |
Johannes Berg | 7d930bc | 2009-10-20 15:08:53 +0900 | [diff] [blame] | 600 | } |
| 601 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 602 | /* |
| 603 | * code shared for in-device and software SME |
| 604 | */ |
| 605 | |
| 606 | static bool cfg80211_is_all_idle(void) |
| 607 | { |
| 608 | struct cfg80211_registered_device *rdev; |
| 609 | struct wireless_dev *wdev; |
| 610 | bool is_all_idle = true; |
| 611 | |
| 612 | /* |
| 613 | * All devices must be idle as otherwise if you are actively |
| 614 | * scanning some new beacon hints could be learned and would |
| 615 | * count as new regulatory hints. |
| 616 | */ |
| 617 | list_for_each_entry(rdev, &cfg80211_rdev_list, list) { |
Johannes Berg | 53873f1 | 2016-05-03 16:52:04 +0300 | [diff] [blame] | 618 | list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) { |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 619 | wdev_lock(wdev); |
| 620 | if (wdev->conn || wdev->current_bss) |
| 621 | is_all_idle = false; |
| 622 | wdev_unlock(wdev); |
| 623 | } |
| 624 | } |
| 625 | |
| 626 | return is_all_idle; |
| 627 | } |
| 628 | |
| 629 | static void disconnect_work(struct work_struct *work) |
| 630 | { |
| 631 | rtnl_lock(); |
| 632 | if (cfg80211_is_all_idle()) |
| 633 | regulatory_hint_disconnect(); |
| 634 | rtnl_unlock(); |
| 635 | } |
| 636 | |
| 637 | static DECLARE_WORK(cfg80211_disconnect_work, disconnect_work); |
| 638 | |
| 639 | |
| 640 | /* |
| 641 | * API calls for drivers implementing connect/disconnect and |
| 642 | * SME event handling |
| 643 | */ |
| 644 | |
Ben Greear | 6f39090 | 2013-06-19 14:06:25 -0700 | [diff] [blame] | 645 | /* This method must consume bss one way or another */ |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 646 | void __cfg80211_connect_result(struct net_device *dev, const u8 *bssid, |
| 647 | const u8 *req_ie, size_t req_ie_len, |
| 648 | const u8 *resp_ie, size_t resp_ie_len, |
Jouni Malinen | bf1ecd2 | 2016-05-31 00:16:50 +0300 | [diff] [blame] | 649 | int status, bool wextev, |
Johannes Berg | df7fc0f | 2009-07-29 11:23:49 +0200 | [diff] [blame] | 650 | struct cfg80211_bss *bss) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 651 | { |
| 652 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 653 | const u8 *country_ie; |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 654 | #ifdef CONFIG_CFG80211_WEXT |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 655 | union iwreq_data wrqu; |
| 656 | #endif |
| 657 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 658 | ASSERT_WDEV_LOCK(wdev); |
| 659 | |
Johannes Berg | 074ac8d | 2010-09-16 14:58:22 +0200 | [diff] [blame] | 660 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && |
Ben Greear | 6f39090 | 2013-06-19 14:06:25 -0700 | [diff] [blame] | 661 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) { |
| 662 | cfg80211_put_bss(wdev->wiphy, bss); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 663 | return; |
Ben Greear | 6f39090 | 2013-06-19 14:06:25 -0700 | [diff] [blame] | 664 | } |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 665 | |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 666 | nl80211_send_connect_result(wiphy_to_rdev(wdev->wiphy), dev, |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 667 | bssid, req_ie, req_ie_len, |
Johannes Berg | ea416a7 | 2009-08-17 12:22:14 +0200 | [diff] [blame] | 668 | resp_ie, resp_ie_len, |
| 669 | status, GFP_KERNEL); |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 670 | |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 671 | #ifdef CONFIG_CFG80211_WEXT |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 672 | if (wextev) { |
| 673 | if (req_ie && status == WLAN_STATUS_SUCCESS) { |
| 674 | memset(&wrqu, 0, sizeof(wrqu)); |
| 675 | wrqu.data.length = req_ie_len; |
Zhu Yi | 3409ff7 | 2009-07-20 11:47:44 +0800 | [diff] [blame] | 676 | wireless_send_event(dev, IWEVASSOCREQIE, &wrqu, req_ie); |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 677 | } |
| 678 | |
| 679 | if (resp_ie && status == WLAN_STATUS_SUCCESS) { |
| 680 | memset(&wrqu, 0, sizeof(wrqu)); |
| 681 | wrqu.data.length = resp_ie_len; |
| 682 | wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, resp_ie); |
| 683 | } |
| 684 | |
| 685 | memset(&wrqu, 0, sizeof(wrqu)); |
| 686 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 687 | if (bssid && status == WLAN_STATUS_SUCCESS) { |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 688 | memcpy(wrqu.ap_addr.sa_data, bssid, ETH_ALEN); |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 689 | memcpy(wdev->wext.prev_bssid, bssid, ETH_ALEN); |
| 690 | wdev->wext.prev_bssid_valid = true; |
| 691 | } |
Johannes Berg | e45cd82 | 2009-07-02 09:58:04 +0200 | [diff] [blame] | 692 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
| 693 | } |
| 694 | #endif |
| 695 | |
Ujjal Roy | 4c4d684 | 2013-12-04 17:27:34 +0530 | [diff] [blame] | 696 | if (!bss && (status == WLAN_STATUS_SUCCESS)) { |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 697 | WARN_ON_ONCE(!wiphy_to_rdev(wdev->wiphy)->ops->connect); |
Ujjal Roy | 4c4d684 | 2013-12-04 17:27:34 +0530 | [diff] [blame] | 698 | bss = cfg80211_get_bss(wdev->wiphy, NULL, bssid, |
| 699 | wdev->ssid, wdev->ssid_len, |
Lior David | 34d5051 | 2016-01-28 10:58:25 +0200 | [diff] [blame] | 700 | wdev->conn_bss_type, |
Dedy Lansky | 6eb1813 | 2015-02-08 15:52:03 +0200 | [diff] [blame] | 701 | IEEE80211_PRIVACY_ANY); |
Ujjal Roy | 4c4d684 | 2013-12-04 17:27:34 +0530 | [diff] [blame] | 702 | if (bss) |
| 703 | cfg80211_hold_bss(bss_from_pub(bss)); |
| 704 | } |
| 705 | |
Johannes Berg | df7fc0f | 2009-07-29 11:23:49 +0200 | [diff] [blame] | 706 | if (wdev->current_bss) { |
| 707 | cfg80211_unhold_bss(wdev->current_bss); |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 708 | cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); |
Johannes Berg | df7fc0f | 2009-07-29 11:23:49 +0200 | [diff] [blame] | 709 | wdev->current_bss = NULL; |
| 710 | } |
| 711 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 712 | if (status != WLAN_STATUS_SUCCESS) { |
Johannes Berg | b47f610 | 2014-09-10 13:39:54 +0300 | [diff] [blame] | 713 | kzfree(wdev->connect_keys); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 714 | wdev->connect_keys = NULL; |
Johannes Berg | 8dadadb | 2009-08-04 09:32:23 +0200 | [diff] [blame] | 715 | wdev->ssid_len = 0; |
Johannes Berg | f1940c5 | 2013-06-19 13:21:15 +0200 | [diff] [blame] | 716 | if (bss) { |
| 717 | cfg80211_unhold_bss(bss_from_pub(bss)); |
| 718 | cfg80211_put_bss(wdev->wiphy, bss); |
| 719 | } |
Eliad Peller | c1fbb25 | 2014-04-30 15:58:13 +0300 | [diff] [blame] | 720 | cfg80211_sme_free(wdev); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 721 | return; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 722 | } |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 723 | |
Ujjal Roy | 4c4d684 | 2013-12-04 17:27:34 +0530 | [diff] [blame] | 724 | if (WARN_ON(!bss)) |
| 725 | return; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 726 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 727 | wdev->current_bss = bss_from_pub(bss); |
| 728 | |
David Spinadel | b867622 | 2016-09-22 23:16:50 +0300 | [diff] [blame] | 729 | if (!(wdev->wiphy->flags & WIPHY_FLAG_HAS_STATIC_WEP)) |
| 730 | cfg80211_upload_connect_keys(wdev); |
Luis R. Rodriguez | 8b19e6c | 2009-07-30 17:38:09 -0700 | [diff] [blame] | 731 | |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 732 | rcu_read_lock(); |
| 733 | country_ie = ieee80211_bss_get_ie(bss, WLAN_EID_COUNTRY); |
| 734 | if (!country_ie) { |
| 735 | rcu_read_unlock(); |
| 736 | return; |
| 737 | } |
| 738 | |
| 739 | country_ie = kmemdup(country_ie, 2 + country_ie[1], GFP_ATOMIC); |
| 740 | rcu_read_unlock(); |
Luis R. Rodriguez | 8b19e6c | 2009-07-30 17:38:09 -0700 | [diff] [blame] | 741 | |
| 742 | if (!country_ie) |
| 743 | return; |
| 744 | |
| 745 | /* |
| 746 | * ieee80211_bss_get_ie() ensures we can access: |
| 747 | * - country_ie + 2, the start of the country ie data, and |
| 748 | * - and country_ie[1] which is the IE length |
| 749 | */ |
Luis R. Rodriguez | 789fd03 | 2013-10-04 18:07:24 -0700 | [diff] [blame] | 750 | regulatory_hint_country_ie(wdev->wiphy, bss->channel->band, |
| 751 | country_ie + 2, country_ie[1]); |
Johannes Berg | 9caf036 | 2012-11-29 01:25:20 +0100 | [diff] [blame] | 752 | kfree(country_ie); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 753 | } |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 754 | |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 755 | /* Consumes bss object one way or another */ |
| 756 | void cfg80211_connect_bss(struct net_device *dev, const u8 *bssid, |
| 757 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 758 | size_t req_ie_len, const u8 *resp_ie, |
Jouni Malinen | bf1ecd2 | 2016-05-31 00:16:50 +0300 | [diff] [blame] | 759 | size_t resp_ie_len, int status, gfp_t gfp) |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 760 | { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 761 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 762 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 763 | struct cfg80211_event *ev; |
| 764 | unsigned long flags; |
| 765 | |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 766 | if (bss) { |
| 767 | /* Make sure the bss entry provided by the driver is valid. */ |
| 768 | struct cfg80211_internal_bss *ibss = bss_from_pub(bss); |
| 769 | |
| 770 | if (WARN_ON(list_empty(&ibss->list))) { |
| 771 | cfg80211_put_bss(wdev->wiphy, bss); |
| 772 | return; |
| 773 | } |
| 774 | } |
| 775 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 776 | ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 777 | if (!ev) { |
| 778 | cfg80211_put_bss(wdev->wiphy, bss); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 779 | return; |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 780 | } |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 781 | |
| 782 | ev->type = EVENT_CONNECT_RESULT; |
Zhu Yi | 16a832e | 2009-08-19 16:08:22 +0800 | [diff] [blame] | 783 | if (bssid) |
| 784 | memcpy(ev->cr.bssid, bssid, ETH_ALEN); |
Nishant Sarmukadam | 7834704b | 2010-04-14 22:03:02 -0700 | [diff] [blame] | 785 | if (req_ie_len) { |
| 786 | ev->cr.req_ie = ((u8 *)ev) + sizeof(*ev); |
| 787 | ev->cr.req_ie_len = req_ie_len; |
| 788 | memcpy((void *)ev->cr.req_ie, req_ie, req_ie_len); |
| 789 | } |
| 790 | if (resp_ie_len) { |
| 791 | ev->cr.resp_ie = ((u8 *)ev) + sizeof(*ev) + req_ie_len; |
| 792 | ev->cr.resp_ie_len = resp_ie_len; |
| 793 | memcpy((void *)ev->cr.resp_ie, resp_ie, resp_ie_len); |
| 794 | } |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 795 | if (bss) |
| 796 | cfg80211_hold_bss(bss_from_pub(bss)); |
| 797 | ev->cr.bss = bss; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 798 | ev->cr.status = status; |
| 799 | |
| 800 | spin_lock_irqsave(&wdev->event_lock, flags); |
| 801 | list_add_tail(&ev->list, &wdev->event_list); |
| 802 | spin_unlock_irqrestore(&wdev->event_lock, flags); |
Alban Browaeys | e60d744 | 2009-11-25 15:13:00 +0100 | [diff] [blame] | 803 | queue_work(cfg80211_wq, &rdev->event_work); |
Johannes Berg | f212935 | 2009-07-01 21:26:56 +0200 | [diff] [blame] | 804 | } |
Kanchanapally, Vidyullatha | e705498 | 2016-04-11 15:16:01 +0530 | [diff] [blame] | 805 | EXPORT_SYMBOL(cfg80211_connect_bss); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 806 | |
Ben Greear | 0e3a39b | 2013-06-19 14:06:27 -0700 | [diff] [blame] | 807 | /* Consumes bss object one way or another */ |
Jouni Malinen | ed9d010 | 2011-05-16 19:40:15 +0300 | [diff] [blame] | 808 | void __cfg80211_roamed(struct wireless_dev *wdev, |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 809 | struct cfg80211_bss *bss, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 810 | const u8 *req_ie, size_t req_ie_len, |
| 811 | const u8 *resp_ie, size_t resp_ie_len) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 812 | { |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 813 | #ifdef CONFIG_CFG80211_WEXT |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 814 | union iwreq_data wrqu; |
| 815 | #endif |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 816 | ASSERT_WDEV_LOCK(wdev); |
| 817 | |
Johannes Berg | 074ac8d | 2010-09-16 14:58:22 +0200 | [diff] [blame] | 818 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && |
| 819 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 820 | goto out; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 821 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 822 | if (WARN_ON(!wdev->current_bss)) |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 823 | goto out; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 824 | |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 825 | cfg80211_unhold_bss(wdev->current_bss); |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 826 | cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 827 | wdev->current_bss = NULL; |
| 828 | |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 829 | cfg80211_hold_bss(bss_from_pub(bss)); |
| 830 | wdev->current_bss = bss_from_pub(bss); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 831 | |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 832 | nl80211_send_roamed(wiphy_to_rdev(wdev->wiphy), |
| 833 | wdev->netdev, bss->bssid, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 834 | req_ie, req_ie_len, resp_ie, resp_ie_len, |
| 835 | GFP_KERNEL); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 836 | |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 837 | #ifdef CONFIG_CFG80211_WEXT |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 838 | if (req_ie) { |
| 839 | memset(&wrqu, 0, sizeof(wrqu)); |
| 840 | wrqu.data.length = req_ie_len; |
Zhu Yi | 3409ff7 | 2009-07-20 11:47:44 +0800 | [diff] [blame] | 841 | wireless_send_event(wdev->netdev, IWEVASSOCREQIE, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 842 | &wrqu, req_ie); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 843 | } |
| 844 | |
| 845 | if (resp_ie) { |
| 846 | memset(&wrqu, 0, sizeof(wrqu)); |
| 847 | wrqu.data.length = resp_ie_len; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 848 | wireless_send_event(wdev->netdev, IWEVASSOCRESPIE, |
| 849 | &wrqu, resp_ie); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 850 | } |
| 851 | |
| 852 | memset(&wrqu, 0, sizeof(wrqu)); |
| 853 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 854 | memcpy(wrqu.ap_addr.sa_data, bss->bssid, ETH_ALEN); |
| 855 | memcpy(wdev->wext.prev_bssid, bss->bssid, ETH_ALEN); |
Johannes Berg | f401a6f | 2009-08-07 14:51:05 +0200 | [diff] [blame] | 856 | wdev->wext.prev_bssid_valid = true; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 857 | wireless_send_event(wdev->netdev, SIOCGIWAP, &wrqu, NULL); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 858 | #endif |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 859 | |
| 860 | return; |
| 861 | out: |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 862 | cfg80211_put_bss(wdev->wiphy, bss); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 863 | } |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 864 | |
Jouni Malinen | ed9d010 | 2011-05-16 19:40:15 +0300 | [diff] [blame] | 865 | void cfg80211_roamed(struct net_device *dev, |
| 866 | struct ieee80211_channel *channel, |
| 867 | const u8 *bssid, |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 868 | const u8 *req_ie, size_t req_ie_len, |
| 869 | const u8 *resp_ie, size_t resp_ie_len, gfp_t gfp) |
| 870 | { |
| 871 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 872 | struct cfg80211_bss *bss; |
| 873 | |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 874 | bss = cfg80211_get_bss(wdev->wiphy, channel, bssid, wdev->ssid, |
Dedy Lansky | 6eb1813 | 2015-02-08 15:52:03 +0200 | [diff] [blame] | 875 | wdev->ssid_len, |
Lior David | 34d5051 | 2016-01-28 10:58:25 +0200 | [diff] [blame] | 876 | wdev->conn_bss_type, IEEE80211_PRIVACY_ANY); |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 877 | if (WARN_ON(!bss)) |
| 878 | return; |
| 879 | |
| 880 | cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, |
| 881 | resp_ie_len, gfp); |
| 882 | } |
| 883 | EXPORT_SYMBOL(cfg80211_roamed); |
| 884 | |
Ben Greear | 0e3a39b | 2013-06-19 14:06:27 -0700 | [diff] [blame] | 885 | /* Consumes bss object one way or another */ |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 886 | void cfg80211_roamed_bss(struct net_device *dev, |
| 887 | struct cfg80211_bss *bss, const u8 *req_ie, |
| 888 | size_t req_ie_len, const u8 *resp_ie, |
| 889 | size_t resp_ie_len, gfp_t gfp) |
| 890 | { |
| 891 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 892 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 893 | struct cfg80211_event *ev; |
| 894 | unsigned long flags; |
| 895 | |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 896 | if (WARN_ON(!bss)) |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 897 | return; |
| 898 | |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 899 | ev = kzalloc(sizeof(*ev) + req_ie_len + resp_ie_len, gfp); |
| 900 | if (!ev) { |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 901 | cfg80211_put_bss(wdev->wiphy, bss); |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 902 | return; |
| 903 | } |
| 904 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 905 | ev->type = EVENT_ROAMED; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 906 | ev->rm.req_ie = ((u8 *)ev) + sizeof(*ev); |
| 907 | ev->rm.req_ie_len = req_ie_len; |
| 908 | memcpy((void *)ev->rm.req_ie, req_ie, req_ie_len); |
| 909 | ev->rm.resp_ie = ((u8 *)ev) + sizeof(*ev) + req_ie_len; |
| 910 | ev->rm.resp_ie_len = resp_ie_len; |
| 911 | memcpy((void *)ev->rm.resp_ie, resp_ie, resp_ie_len); |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 912 | ev->rm.bss = bss; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 913 | |
| 914 | spin_lock_irqsave(&wdev->event_lock, flags); |
| 915 | list_add_tail(&ev->list, &wdev->event_list); |
| 916 | spin_unlock_irqrestore(&wdev->event_lock, flags); |
Alban Browaeys | e60d744 | 2009-11-25 15:13:00 +0100 | [diff] [blame] | 917 | queue_work(cfg80211_wq, &rdev->event_work); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 918 | } |
Vasanthakumar Thiagarajan | adbde34 | 2011-12-08 14:28:47 +0530 | [diff] [blame] | 919 | EXPORT_SYMBOL(cfg80211_roamed_bss); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 920 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 921 | void __cfg80211_disconnected(struct net_device *dev, const u8 *ie, |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 922 | size_t ie_len, u16 reason, bool from_ap) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 923 | { |
| 924 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 925 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 926 | int i; |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 927 | #ifdef CONFIG_CFG80211_WEXT |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 928 | union iwreq_data wrqu; |
| 929 | #endif |
| 930 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 931 | ASSERT_WDEV_LOCK(wdev); |
| 932 | |
Johannes Berg | 074ac8d | 2010-09-16 14:58:22 +0200 | [diff] [blame] | 933 | if (WARN_ON(wdev->iftype != NL80211_IFTYPE_STATION && |
| 934 | wdev->iftype != NL80211_IFTYPE_P2P_CLIENT)) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 935 | return; |
| 936 | |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 937 | if (wdev->current_bss) { |
| 938 | cfg80211_unhold_bss(wdev->current_bss); |
Johannes Berg | 5b112d3 | 2013-02-01 01:49:58 +0100 | [diff] [blame] | 939 | cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 940 | } |
| 941 | |
| 942 | wdev->current_bss = NULL; |
Johannes Berg | 8dadadb | 2009-08-04 09:32:23 +0200 | [diff] [blame] | 943 | wdev->ssid_len = 0; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 944 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 945 | nl80211_send_disconnected(rdev, dev, reason, ie, ie_len, from_ap); |
| 946 | |
Arend van Spriel | b860715 | 2016-02-15 14:35:53 +0100 | [diff] [blame] | 947 | /* stop critical protocol if supported */ |
| 948 | if (rdev->ops->crit_proto_stop && rdev->crit_proto_nlportid) { |
| 949 | rdev->crit_proto_nlportid = 0; |
| 950 | rdev_crit_proto_stop(rdev, wdev); |
| 951 | } |
| 952 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 953 | /* |
| 954 | * Delete all the keys ... pairwise keys can't really |
| 955 | * exist any more anyway, but default keys might. |
| 956 | */ |
| 957 | if (rdev->ops->del_key) |
| 958 | for (i = 0; i < 6; i++) |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 959 | rdev_del_key(rdev, dev, i, false, NULL); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 960 | |
Kyeyoon Park | fa9ffc7 | 2013-12-16 23:01:30 -0800 | [diff] [blame] | 961 | rdev_set_qos_map(rdev, dev, NULL); |
| 962 | |
Johannes Berg | 3d23e34 | 2009-09-29 23:27:28 +0200 | [diff] [blame] | 963 | #ifdef CONFIG_CFG80211_WEXT |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 964 | memset(&wrqu, 0, sizeof(wrqu)); |
| 965 | wrqu.ap_addr.sa_family = ARPHRD_ETHER; |
| 966 | wireless_send_event(dev, SIOCGIWAP, &wrqu, NULL); |
Abhijeet Kolekar | 5f61203 | 2010-01-13 13:23:14 -0800 | [diff] [blame] | 967 | wdev->wext.connect.ssid_len = 0; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 968 | #endif |
Luis R. Rodriguez | 09d989d | 2010-01-29 19:58:57 -0500 | [diff] [blame] | 969 | |
| 970 | schedule_work(&cfg80211_disconnect_work); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 971 | } |
| 972 | |
| 973 | void cfg80211_disconnected(struct net_device *dev, u16 reason, |
Johannes Berg | 80279fb | 2015-05-22 16:22:20 +0200 | [diff] [blame] | 974 | const u8 *ie, size_t ie_len, |
| 975 | bool locally_generated, gfp_t gfp) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 976 | { |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 977 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Zhao, Gang | f26cbf4 | 2014-04-21 12:53:03 +0800 | [diff] [blame] | 978 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy); |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 979 | struct cfg80211_event *ev; |
| 980 | unsigned long flags; |
| 981 | |
| 982 | ev = kzalloc(sizeof(*ev) + ie_len, gfp); |
| 983 | if (!ev) |
| 984 | return; |
| 985 | |
| 986 | ev->type = EVENT_DISCONNECTED; |
| 987 | ev->dc.ie = ((u8 *)ev) + sizeof(*ev); |
| 988 | ev->dc.ie_len = ie_len; |
| 989 | memcpy((void *)ev->dc.ie, ie, ie_len); |
| 990 | ev->dc.reason = reason; |
Johannes Berg | 80279fb | 2015-05-22 16:22:20 +0200 | [diff] [blame] | 991 | ev->dc.locally_generated = locally_generated; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 992 | |
| 993 | spin_lock_irqsave(&wdev->event_lock, flags); |
| 994 | list_add_tail(&ev->list, &wdev->event_list); |
| 995 | spin_unlock_irqrestore(&wdev->event_lock, flags); |
Alban Browaeys | e60d744 | 2009-11-25 15:13:00 +0100 | [diff] [blame] | 996 | queue_work(cfg80211_wq, &rdev->event_work); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 997 | } |
| 998 | EXPORT_SYMBOL(cfg80211_disconnected); |
| 999 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1000 | /* |
| 1001 | * API calls for nl80211/wext compatibility code |
| 1002 | */ |
Johannes Berg | 83739b0 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 1003 | int cfg80211_connect(struct cfg80211_registered_device *rdev, |
| 1004 | struct net_device *dev, |
| 1005 | struct cfg80211_connect_params *connect, |
| 1006 | struct cfg80211_cached_keys *connkeys, |
| 1007 | const u8 *prev_bssid) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1008 | { |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1009 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1010 | int err; |
| 1011 | |
| 1012 | ASSERT_WDEV_LOCK(wdev); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1013 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1014 | if (WARN_ON(wdev->connect_keys)) { |
Johannes Berg | b47f610 | 2014-09-10 13:39:54 +0300 | [diff] [blame] | 1015 | kzfree(wdev->connect_keys); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1016 | wdev->connect_keys = NULL; |
| 1017 | } |
| 1018 | |
Ben Greear | 7e7c892 | 2011-11-18 11:31:59 -0800 | [diff] [blame] | 1019 | cfg80211_oper_and_ht_capa(&connect->ht_capa_mask, |
| 1020 | rdev->wiphy.ht_capa_mod_mask); |
| 1021 | |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1022 | if (connkeys && connkeys->def >= 0) { |
| 1023 | int idx; |
Samuel Ortiz | bcba8ea | 2009-08-06 21:04:41 +0200 | [diff] [blame] | 1024 | u32 cipher; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1025 | |
| 1026 | idx = connkeys->def; |
Samuel Ortiz | bcba8ea | 2009-08-06 21:04:41 +0200 | [diff] [blame] | 1027 | cipher = connkeys->params[idx].cipher; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1028 | /* If given a WEP key we may need it for shared key auth */ |
Samuel Ortiz | bcba8ea | 2009-08-06 21:04:41 +0200 | [diff] [blame] | 1029 | if (cipher == WLAN_CIPHER_SUITE_WEP40 || |
| 1030 | cipher == WLAN_CIPHER_SUITE_WEP104) { |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1031 | connect->key_idx = idx; |
| 1032 | connect->key = connkeys->params[idx].key; |
| 1033 | connect->key_len = connkeys->params[idx].key_len; |
Samuel Ortiz | bcba8ea | 2009-08-06 21:04:41 +0200 | [diff] [blame] | 1034 | |
| 1035 | /* |
| 1036 | * If ciphers are not set (e.g. when going through |
| 1037 | * iwconfig), we have to set them appropriately here. |
| 1038 | */ |
| 1039 | if (connect->crypto.cipher_group == 0) |
| 1040 | connect->crypto.cipher_group = cipher; |
| 1041 | |
| 1042 | if (connect->crypto.n_ciphers_pairwise == 0) { |
| 1043 | connect->crypto.n_ciphers_pairwise = 1; |
| 1044 | connect->crypto.ciphers_pairwise[0] = cipher; |
| 1045 | } |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1046 | } |
David Spinadel | b867622 | 2016-09-22 23:16:50 +0300 | [diff] [blame] | 1047 | |
| 1048 | connect->crypto.wep_keys = connkeys->params; |
| 1049 | connect->crypto.wep_tx_key = connkeys->def; |
Johannes Berg | f1c1f17 | 2016-09-13 17:08:23 +0200 | [diff] [blame] | 1050 | } else { |
| 1051 | if (WARN_ON(connkeys)) |
| 1052 | return -EINVAL; |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1053 | } |
| 1054 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1055 | wdev->connect_keys = connkeys; |
| 1056 | memcpy(wdev->ssid, connect->ssid, connect->ssid_len); |
| 1057 | wdev->ssid_len = connect->ssid_len; |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 1058 | |
Lior David | 34d5051 | 2016-01-28 10:58:25 +0200 | [diff] [blame] | 1059 | wdev->conn_bss_type = connect->pbss ? IEEE80211_BSS_TYPE_PBSS : |
| 1060 | IEEE80211_BSS_TYPE_ESS; |
| 1061 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1062 | if (!rdev->ops->connect) |
| 1063 | err = cfg80211_sme_connect(wdev, connect, prev_bssid); |
| 1064 | else |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 1065 | err = rdev_connect(rdev, dev, connect); |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 1066 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1067 | if (err) { |
| 1068 | wdev->connect_keys = NULL; |
| 1069 | wdev->ssid_len = 0; |
| 1070 | return err; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1071 | } |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1072 | |
| 1073 | return 0; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1074 | } |
| 1075 | |
Johannes Berg | 83739b0 | 2013-05-15 17:44:01 +0200 | [diff] [blame] | 1076 | int cfg80211_disconnect(struct cfg80211_registered_device *rdev, |
| 1077 | struct net_device *dev, u16 reason, bool wextev) |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1078 | { |
Johannes Berg | 6829c87 | 2009-07-02 09:13:27 +0200 | [diff] [blame] | 1079 | struct wireless_dev *wdev = dev->ieee80211_ptr; |
Johannes Berg | dee8a97 | 2013-08-13 09:23:57 +0200 | [diff] [blame] | 1080 | int err = 0; |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1081 | |
Johannes Berg | 667503dd | 2009-07-07 03:56:11 +0200 | [diff] [blame] | 1082 | ASSERT_WDEV_LOCK(wdev); |
| 1083 | |
Johannes Berg | b47f610 | 2014-09-10 13:39:54 +0300 | [diff] [blame] | 1084 | kzfree(wdev->connect_keys); |
Johannes Berg | fffd093 | 2009-07-08 14:22:54 +0200 | [diff] [blame] | 1085 | wdev->connect_keys = NULL; |
| 1086 | |
Johannes Berg | dee8a97 | 2013-08-13 09:23:57 +0200 | [diff] [blame] | 1087 | if (wdev->conn) |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1088 | err = cfg80211_sme_disconnect(wdev, reason); |
Johannes Berg | dee8a97 | 2013-08-13 09:23:57 +0200 | [diff] [blame] | 1089 | else if (!rdev->ops->disconnect) |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1090 | cfg80211_mlme_down(rdev, dev); |
Johannes Berg | dee8a97 | 2013-08-13 09:23:57 +0200 | [diff] [blame] | 1091 | else if (wdev->current_bss) |
Hila Gonen | e35e4d2 | 2012-06-27 17:19:42 +0300 | [diff] [blame] | 1092 | err = rdev_disconnect(rdev, dev, reason); |
Samuel Ortiz | b23aa67 | 2009-07-01 21:26:54 +0200 | [diff] [blame] | 1093 | |
Johannes Berg | ceca7b7 | 2013-05-16 00:55:45 +0200 | [diff] [blame] | 1094 | return err; |
Johannes Berg | 19957bb | 2009-07-02 17:20:43 +0200 | [diff] [blame] | 1095 | } |