core.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229
  1. /*
  2. * This is the linux wireless configuration interface.
  3. *
  4. * Copyright 2006-2010 Johannes Berg <johannes@sipsolutions.net>
  5. * Copyright 2013-2014 Intel Mobile Communications GmbH
  6. */
  7. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  8. #include <linux/if.h>
  9. #include <linux/module.h>
  10. #include <linux/err.h>
  11. #include <linux/list.h>
  12. #include <linux/slab.h>
  13. #include <linux/nl80211.h>
  14. #include <linux/debugfs.h>
  15. #include <linux/notifier.h>
  16. #include <linux/device.h>
  17. #include <linux/etherdevice.h>
  18. #include <linux/rtnetlink.h>
  19. #include <linux/sched.h>
  20. #include <net/genetlink.h>
  21. #include <net/cfg80211.h>
  22. #include <net/rtnetlink.h>
  23. #include "nl80211.h"
  24. #include "core.h"
  25. #include "sysfs.h"
  26. #include "debugfs.h"
  27. #include "wext-compat.h"
  28. #include "rdev-ops.h"
  29. /* name for sysfs, %d is appended */
  30. #define PHY_NAME "phy"
  31. MODULE_AUTHOR("Johannes Berg");
  32. MODULE_LICENSE("GPL");
  33. MODULE_DESCRIPTION("wireless configuration support");
  34. MODULE_ALIAS_GENL_FAMILY(NL80211_GENL_NAME);
  35. /* RCU-protected (and RTNL for writers) */
  36. LIST_HEAD(cfg80211_rdev_list);
  37. int cfg80211_rdev_list_generation;
  38. /* for debugfs */
  39. static struct dentry *ieee80211_debugfs_dir;
  40. /* for the cleanup, scan and event works */
  41. struct workqueue_struct *cfg80211_wq;
  42. static bool cfg80211_disable_40mhz_24ghz;
  43. module_param(cfg80211_disable_40mhz_24ghz, bool, 0644);
  44. MODULE_PARM_DESC(cfg80211_disable_40mhz_24ghz,
  45. "Disable 40MHz support in the 2.4GHz band");
  46. struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
  47. {
  48. struct cfg80211_registered_device *result = NULL, *rdev;
  49. ASSERT_RTNL();
  50. list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
  51. if (rdev->wiphy_idx == wiphy_idx) {
  52. result = rdev;
  53. break;
  54. }
  55. }
  56. return result;
  57. }
  58. int get_wiphy_idx(struct wiphy *wiphy)
  59. {
  60. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  61. return rdev->wiphy_idx;
  62. }
  63. struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
  64. {
  65. struct cfg80211_registered_device *rdev;
  66. ASSERT_RTNL();
  67. rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx);
  68. if (!rdev)
  69. return NULL;
  70. return &rdev->wiphy;
  71. }
  72. static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
  73. const char *newname)
  74. {
  75. struct cfg80211_registered_device *rdev2;
  76. int wiphy_idx, taken = -1, digits;
  77. ASSERT_RTNL();
  78. /* prohibit calling the thing phy%d when %d is not its number */
  79. sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
  80. if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
  81. /* count number of places needed to print wiphy_idx */
  82. digits = 1;
  83. while (wiphy_idx /= 10)
  84. digits++;
  85. /*
  86. * deny the name if it is phy<idx> where <idx> is printed
  87. * without leading zeroes. taken == strlen(newname) here
  88. */
  89. if (taken == strlen(PHY_NAME) + digits)
  90. return -EINVAL;
  91. }
  92. /* Ensure another device does not already have this name. */
  93. list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
  94. if (strcmp(newname, wiphy_name(&rdev2->wiphy)) == 0)
  95. return -EINVAL;
  96. return 0;
  97. }
  98. int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
  99. char *newname)
  100. {
  101. int result;
  102. ASSERT_RTNL();
  103. /* Ignore nop renames */
  104. if (strcmp(newname, wiphy_name(&rdev->wiphy)) == 0)
  105. return 0;
  106. result = cfg80211_dev_check_name(rdev, newname);
  107. if (result < 0)
  108. return result;
  109. result = device_rename(&rdev->wiphy.dev, newname);
  110. if (result)
  111. return result;
  112. if (rdev->wiphy.debugfsdir &&
  113. !debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
  114. rdev->wiphy.debugfsdir,
  115. rdev->wiphy.debugfsdir->d_parent,
  116. newname))
  117. pr_err("failed to rename debugfs dir to %s!\n", newname);
  118. nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
  119. return 0;
  120. }
  121. int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
  122. struct net *net)
  123. {
  124. struct wireless_dev *wdev;
  125. int err = 0;
  126. if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
  127. return -EOPNOTSUPP;
  128. list_for_each_entry(wdev, &rdev->wdev_list, list) {
  129. if (!wdev->netdev)
  130. continue;
  131. wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
  132. err = dev_change_net_namespace(wdev->netdev, net, "wlan%d");
  133. if (err)
  134. break;
  135. wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
  136. }
  137. if (err) {
  138. /* failed -- clean up to old netns */
  139. net = wiphy_net(&rdev->wiphy);
  140. list_for_each_entry_continue_reverse(wdev, &rdev->wdev_list,
  141. list) {
  142. if (!wdev->netdev)
  143. continue;
  144. wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
  145. err = dev_change_net_namespace(wdev->netdev, net,
  146. "wlan%d");
  147. WARN_ON(err);
  148. wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
  149. }
  150. return err;
  151. }
  152. wiphy_net_set(&rdev->wiphy, net);
  153. err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
  154. WARN_ON(err);
  155. return 0;
  156. }
  157. static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
  158. {
  159. struct cfg80211_registered_device *rdev = data;
  160. rdev_rfkill_poll(rdev);
  161. }
  162. void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
  163. struct wireless_dev *wdev)
  164. {
  165. ASSERT_RTNL();
  166. if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE))
  167. return;
  168. if (!wdev->p2p_started)
  169. return;
  170. rdev_stop_p2p_device(rdev, wdev);
  171. wdev->p2p_started = false;
  172. rdev->opencount--;
  173. if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  174. if (WARN_ON(!rdev->scan_req->notified))
  175. rdev->scan_req->aborted = true;
  176. ___cfg80211_scan_done(rdev, false);
  177. }
  178. }
  179. void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
  180. {
  181. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  182. struct wireless_dev *wdev;
  183. ASSERT_RTNL();
  184. list_for_each_entry(wdev, &rdev->wdev_list, list) {
  185. if (wdev->netdev) {
  186. dev_close(wdev->netdev);
  187. continue;
  188. }
  189. /* otherwise, check iftype */
  190. switch (wdev->iftype) {
  191. case NL80211_IFTYPE_P2P_DEVICE:
  192. cfg80211_stop_p2p_device(rdev, wdev);
  193. break;
  194. default:
  195. break;
  196. }
  197. }
  198. }
  199. EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces);
  200. static int cfg80211_rfkill_set_block(void *data, bool blocked)
  201. {
  202. struct cfg80211_registered_device *rdev = data;
  203. if (!blocked)
  204. return 0;
  205. rtnl_lock();
  206. cfg80211_shutdown_all_interfaces(&rdev->wiphy);
  207. rtnl_unlock();
  208. return 0;
  209. }
  210. static void cfg80211_rfkill_sync_work(struct work_struct *work)
  211. {
  212. struct cfg80211_registered_device *rdev;
  213. rdev = container_of(work, struct cfg80211_registered_device, rfkill_sync);
  214. cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
  215. }
  216. static void cfg80211_event_work(struct work_struct *work)
  217. {
  218. struct cfg80211_registered_device *rdev;
  219. rdev = container_of(work, struct cfg80211_registered_device,
  220. event_work);
  221. rtnl_lock();
  222. cfg80211_process_rdev_events(rdev);
  223. rtnl_unlock();
  224. }
  225. void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)
  226. {
  227. struct cfg80211_iface_destroy *item;
  228. ASSERT_RTNL();
  229. spin_lock_irq(&rdev->destroy_list_lock);
  230. while ((item = list_first_entry_or_null(&rdev->destroy_list,
  231. struct cfg80211_iface_destroy,
  232. list))) {
  233. struct wireless_dev *wdev, *tmp;
  234. u32 nlportid = item->nlportid;
  235. list_del(&item->list);
  236. kfree(item);
  237. spin_unlock_irq(&rdev->destroy_list_lock);
  238. list_for_each_entry_safe(wdev, tmp, &rdev->wdev_list, list) {
  239. if (nlportid == wdev->owner_nlportid)
  240. rdev_del_virtual_intf(rdev, wdev);
  241. }
  242. spin_lock_irq(&rdev->destroy_list_lock);
  243. }
  244. spin_unlock_irq(&rdev->destroy_list_lock);
  245. }
  246. static void cfg80211_destroy_iface_wk(struct work_struct *work)
  247. {
  248. struct cfg80211_registered_device *rdev;
  249. rdev = container_of(work, struct cfg80211_registered_device,
  250. destroy_work);
  251. rtnl_lock();
  252. cfg80211_destroy_ifaces(rdev);
  253. rtnl_unlock();
  254. }
  255. static void cfg80211_sched_scan_stop_wk(struct work_struct *work)
  256. {
  257. struct cfg80211_registered_device *rdev;
  258. rdev = container_of(work, struct cfg80211_registered_device,
  259. sched_scan_stop_wk);
  260. rtnl_lock();
  261. __cfg80211_stop_sched_scan(rdev, false);
  262. rtnl_unlock();
  263. }
  264. /* exported functions */
  265. struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
  266. const char *requested_name)
  267. {
  268. static atomic_t wiphy_counter = ATOMIC_INIT(0);
  269. struct cfg80211_registered_device *rdev;
  270. int alloc_size;
  271. WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
  272. WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
  273. WARN_ON(ops->connect && !ops->disconnect);
  274. WARN_ON(ops->join_ibss && !ops->leave_ibss);
  275. WARN_ON(ops->add_virtual_intf && !ops->del_virtual_intf);
  276. WARN_ON(ops->add_station && !ops->del_station);
  277. WARN_ON(ops->add_mpath && !ops->del_mpath);
  278. WARN_ON(ops->join_mesh && !ops->leave_mesh);
  279. alloc_size = sizeof(*rdev) + sizeof_priv;
  280. rdev = kzalloc(alloc_size, GFP_KERNEL);
  281. if (!rdev)
  282. return NULL;
  283. rdev->ops = ops;
  284. rdev->wiphy_idx = atomic_inc_return(&wiphy_counter);
  285. if (unlikely(rdev->wiphy_idx < 0)) {
  286. /* ugh, wrapped! */
  287. atomic_dec(&wiphy_counter);
  288. kfree(rdev);
  289. return NULL;
  290. }
  291. /* atomic_inc_return makes it start at 1, make it start at 0 */
  292. rdev->wiphy_idx--;
  293. /* give it a proper name */
  294. if (requested_name && requested_name[0]) {
  295. int rv;
  296. rtnl_lock();
  297. rv = cfg80211_dev_check_name(rdev, requested_name);
  298. if (rv < 0) {
  299. rtnl_unlock();
  300. goto use_default_name;
  301. }
  302. rv = dev_set_name(&rdev->wiphy.dev, "%s", requested_name);
  303. rtnl_unlock();
  304. if (rv)
  305. goto use_default_name;
  306. } else {
  307. use_default_name:
  308. /* NOTE: This is *probably* safe w/out holding rtnl because of
  309. * the restrictions on phy names. Probably this call could
  310. * fail if some other part of the kernel (re)named a device
  311. * phyX. But, might should add some locking and check return
  312. * value, and use a different name if this one exists?
  313. */
  314. dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
  315. }
  316. INIT_LIST_HEAD(&rdev->wdev_list);
  317. INIT_LIST_HEAD(&rdev->beacon_registrations);
  318. spin_lock_init(&rdev->beacon_registrations_lock);
  319. spin_lock_init(&rdev->bss_lock);
  320. INIT_LIST_HEAD(&rdev->bss_list);
  321. INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done);
  322. INIT_WORK(&rdev->sched_scan_results_wk, __cfg80211_sched_scan_results);
  323. INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
  324. cfg80211_dfs_channels_update_work);
  325. #ifdef CONFIG_CFG80211_WEXT
  326. rdev->wiphy.wext = &cfg80211_wext_handler;
  327. #endif
  328. device_initialize(&rdev->wiphy.dev);
  329. rdev->wiphy.dev.class = &ieee80211_class;
  330. rdev->wiphy.dev.platform_data = rdev;
  331. INIT_LIST_HEAD(&rdev->destroy_list);
  332. spin_lock_init(&rdev->destroy_list_lock);
  333. INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk);
  334. INIT_WORK(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk);
  335. #ifdef CONFIG_CFG80211_DEFAULT_PS
  336. rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
  337. #endif
  338. wiphy_net_set(&rdev->wiphy, &init_net);
  339. rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block;
  340. rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
  341. &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
  342. &rdev->rfkill_ops, rdev);
  343. if (!rdev->rfkill) {
  344. kfree(rdev);
  345. return NULL;
  346. }
  347. INIT_WORK(&rdev->rfkill_sync, cfg80211_rfkill_sync_work);
  348. INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
  349. INIT_WORK(&rdev->event_work, cfg80211_event_work);
  350. init_waitqueue_head(&rdev->dev_wait);
  351. /*
  352. * Initialize wiphy parameters to IEEE 802.11 MIB default values.
  353. * Fragmentation and RTS threshold are disabled by default with the
  354. * special -1 value.
  355. */
  356. rdev->wiphy.retry_short = 7;
  357. rdev->wiphy.retry_long = 4;
  358. rdev->wiphy.frag_threshold = (u32) -1;
  359. rdev->wiphy.rts_threshold = (u32) -1;
  360. rdev->wiphy.coverage_class = 0;
  361. rdev->wiphy.max_num_csa_counters = 1;
  362. return &rdev->wiphy;
  363. }
  364. EXPORT_SYMBOL(wiphy_new_nm);
  365. static int wiphy_verify_combinations(struct wiphy *wiphy)
  366. {
  367. const struct ieee80211_iface_combination *c;
  368. int i, j;
  369. for (i = 0; i < wiphy->n_iface_combinations; i++) {
  370. u32 cnt = 0;
  371. u16 all_iftypes = 0;
  372. c = &wiphy->iface_combinations[i];
  373. /*
  374. * Combinations with just one interface aren't real,
  375. * however we make an exception for DFS.
  376. */
  377. if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
  378. return -EINVAL;
  379. /* Need at least one channel */
  380. if (WARN_ON(!c->num_different_channels))
  381. return -EINVAL;
  382. /*
  383. * Put a sane limit on maximum number of different
  384. * channels to simplify channel accounting code.
  385. */
  386. if (WARN_ON(c->num_different_channels >
  387. CFG80211_MAX_NUM_DIFFERENT_CHANNELS))
  388. return -EINVAL;
  389. /* DFS only works on one channel. */
  390. if (WARN_ON(c->radar_detect_widths &&
  391. (c->num_different_channels > 1)))
  392. return -EINVAL;
  393. if (WARN_ON(!c->n_limits))
  394. return -EINVAL;
  395. for (j = 0; j < c->n_limits; j++) {
  396. u16 types = c->limits[j].types;
  397. /* interface types shouldn't overlap */
  398. if (WARN_ON(types & all_iftypes))
  399. return -EINVAL;
  400. all_iftypes |= types;
  401. if (WARN_ON(!c->limits[j].max))
  402. return -EINVAL;
  403. /* Shouldn't list software iftypes in combinations! */
  404. if (WARN_ON(wiphy->software_iftypes & types))
  405. return -EINVAL;
  406. /* Only a single P2P_DEVICE can be allowed */
  407. if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
  408. c->limits[j].max > 1))
  409. return -EINVAL;
  410. cnt += c->limits[j].max;
  411. /*
  412. * Don't advertise an unsupported type
  413. * in a combination.
  414. */
  415. if (WARN_ON((wiphy->interface_modes & types) != types))
  416. return -EINVAL;
  417. }
  418. /* You can't even choose that many! */
  419. if (WARN_ON(cnt < c->max_interfaces))
  420. return -EINVAL;
  421. }
  422. return 0;
  423. }
  424. int wiphy_register(struct wiphy *wiphy)
  425. {
  426. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  427. int res;
  428. enum ieee80211_band band;
  429. struct ieee80211_supported_band *sband;
  430. bool have_band = false;
  431. int i;
  432. u16 ifmodes = wiphy->interface_modes;
  433. #ifdef CONFIG_PM
  434. if (WARN_ON(wiphy->wowlan &&
  435. (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
  436. !(wiphy->wowlan->flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY)))
  437. return -EINVAL;
  438. if (WARN_ON(wiphy->wowlan &&
  439. !wiphy->wowlan->flags && !wiphy->wowlan->n_patterns &&
  440. !wiphy->wowlan->tcp))
  441. return -EINVAL;
  442. #endif
  443. if (WARN_ON((wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) &&
  444. (!rdev->ops->tdls_channel_switch ||
  445. !rdev->ops->tdls_cancel_channel_switch)))
  446. return -EINVAL;
  447. /*
  448. * if a wiphy has unsupported modes for regulatory channel enforcement,
  449. * opt-out of enforcement checking
  450. */
  451. if (wiphy->interface_modes & ~(BIT(NL80211_IFTYPE_STATION) |
  452. BIT(NL80211_IFTYPE_P2P_CLIENT) |
  453. BIT(NL80211_IFTYPE_AP) |
  454. BIT(NL80211_IFTYPE_P2P_GO) |
  455. BIT(NL80211_IFTYPE_ADHOC) |
  456. BIT(NL80211_IFTYPE_P2P_DEVICE) |
  457. BIT(NL80211_IFTYPE_AP_VLAN) |
  458. BIT(NL80211_IFTYPE_MONITOR)))
  459. wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
  460. if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) &&
  461. (wiphy->regulatory_flags &
  462. (REGULATORY_CUSTOM_REG |
  463. REGULATORY_STRICT_REG |
  464. REGULATORY_COUNTRY_IE_FOLLOW_POWER |
  465. REGULATORY_COUNTRY_IE_IGNORE))))
  466. return -EINVAL;
  467. if (WARN_ON(wiphy->coalesce &&
  468. (!wiphy->coalesce->n_rules ||
  469. !wiphy->coalesce->n_patterns) &&
  470. (!wiphy->coalesce->pattern_min_len ||
  471. wiphy->coalesce->pattern_min_len >
  472. wiphy->coalesce->pattern_max_len)))
  473. return -EINVAL;
  474. if (WARN_ON(wiphy->ap_sme_capa &&
  475. !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME)))
  476. return -EINVAL;
  477. if (WARN_ON(wiphy->addresses && !wiphy->n_addresses))
  478. return -EINVAL;
  479. if (WARN_ON(wiphy->addresses &&
  480. !is_zero_ether_addr(wiphy->perm_addr) &&
  481. memcmp(wiphy->perm_addr, wiphy->addresses[0].addr,
  482. ETH_ALEN)))
  483. return -EINVAL;
  484. if (WARN_ON(wiphy->max_acl_mac_addrs &&
  485. (!(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME) ||
  486. !rdev->ops->set_mac_acl)))
  487. return -EINVAL;
  488. if (wiphy->addresses)
  489. memcpy(wiphy->perm_addr, wiphy->addresses[0].addr, ETH_ALEN);
  490. /* sanity check ifmodes */
  491. WARN_ON(!ifmodes);
  492. ifmodes &= ((1 << NUM_NL80211_IFTYPES) - 1) & ~1;
  493. if (WARN_ON(ifmodes != wiphy->interface_modes))
  494. wiphy->interface_modes = ifmodes;
  495. res = wiphy_verify_combinations(wiphy);
  496. if (res)
  497. return res;
  498. /* sanity check supported bands/channels */
  499. for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
  500. sband = wiphy->bands[band];
  501. if (!sband)
  502. continue;
  503. sband->band = band;
  504. if (WARN_ON(!sband->n_channels))
  505. return -EINVAL;
  506. /*
  507. * on 60gHz band, there are no legacy rates, so
  508. * n_bitrates is 0
  509. */
  510. if (WARN_ON(band != IEEE80211_BAND_60GHZ &&
  511. !sband->n_bitrates))
  512. return -EINVAL;
  513. /*
  514. * Since cfg80211_disable_40mhz_24ghz is global, we can
  515. * modify the sband's ht data even if the driver uses a
  516. * global structure for that.
  517. */
  518. if (cfg80211_disable_40mhz_24ghz &&
  519. band == IEEE80211_BAND_2GHZ &&
  520. sband->ht_cap.ht_supported) {
  521. sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
  522. sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
  523. }
  524. /*
  525. * Since we use a u32 for rate bitmaps in
  526. * ieee80211_get_response_rate, we cannot
  527. * have more than 32 legacy rates.
  528. */
  529. if (WARN_ON(sband->n_bitrates > 32))
  530. return -EINVAL;
  531. for (i = 0; i < sband->n_channels; i++) {
  532. sband->channels[i].orig_flags =
  533. sband->channels[i].flags;
  534. sband->channels[i].orig_mag = INT_MAX;
  535. sband->channels[i].orig_mpwr =
  536. sband->channels[i].max_power;
  537. sband->channels[i].band = band;
  538. }
  539. have_band = true;
  540. }
  541. if (!have_band) {
  542. WARN_ON(1);
  543. return -EINVAL;
  544. }
  545. #ifdef CONFIG_PM
  546. if (WARN_ON(rdev->wiphy.wowlan && rdev->wiphy.wowlan->n_patterns &&
  547. (!rdev->wiphy.wowlan->pattern_min_len ||
  548. rdev->wiphy.wowlan->pattern_min_len >
  549. rdev->wiphy.wowlan->pattern_max_len)))
  550. return -EINVAL;
  551. #endif
  552. /* check and set up bitrates */
  553. ieee80211_set_bitrate_flags(wiphy);
  554. rdev->wiphy.features |= NL80211_FEATURE_SCAN_FLUSH;
  555. rtnl_lock();
  556. res = device_add(&rdev->wiphy.dev);
  557. if (res) {
  558. rtnl_unlock();
  559. return res;
  560. }
  561. /* set up regulatory info */
  562. wiphy_regulatory_register(wiphy);
  563. list_add_rcu(&rdev->list, &cfg80211_rdev_list);
  564. cfg80211_rdev_list_generation++;
  565. /* add to debugfs */
  566. rdev->wiphy.debugfsdir =
  567. debugfs_create_dir(wiphy_name(&rdev->wiphy),
  568. ieee80211_debugfs_dir);
  569. if (IS_ERR(rdev->wiphy.debugfsdir))
  570. rdev->wiphy.debugfsdir = NULL;
  571. cfg80211_debugfs_rdev_add(rdev);
  572. nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
  573. if (wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) {
  574. struct regulatory_request request;
  575. request.wiphy_idx = get_wiphy_idx(wiphy);
  576. request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
  577. request.alpha2[0] = '9';
  578. request.alpha2[1] = '9';
  579. nl80211_send_reg_change_event(&request);
  580. }
  581. rdev->wiphy.registered = true;
  582. rtnl_unlock();
  583. res = rfkill_register(rdev->rfkill);
  584. if (res) {
  585. rfkill_destroy(rdev->rfkill);
  586. rdev->rfkill = NULL;
  587. wiphy_unregister(&rdev->wiphy);
  588. return res;
  589. }
  590. return 0;
  591. }
  592. EXPORT_SYMBOL(wiphy_register);
  593. void wiphy_rfkill_start_polling(struct wiphy *wiphy)
  594. {
  595. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  596. if (!rdev->ops->rfkill_poll)
  597. return;
  598. rdev->rfkill_ops.poll = cfg80211_rfkill_poll;
  599. rfkill_resume_polling(rdev->rfkill);
  600. }
  601. EXPORT_SYMBOL(wiphy_rfkill_start_polling);
  602. void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
  603. {
  604. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  605. rfkill_pause_polling(rdev->rfkill);
  606. }
  607. EXPORT_SYMBOL(wiphy_rfkill_stop_polling);
  608. void wiphy_unregister(struct wiphy *wiphy)
  609. {
  610. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  611. wait_event(rdev->dev_wait, ({
  612. int __count;
  613. rtnl_lock();
  614. __count = rdev->opencount;
  615. rtnl_unlock();
  616. __count == 0; }));
  617. if (rdev->rfkill)
  618. rfkill_unregister(rdev->rfkill);
  619. rtnl_lock();
  620. nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
  621. rdev->wiphy.registered = false;
  622. WARN_ON(!list_empty(&rdev->wdev_list));
  623. /*
  624. * First remove the hardware from everywhere, this makes
  625. * it impossible to find from userspace.
  626. */
  627. debugfs_remove_recursive(rdev->wiphy.debugfsdir);
  628. list_del_rcu(&rdev->list);
  629. synchronize_rcu();
  630. /*
  631. * If this device got a regulatory hint tell core its
  632. * free to listen now to a new shiny device regulatory hint
  633. */
  634. wiphy_regulatory_deregister(wiphy);
  635. cfg80211_rdev_list_generation++;
  636. device_del(&rdev->wiphy.dev);
  637. rtnl_unlock();
  638. flush_work(&rdev->scan_done_wk);
  639. cancel_work_sync(&rdev->conn_work);
  640. flush_work(&rdev->event_work);
  641. cancel_delayed_work_sync(&rdev->dfs_update_channels_wk);
  642. flush_work(&rdev->destroy_work);
  643. flush_work(&rdev->sched_scan_stop_wk);
  644. #ifdef CONFIG_PM
  645. if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup)
  646. rdev_set_wakeup(rdev, false);
  647. #endif
  648. cfg80211_rdev_free_wowlan(rdev);
  649. cfg80211_rdev_free_coalesce(rdev);
  650. }
  651. EXPORT_SYMBOL(wiphy_unregister);
  652. void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
  653. {
  654. struct cfg80211_internal_bss *scan, *tmp;
  655. struct cfg80211_beacon_registration *reg, *treg;
  656. rfkill_destroy(rdev->rfkill);
  657. list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
  658. list_del(&reg->list);
  659. kfree(reg);
  660. }
  661. list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
  662. cfg80211_put_bss(&rdev->wiphy, &scan->pub);
  663. kfree(rdev);
  664. }
  665. void wiphy_free(struct wiphy *wiphy)
  666. {
  667. put_device(&wiphy->dev);
  668. }
  669. EXPORT_SYMBOL(wiphy_free);
  670. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
  671. {
  672. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  673. if (rfkill_set_hw_state(rdev->rfkill, blocked))
  674. schedule_work(&rdev->rfkill_sync);
  675. }
  676. EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
  677. void cfg80211_unregister_wdev(struct wireless_dev *wdev)
  678. {
  679. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
  680. ASSERT_RTNL();
  681. if (WARN_ON(wdev->netdev))
  682. return;
  683. list_del_rcu(&wdev->list);
  684. rdev->devlist_generation++;
  685. switch (wdev->iftype) {
  686. case NL80211_IFTYPE_P2P_DEVICE:
  687. cfg80211_stop_p2p_device(rdev, wdev);
  688. break;
  689. default:
  690. WARN_ON_ONCE(1);
  691. break;
  692. }
  693. }
  694. EXPORT_SYMBOL(cfg80211_unregister_wdev);
  695. static const struct device_type wiphy_type = {
  696. .name = "wlan",
  697. };
  698. void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
  699. enum nl80211_iftype iftype, int num)
  700. {
  701. ASSERT_RTNL();
  702. rdev->num_running_ifaces += num;
  703. if (iftype == NL80211_IFTYPE_MONITOR)
  704. rdev->num_running_monitor_ifaces += num;
  705. }
  706. void __cfg80211_leave(struct cfg80211_registered_device *rdev,
  707. struct wireless_dev *wdev)
  708. {
  709. struct net_device *dev = wdev->netdev;
  710. struct cfg80211_sched_scan_request *sched_scan_req;
  711. ASSERT_RTNL();
  712. ASSERT_WDEV_LOCK(wdev);
  713. switch (wdev->iftype) {
  714. case NL80211_IFTYPE_ADHOC:
  715. __cfg80211_leave_ibss(rdev, dev, true);
  716. break;
  717. case NL80211_IFTYPE_P2P_CLIENT:
  718. case NL80211_IFTYPE_STATION:
  719. sched_scan_req = rtnl_dereference(rdev->sched_scan_req);
  720. if (sched_scan_req && dev == sched_scan_req->dev)
  721. __cfg80211_stop_sched_scan(rdev, false);
  722. #ifdef CONFIG_CFG80211_WEXT
  723. kfree(wdev->wext.ie);
  724. wdev->wext.ie = NULL;
  725. wdev->wext.ie_len = 0;
  726. wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
  727. #endif
  728. cfg80211_disconnect(rdev, dev,
  729. WLAN_REASON_DEAUTH_LEAVING, true);
  730. break;
  731. case NL80211_IFTYPE_MESH_POINT:
  732. __cfg80211_leave_mesh(rdev, dev);
  733. break;
  734. case NL80211_IFTYPE_AP:
  735. case NL80211_IFTYPE_P2P_GO:
  736. __cfg80211_stop_ap(rdev, dev, true);
  737. break;
  738. case NL80211_IFTYPE_OCB:
  739. __cfg80211_leave_ocb(rdev, dev);
  740. break;
  741. case NL80211_IFTYPE_WDS:
  742. /* must be handled by mac80211/driver, has no APIs */
  743. break;
  744. case NL80211_IFTYPE_P2P_DEVICE:
  745. /* cannot happen, has no netdev */
  746. break;
  747. case NL80211_IFTYPE_AP_VLAN:
  748. case NL80211_IFTYPE_MONITOR:
  749. /* nothing to do */
  750. break;
  751. case NL80211_IFTYPE_UNSPECIFIED:
  752. case NUM_NL80211_IFTYPES:
  753. /* invalid */
  754. break;
  755. }
  756. }
  757. void cfg80211_leave(struct cfg80211_registered_device *rdev,
  758. struct wireless_dev *wdev)
  759. {
  760. wdev_lock(wdev);
  761. __cfg80211_leave(rdev, wdev);
  762. wdev_unlock(wdev);
  763. }
  764. void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
  765. gfp_t gfp)
  766. {
  767. struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
  768. struct cfg80211_event *ev;
  769. unsigned long flags;
  770. trace_cfg80211_stop_iface(wiphy, wdev);
  771. ev = kzalloc(sizeof(*ev), gfp);
  772. if (!ev)
  773. return;
  774. ev->type = EVENT_STOPPED;
  775. spin_lock_irqsave(&wdev->event_lock, flags);
  776. list_add_tail(&ev->list, &wdev->event_list);
  777. spin_unlock_irqrestore(&wdev->event_lock, flags);
  778. queue_work(cfg80211_wq, &rdev->event_work);
  779. }
  780. EXPORT_SYMBOL(cfg80211_stop_iface);
  781. static const struct rtnl_link_ops wireless_link_ops = {
  782. .kind = "wlan",
  783. };
  784. static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
  785. unsigned long state, void *ptr)
  786. {
  787. struct net_device *dev = netdev_notifier_info_to_dev(ptr);
  788. struct wireless_dev *wdev = dev->ieee80211_ptr;
  789. struct cfg80211_registered_device *rdev;
  790. struct cfg80211_sched_scan_request *sched_scan_req;
  791. if (!wdev)
  792. return NOTIFY_DONE;
  793. rdev = wiphy_to_rdev(wdev->wiphy);
  794. WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
  795. switch (state) {
  796. case NETDEV_POST_INIT:
  797. SET_NETDEV_DEVTYPE(dev, &wiphy_type);
  798. dev->rtnl_link_ops = &wireless_link_ops;
  799. break;
  800. case NETDEV_REGISTER:
  801. /*
  802. * NB: cannot take rdev->mtx here because this may be
  803. * called within code protected by it when interfaces
  804. * are added with nl80211.
  805. */
  806. mutex_init(&wdev->mtx);
  807. INIT_LIST_HEAD(&wdev->event_list);
  808. spin_lock_init(&wdev->event_lock);
  809. INIT_LIST_HEAD(&wdev->mgmt_registrations);
  810. spin_lock_init(&wdev->mgmt_registrations_lock);
  811. wdev->identifier = ++rdev->wdev_id;
  812. list_add_rcu(&wdev->list, &rdev->wdev_list);
  813. rdev->devlist_generation++;
  814. /* can only change netns with wiphy */
  815. dev->features |= NETIF_F_NETNS_LOCAL;
  816. if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
  817. "phy80211")) {
  818. pr_err("failed to add phy80211 symlink to netdev!\n");
  819. }
  820. wdev->netdev = dev;
  821. #ifdef CONFIG_CFG80211_WEXT
  822. wdev->wext.default_key = -1;
  823. wdev->wext.default_mgmt_key = -1;
  824. wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
  825. #endif
  826. if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
  827. wdev->ps = true;
  828. else
  829. wdev->ps = false;
  830. /* allow mac80211 to determine the timeout */
  831. wdev->ps_timeout = -1;
  832. if ((wdev->iftype == NL80211_IFTYPE_STATION ||
  833. wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
  834. wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
  835. dev->priv_flags |= IFF_DONT_BRIDGE;
  836. break;
  837. case NETDEV_GOING_DOWN:
  838. cfg80211_leave(rdev, wdev);
  839. break;
  840. case NETDEV_DOWN:
  841. cfg80211_update_iface_num(rdev, wdev->iftype, -1);
  842. if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
  843. if (WARN_ON(!rdev->scan_req->notified))
  844. rdev->scan_req->aborted = true;
  845. ___cfg80211_scan_done(rdev, false);
  846. }
  847. sched_scan_req = rtnl_dereference(rdev->sched_scan_req);
  848. if (WARN_ON(sched_scan_req &&
  849. sched_scan_req->dev == wdev->netdev)) {
  850. __cfg80211_stop_sched_scan(rdev, false);
  851. }
  852. rdev->opencount--;
  853. wake_up(&rdev->dev_wait);
  854. break;
  855. case NETDEV_UP:
  856. cfg80211_update_iface_num(rdev, wdev->iftype, 1);
  857. wdev_lock(wdev);
  858. switch (wdev->iftype) {
  859. #ifdef CONFIG_CFG80211_WEXT
  860. case NL80211_IFTYPE_ADHOC:
  861. cfg80211_ibss_wext_join(rdev, wdev);
  862. break;
  863. case NL80211_IFTYPE_STATION:
  864. cfg80211_mgd_wext_connect(rdev, wdev);
  865. break;
  866. #endif
  867. #ifdef CONFIG_MAC80211_MESH
  868. case NL80211_IFTYPE_MESH_POINT:
  869. {
  870. /* backward compat code... */
  871. struct mesh_setup setup;
  872. memcpy(&setup, &default_mesh_setup,
  873. sizeof(setup));
  874. /* back compat only needed for mesh_id */
  875. setup.mesh_id = wdev->ssid;
  876. setup.mesh_id_len = wdev->mesh_id_up_len;
  877. if (wdev->mesh_id_up_len)
  878. __cfg80211_join_mesh(rdev, dev,
  879. &setup,
  880. &default_mesh_config);
  881. break;
  882. }
  883. #endif
  884. default:
  885. break;
  886. }
  887. wdev_unlock(wdev);
  888. rdev->opencount++;
  889. /*
  890. * Configure power management to the driver here so that its
  891. * correctly set also after interface type changes etc.
  892. */
  893. if ((wdev->iftype == NL80211_IFTYPE_STATION ||
  894. wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
  895. rdev->ops->set_power_mgmt)
  896. if (rdev_set_power_mgmt(rdev, dev, wdev->ps,
  897. wdev->ps_timeout)) {
  898. /* assume this means it's off */
  899. wdev->ps = false;
  900. }
  901. break;
  902. case NETDEV_UNREGISTER:
  903. /*
  904. * It is possible to get NETDEV_UNREGISTER
  905. * multiple times. To detect that, check
  906. * that the interface is still on the list
  907. * of registered interfaces, and only then
  908. * remove and clean it up.
  909. */
  910. if (!list_empty(&wdev->list)) {
  911. sysfs_remove_link(&dev->dev.kobj, "phy80211");
  912. list_del_rcu(&wdev->list);
  913. rdev->devlist_generation++;
  914. cfg80211_mlme_purge_registrations(wdev);
  915. #ifdef CONFIG_CFG80211_WEXT
  916. kzfree(wdev->wext.keys);
  917. #endif
  918. }
  919. /*
  920. * synchronise (so that we won't find this netdev
  921. * from other code any more) and then clear the list
  922. * head so that the above code can safely check for
  923. * !list_empty() to avoid double-cleanup.
  924. */
  925. synchronize_rcu();
  926. INIT_LIST_HEAD(&wdev->list);
  927. /*
  928. * Ensure that all events have been processed and
  929. * freed.
  930. */
  931. cfg80211_process_wdev_events(wdev);
  932. if (WARN_ON(wdev->current_bss)) {
  933. cfg80211_unhold_bss(wdev->current_bss);
  934. cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
  935. wdev->current_bss = NULL;
  936. }
  937. break;
  938. case NETDEV_PRE_UP:
  939. if (!(wdev->wiphy->interface_modes & BIT(wdev->iftype)))
  940. return notifier_from_errno(-EOPNOTSUPP);
  941. if (rfkill_blocked(rdev->rfkill))
  942. return notifier_from_errno(-ERFKILL);
  943. break;
  944. default:
  945. return NOTIFY_DONE;
  946. }
  947. return NOTIFY_OK;
  948. }
  949. static struct notifier_block cfg80211_netdev_notifier = {
  950. .notifier_call = cfg80211_netdev_notifier_call,
  951. };
  952. static void __net_exit cfg80211_pernet_exit(struct net *net)
  953. {
  954. struct cfg80211_registered_device *rdev;
  955. rtnl_lock();
  956. list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
  957. if (net_eq(wiphy_net(&rdev->wiphy), net))
  958. WARN_ON(cfg80211_switch_netns(rdev, &init_net));
  959. }
  960. rtnl_unlock();
  961. }
  962. static struct pernet_operations cfg80211_pernet_ops = {
  963. .exit = cfg80211_pernet_exit,
  964. };
  965. static int __init cfg80211_init(void)
  966. {
  967. int err;
  968. err = register_pernet_device(&cfg80211_pernet_ops);
  969. if (err)
  970. goto out_fail_pernet;
  971. err = wiphy_sysfs_init();
  972. if (err)
  973. goto out_fail_sysfs;
  974. err = register_netdevice_notifier(&cfg80211_netdev_notifier);
  975. if (err)
  976. goto out_fail_notifier;
  977. err = nl80211_init();
  978. if (err)
  979. goto out_fail_nl80211;
  980. ieee80211_debugfs_dir = debugfs_create_dir("ieee80211", NULL);
  981. err = regulatory_init();
  982. if (err)
  983. goto out_fail_reg;
  984. cfg80211_wq = create_singlethread_workqueue("cfg80211");
  985. if (!cfg80211_wq) {
  986. err = -ENOMEM;
  987. goto out_fail_wq;
  988. }
  989. return 0;
  990. out_fail_wq:
  991. regulatory_exit();
  992. out_fail_reg:
  993. debugfs_remove(ieee80211_debugfs_dir);
  994. out_fail_nl80211:
  995. unregister_netdevice_notifier(&cfg80211_netdev_notifier);
  996. out_fail_notifier:
  997. wiphy_sysfs_exit();
  998. out_fail_sysfs:
  999. unregister_pernet_device(&cfg80211_pernet_ops);
  1000. out_fail_pernet:
  1001. return err;
  1002. }
  1003. subsys_initcall(cfg80211_init);
  1004. static void __exit cfg80211_exit(void)
  1005. {
  1006. debugfs_remove(ieee80211_debugfs_dir);
  1007. nl80211_exit();
  1008. unregister_netdevice_notifier(&cfg80211_netdev_notifier);
  1009. wiphy_sysfs_exit();
  1010. regulatory_exit();
  1011. unregister_pernet_device(&cfg80211_pernet_ops);
  1012. destroy_workqueue(cfg80211_wq);
  1013. }
  1014. module_exit(cfg80211_exit);