iface.c 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785
  1. /*
  2. * Interface handling
  3. *
  4. * Copyright 2002-2005, Instant802 Networks, Inc.
  5. * Copyright 2005-2006, Devicescape Software, Inc.
  6. * Copyright (c) 2006 Jiri Benc <jbenc@suse.cz>
  7. * Copyright 2008, Johannes Berg <johannes@sipsolutions.net>
  8. *
  9. * This program is free software; you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License version 2 as
  11. * published by the Free Software Foundation.
  12. */
  13. #include <linux/slab.h>
  14. #include <linux/kernel.h>
  15. #include <linux/if_arp.h>
  16. #include <linux/netdevice.h>
  17. #include <linux/rtnetlink.h>
  18. #include <net/mac80211.h>
  19. #include <net/ieee80211_radiotap.h>
  20. #include "ieee80211_i.h"
  21. #include "sta_info.h"
  22. #include "debugfs_netdev.h"
  23. #include "mesh.h"
  24. #include "led.h"
  25. #include "driver-ops.h"
  26. #include "wme.h"
  27. #include "rate.h"
  28. /**
  29. * DOC: Interface list locking
  30. *
  31. * The interface list in each struct ieee80211_local is protected
  32. * three-fold:
  33. *
  34. * (1) modifications may only be done under the RTNL
  35. * (2) modifications and readers are protected against each other by
  36. * the iflist_mtx.
  37. * (3) modifications are done in an RCU manner so atomic readers
  38. * can traverse the list in RCU-safe blocks.
  39. *
  40. * As a consequence, reads (traversals) of the list can be protected
  41. * by either the RTNL, the iflist_mtx or RCU.
  42. */
  43. bool __ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
  44. {
  45. struct ieee80211_chanctx_conf *chanctx_conf;
  46. int power;
  47. rcu_read_lock();
  48. chanctx_conf = rcu_dereference(sdata->vif.chanctx_conf);
  49. if (!chanctx_conf) {
  50. rcu_read_unlock();
  51. return false;
  52. }
  53. power = chanctx_conf->def.chan->max_power;
  54. rcu_read_unlock();
  55. if (sdata->user_power_level != IEEE80211_UNSET_POWER_LEVEL)
  56. power = min(power, sdata->user_power_level);
  57. if (sdata->ap_power_level != IEEE80211_UNSET_POWER_LEVEL)
  58. power = min(power, sdata->ap_power_level);
  59. if (power != sdata->vif.bss_conf.txpower) {
  60. sdata->vif.bss_conf.txpower = power;
  61. ieee80211_hw_config(sdata->local, 0);
  62. return true;
  63. }
  64. return false;
  65. }
  66. void ieee80211_recalc_txpower(struct ieee80211_sub_if_data *sdata)
  67. {
  68. if (__ieee80211_recalc_txpower(sdata))
  69. ieee80211_bss_info_change_notify(sdata, BSS_CHANGED_TXPOWER);
  70. }
  71. static u32 __ieee80211_idle_off(struct ieee80211_local *local)
  72. {
  73. if (!(local->hw.conf.flags & IEEE80211_CONF_IDLE))
  74. return 0;
  75. local->hw.conf.flags &= ~IEEE80211_CONF_IDLE;
  76. return IEEE80211_CONF_CHANGE_IDLE;
  77. }
  78. static u32 __ieee80211_idle_on(struct ieee80211_local *local)
  79. {
  80. if (local->hw.conf.flags & IEEE80211_CONF_IDLE)
  81. return 0;
  82. ieee80211_flush_queues(local, NULL);
  83. local->hw.conf.flags |= IEEE80211_CONF_IDLE;
  84. return IEEE80211_CONF_CHANGE_IDLE;
  85. }
  86. static u32 __ieee80211_recalc_idle(struct ieee80211_local *local,
  87. bool force_active)
  88. {
  89. bool working = false, scanning, active;
  90. unsigned int led_trig_start = 0, led_trig_stop = 0;
  91. struct ieee80211_roc_work *roc;
  92. lockdep_assert_held(&local->mtx);
  93. active = force_active ||
  94. !list_empty(&local->chanctx_list) ||
  95. local->monitors;
  96. if (!local->ops->remain_on_channel) {
  97. list_for_each_entry(roc, &local->roc_list, list) {
  98. working = true;
  99. break;
  100. }
  101. }
  102. scanning = test_bit(SCAN_SW_SCANNING, &local->scanning) ||
  103. test_bit(SCAN_ONCHANNEL_SCANNING, &local->scanning);
  104. if (working || scanning)
  105. led_trig_start |= IEEE80211_TPT_LEDTRIG_FL_WORK;
  106. else
  107. led_trig_stop |= IEEE80211_TPT_LEDTRIG_FL_WORK;
  108. if (active)
  109. led_trig_start |= IEEE80211_TPT_LEDTRIG_FL_CONNECTED;
  110. else
  111. led_trig_stop |= IEEE80211_TPT_LEDTRIG_FL_CONNECTED;
  112. ieee80211_mod_tpt_led_trig(local, led_trig_start, led_trig_stop);
  113. if (working || scanning || active)
  114. return __ieee80211_idle_off(local);
  115. return __ieee80211_idle_on(local);
  116. }
  117. u32 ieee80211_idle_off(struct ieee80211_local *local)
  118. {
  119. return __ieee80211_recalc_idle(local, true);
  120. }
  121. void ieee80211_recalc_idle(struct ieee80211_local *local)
  122. {
  123. u32 change = __ieee80211_recalc_idle(local, false);
  124. if (change)
  125. ieee80211_hw_config(local, change);
  126. }
  127. static int ieee80211_change_mtu(struct net_device *dev, int new_mtu)
  128. {
  129. if (new_mtu < 256 || new_mtu > IEEE80211_MAX_DATA_LEN)
  130. return -EINVAL;
  131. dev->mtu = new_mtu;
  132. return 0;
  133. }
  134. static int ieee80211_verify_mac(struct ieee80211_sub_if_data *sdata, u8 *addr)
  135. {
  136. struct ieee80211_local *local = sdata->local;
  137. struct ieee80211_sub_if_data *iter;
  138. u64 new, mask, tmp;
  139. u8 *m;
  140. int ret = 0;
  141. if (is_zero_ether_addr(local->hw.wiphy->addr_mask))
  142. return 0;
  143. m = addr;
  144. new = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
  145. ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
  146. ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
  147. m = local->hw.wiphy->addr_mask;
  148. mask = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
  149. ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
  150. ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
  151. mutex_lock(&local->iflist_mtx);
  152. list_for_each_entry(iter, &local->interfaces, list) {
  153. if (iter == sdata)
  154. continue;
  155. if (iter->vif.type == NL80211_IFTYPE_MONITOR)
  156. continue;
  157. m = iter->vif.addr;
  158. tmp = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
  159. ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
  160. ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
  161. if ((new & ~mask) != (tmp & ~mask)) {
  162. ret = -EINVAL;
  163. break;
  164. }
  165. }
  166. mutex_unlock(&local->iflist_mtx);
  167. return ret;
  168. }
  169. static int ieee80211_change_mac(struct net_device *dev, void *addr)
  170. {
  171. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  172. struct sockaddr *sa = addr;
  173. int ret;
  174. if (ieee80211_sdata_running(sdata))
  175. return -EBUSY;
  176. ret = ieee80211_verify_mac(sdata, sa->sa_data);
  177. if (ret)
  178. return ret;
  179. ret = eth_mac_addr(dev, sa);
  180. if (ret == 0)
  181. memcpy(sdata->vif.addr, sa->sa_data, ETH_ALEN);
  182. return ret;
  183. }
  184. static inline int identical_mac_addr_allowed(int type1, int type2)
  185. {
  186. return type1 == NL80211_IFTYPE_MONITOR ||
  187. type2 == NL80211_IFTYPE_MONITOR ||
  188. type1 == NL80211_IFTYPE_P2P_DEVICE ||
  189. type2 == NL80211_IFTYPE_P2P_DEVICE ||
  190. (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_WDS) ||
  191. (type1 == NL80211_IFTYPE_WDS &&
  192. (type2 == NL80211_IFTYPE_WDS ||
  193. type2 == NL80211_IFTYPE_AP)) ||
  194. (type1 == NL80211_IFTYPE_AP && type2 == NL80211_IFTYPE_AP_VLAN) ||
  195. (type1 == NL80211_IFTYPE_AP_VLAN &&
  196. (type2 == NL80211_IFTYPE_AP ||
  197. type2 == NL80211_IFTYPE_AP_VLAN));
  198. }
  199. static int ieee80211_check_concurrent_iface(struct ieee80211_sub_if_data *sdata,
  200. enum nl80211_iftype iftype)
  201. {
  202. struct ieee80211_local *local = sdata->local;
  203. struct ieee80211_sub_if_data *nsdata;
  204. ASSERT_RTNL();
  205. /* we hold the RTNL here so can safely walk the list */
  206. list_for_each_entry(nsdata, &local->interfaces, list) {
  207. if (nsdata != sdata && ieee80211_sdata_running(nsdata)) {
  208. /*
  209. * Allow only a single IBSS interface to be up at any
  210. * time. This is restricted because beacon distribution
  211. * cannot work properly if both are in the same IBSS.
  212. *
  213. * To remove this restriction we'd have to disallow them
  214. * from setting the same SSID on different IBSS interfaces
  215. * belonging to the same hardware. Then, however, we're
  216. * faced with having to adopt two different TSF timers...
  217. */
  218. if (iftype == NL80211_IFTYPE_ADHOC &&
  219. nsdata->vif.type == NL80211_IFTYPE_ADHOC)
  220. return -EBUSY;
  221. /*
  222. * The remaining checks are only performed for interfaces
  223. * with the same MAC address.
  224. */
  225. if (!ether_addr_equal(sdata->vif.addr,
  226. nsdata->vif.addr))
  227. continue;
  228. /*
  229. * check whether it may have the same address
  230. */
  231. if (!identical_mac_addr_allowed(iftype,
  232. nsdata->vif.type))
  233. return -ENOTUNIQ;
  234. /*
  235. * can only add VLANs to enabled APs
  236. */
  237. if (iftype == NL80211_IFTYPE_AP_VLAN &&
  238. nsdata->vif.type == NL80211_IFTYPE_AP)
  239. sdata->bss = &nsdata->u.ap;
  240. }
  241. }
  242. return 0;
  243. }
  244. static int ieee80211_check_queues(struct ieee80211_sub_if_data *sdata)
  245. {
  246. int n_queues = sdata->local->hw.queues;
  247. int i;
  248. if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE) {
  249. for (i = 0; i < IEEE80211_NUM_ACS; i++) {
  250. if (WARN_ON_ONCE(sdata->vif.hw_queue[i] ==
  251. IEEE80211_INVAL_HW_QUEUE))
  252. return -EINVAL;
  253. if (WARN_ON_ONCE(sdata->vif.hw_queue[i] >=
  254. n_queues))
  255. return -EINVAL;
  256. }
  257. }
  258. if ((sdata->vif.type != NL80211_IFTYPE_AP &&
  259. sdata->vif.type != NL80211_IFTYPE_MESH_POINT) ||
  260. !(sdata->local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)) {
  261. sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE;
  262. return 0;
  263. }
  264. if (WARN_ON_ONCE(sdata->vif.cab_queue == IEEE80211_INVAL_HW_QUEUE))
  265. return -EINVAL;
  266. if (WARN_ON_ONCE(sdata->vif.cab_queue >= n_queues))
  267. return -EINVAL;
  268. return 0;
  269. }
  270. void ieee80211_adjust_monitor_flags(struct ieee80211_sub_if_data *sdata,
  271. const int offset)
  272. {
  273. struct ieee80211_local *local = sdata->local;
  274. u32 flags = sdata->u.mntr_flags;
  275. #define ADJUST(_f, _s) do { \
  276. if (flags & MONITOR_FLAG_##_f) \
  277. local->fif_##_s += offset; \
  278. } while (0)
  279. ADJUST(FCSFAIL, fcsfail);
  280. ADJUST(PLCPFAIL, plcpfail);
  281. ADJUST(CONTROL, control);
  282. ADJUST(CONTROL, pspoll);
  283. ADJUST(OTHER_BSS, other_bss);
  284. #undef ADJUST
  285. }
  286. static void ieee80211_set_default_queues(struct ieee80211_sub_if_data *sdata)
  287. {
  288. struct ieee80211_local *local = sdata->local;
  289. int i;
  290. for (i = 0; i < IEEE80211_NUM_ACS; i++) {
  291. if (local->hw.flags & IEEE80211_HW_QUEUE_CONTROL)
  292. sdata->vif.hw_queue[i] = IEEE80211_INVAL_HW_QUEUE;
  293. else if (local->hw.queues >= IEEE80211_NUM_ACS)
  294. sdata->vif.hw_queue[i] = i;
  295. else
  296. sdata->vif.hw_queue[i] = 0;
  297. }
  298. sdata->vif.cab_queue = IEEE80211_INVAL_HW_QUEUE;
  299. }
  300. int ieee80211_add_virtual_monitor(struct ieee80211_local *local)
  301. {
  302. struct ieee80211_sub_if_data *sdata;
  303. int ret;
  304. if (!(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF))
  305. return 0;
  306. ASSERT_RTNL();
  307. if (local->monitor_sdata)
  308. return 0;
  309. sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size, GFP_KERNEL);
  310. if (!sdata)
  311. return -ENOMEM;
  312. /* set up data */
  313. sdata->local = local;
  314. sdata->vif.type = NL80211_IFTYPE_MONITOR;
  315. snprintf(sdata->name, IFNAMSIZ, "%s-monitor",
  316. wiphy_name(local->hw.wiphy));
  317. ieee80211_set_default_queues(sdata);
  318. ret = drv_add_interface(local, sdata);
  319. if (WARN_ON(ret)) {
  320. /* ok .. stupid driver, it asked for this! */
  321. kfree(sdata);
  322. return ret;
  323. }
  324. ret = ieee80211_check_queues(sdata);
  325. if (ret) {
  326. kfree(sdata);
  327. return ret;
  328. }
  329. ret = ieee80211_vif_use_channel(sdata, &local->monitor_chandef,
  330. IEEE80211_CHANCTX_EXCLUSIVE);
  331. if (ret) {
  332. drv_remove_interface(local, sdata);
  333. kfree(sdata);
  334. return ret;
  335. }
  336. mutex_lock(&local->iflist_mtx);
  337. rcu_assign_pointer(local->monitor_sdata, sdata);
  338. mutex_unlock(&local->iflist_mtx);
  339. return 0;
  340. }
  341. void ieee80211_del_virtual_monitor(struct ieee80211_local *local)
  342. {
  343. struct ieee80211_sub_if_data *sdata;
  344. if (!(local->hw.flags & IEEE80211_HW_WANT_MONITOR_VIF))
  345. return;
  346. ASSERT_RTNL();
  347. mutex_lock(&local->iflist_mtx);
  348. sdata = rcu_dereference_protected(local->monitor_sdata,
  349. lockdep_is_held(&local->iflist_mtx));
  350. if (!sdata) {
  351. mutex_unlock(&local->iflist_mtx);
  352. return;
  353. }
  354. rcu_assign_pointer(local->monitor_sdata, NULL);
  355. mutex_unlock(&local->iflist_mtx);
  356. synchronize_net();
  357. ieee80211_vif_release_channel(sdata);
  358. drv_remove_interface(local, sdata);
  359. kfree(sdata);
  360. }
  361. /*
  362. * NOTE: Be very careful when changing this function, it must NOT return
  363. * an error on interface type changes that have been pre-checked, so most
  364. * checks should be in ieee80211_check_concurrent_iface.
  365. */
  366. int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
  367. {
  368. struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev);
  369. struct net_device *dev = wdev->netdev;
  370. struct ieee80211_local *local = sdata->local;
  371. struct sta_info *sta;
  372. u32 changed = 0;
  373. int res;
  374. u32 hw_reconf_flags = 0;
  375. switch (sdata->vif.type) {
  376. case NL80211_IFTYPE_WDS:
  377. if (!is_valid_ether_addr(sdata->u.wds.remote_addr))
  378. return -ENOLINK;
  379. break;
  380. case NL80211_IFTYPE_AP_VLAN: {
  381. struct ieee80211_sub_if_data *master;
  382. if (!sdata->bss)
  383. return -ENOLINK;
  384. list_add(&sdata->u.vlan.list, &sdata->bss->vlans);
  385. master = container_of(sdata->bss,
  386. struct ieee80211_sub_if_data, u.ap);
  387. sdata->control_port_protocol =
  388. master->control_port_protocol;
  389. sdata->control_port_no_encrypt =
  390. master->control_port_no_encrypt;
  391. sdata->vif.cab_queue = master->vif.cab_queue;
  392. memcpy(sdata->vif.hw_queue, master->vif.hw_queue,
  393. sizeof(sdata->vif.hw_queue));
  394. break;
  395. }
  396. case NL80211_IFTYPE_AP:
  397. sdata->bss = &sdata->u.ap;
  398. break;
  399. case NL80211_IFTYPE_MESH_POINT:
  400. case NL80211_IFTYPE_STATION:
  401. case NL80211_IFTYPE_MONITOR:
  402. case NL80211_IFTYPE_ADHOC:
  403. case NL80211_IFTYPE_P2P_DEVICE:
  404. /* no special treatment */
  405. break;
  406. case NL80211_IFTYPE_UNSPECIFIED:
  407. case NUM_NL80211_IFTYPES:
  408. case NL80211_IFTYPE_P2P_CLIENT:
  409. case NL80211_IFTYPE_P2P_GO:
  410. /* cannot happen */
  411. WARN_ON(1);
  412. break;
  413. }
  414. if (local->open_count == 0) {
  415. res = drv_start(local);
  416. if (res)
  417. goto err_del_bss;
  418. /* we're brought up, everything changes */
  419. hw_reconf_flags = ~0;
  420. ieee80211_led_radio(local, true);
  421. ieee80211_mod_tpt_led_trig(local,
  422. IEEE80211_TPT_LEDTRIG_FL_RADIO, 0);
  423. }
  424. /*
  425. * Copy the hopefully now-present MAC address to
  426. * this interface, if it has the special null one.
  427. */
  428. if (dev && is_zero_ether_addr(dev->dev_addr)) {
  429. memcpy(dev->dev_addr,
  430. local->hw.wiphy->perm_addr,
  431. ETH_ALEN);
  432. memcpy(dev->perm_addr, dev->dev_addr, ETH_ALEN);
  433. if (!is_valid_ether_addr(dev->dev_addr)) {
  434. res = -EADDRNOTAVAIL;
  435. goto err_stop;
  436. }
  437. }
  438. switch (sdata->vif.type) {
  439. case NL80211_IFTYPE_AP_VLAN:
  440. /* no need to tell driver, but set carrier and chanctx */
  441. if (rtnl_dereference(sdata->bss->beacon)) {
  442. ieee80211_vif_vlan_copy_chanctx(sdata);
  443. netif_carrier_on(dev);
  444. } else {
  445. netif_carrier_off(dev);
  446. }
  447. break;
  448. case NL80211_IFTYPE_MONITOR:
  449. if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
  450. local->cooked_mntrs++;
  451. break;
  452. }
  453. if (local->monitors == 0 && local->open_count == 0) {
  454. res = ieee80211_add_virtual_monitor(local);
  455. if (res)
  456. goto err_stop;
  457. }
  458. /* must be before the call to ieee80211_configure_filter */
  459. local->monitors++;
  460. if (local->monitors == 1) {
  461. local->hw.conf.flags |= IEEE80211_CONF_MONITOR;
  462. hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
  463. }
  464. ieee80211_adjust_monitor_flags(sdata, 1);
  465. ieee80211_configure_filter(local);
  466. mutex_lock(&local->mtx);
  467. ieee80211_recalc_idle(local);
  468. mutex_unlock(&local->mtx);
  469. netif_carrier_on(dev);
  470. break;
  471. default:
  472. if (coming_up) {
  473. ieee80211_del_virtual_monitor(local);
  474. res = drv_add_interface(local, sdata);
  475. if (res)
  476. goto err_stop;
  477. res = ieee80211_check_queues(sdata);
  478. if (res)
  479. goto err_del_interface;
  480. }
  481. if (sdata->vif.type == NL80211_IFTYPE_AP) {
  482. local->fif_pspoll++;
  483. local->fif_probe_req++;
  484. ieee80211_configure_filter(local);
  485. } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
  486. local->fif_probe_req++;
  487. }
  488. if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
  489. changed |= ieee80211_reset_erp_info(sdata);
  490. ieee80211_bss_info_change_notify(sdata, changed);
  491. switch (sdata->vif.type) {
  492. case NL80211_IFTYPE_STATION:
  493. case NL80211_IFTYPE_ADHOC:
  494. case NL80211_IFTYPE_AP:
  495. case NL80211_IFTYPE_MESH_POINT:
  496. netif_carrier_off(dev);
  497. break;
  498. case NL80211_IFTYPE_WDS:
  499. case NL80211_IFTYPE_P2P_DEVICE:
  500. break;
  501. default:
  502. /* not reached */
  503. WARN_ON(1);
  504. }
  505. /*
  506. * set default queue parameters so drivers don't
  507. * need to initialise the hardware if the hardware
  508. * doesn't start up with sane defaults
  509. */
  510. ieee80211_set_wmm_default(sdata, true);
  511. }
  512. set_bit(SDATA_STATE_RUNNING, &sdata->state);
  513. if (sdata->vif.type == NL80211_IFTYPE_WDS) {
  514. /* Create STA entry for the WDS peer */
  515. sta = sta_info_alloc(sdata, sdata->u.wds.remote_addr,
  516. GFP_KERNEL);
  517. if (!sta) {
  518. res = -ENOMEM;
  519. goto err_del_interface;
  520. }
  521. sta_info_pre_move_state(sta, IEEE80211_STA_AUTH);
  522. sta_info_pre_move_state(sta, IEEE80211_STA_ASSOC);
  523. sta_info_pre_move_state(sta, IEEE80211_STA_AUTHORIZED);
  524. res = sta_info_insert(sta);
  525. if (res) {
  526. /* STA has been freed */
  527. goto err_del_interface;
  528. }
  529. rate_control_rate_init(sta);
  530. netif_carrier_on(dev);
  531. } else if (sdata->vif.type == NL80211_IFTYPE_P2P_DEVICE) {
  532. rcu_assign_pointer(local->p2p_sdata, sdata);
  533. }
  534. /*
  535. * set_multicast_list will be invoked by the networking core
  536. * which will check whether any increments here were done in
  537. * error and sync them down to the hardware as filter flags.
  538. */
  539. if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
  540. atomic_inc(&local->iff_allmultis);
  541. if (sdata->flags & IEEE80211_SDATA_PROMISC)
  542. atomic_inc(&local->iff_promiscs);
  543. if (coming_up)
  544. local->open_count++;
  545. if (hw_reconf_flags)
  546. ieee80211_hw_config(local, hw_reconf_flags);
  547. ieee80211_recalc_ps(local, -1);
  548. if (sdata->vif.type == NL80211_IFTYPE_MONITOR ||
  549. sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  550. /* XXX: for AP_VLAN, actually track AP queues */
  551. netif_tx_start_all_queues(dev);
  552. } else if (dev) {
  553. unsigned long flags;
  554. int n_acs = IEEE80211_NUM_ACS;
  555. int ac;
  556. if (local->hw.queues < IEEE80211_NUM_ACS)
  557. n_acs = 1;
  558. spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  559. if (sdata->vif.cab_queue == IEEE80211_INVAL_HW_QUEUE ||
  560. (local->queue_stop_reasons[sdata->vif.cab_queue] == 0 &&
  561. skb_queue_empty(&local->pending[sdata->vif.cab_queue]))) {
  562. for (ac = 0; ac < n_acs; ac++) {
  563. int ac_queue = sdata->vif.hw_queue[ac];
  564. if (local->queue_stop_reasons[ac_queue] == 0 &&
  565. skb_queue_empty(&local->pending[ac_queue]))
  566. netif_start_subqueue(dev, ac);
  567. }
  568. }
  569. spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
  570. }
  571. return 0;
  572. err_del_interface:
  573. drv_remove_interface(local, sdata);
  574. err_stop:
  575. if (!local->open_count)
  576. drv_stop(local);
  577. err_del_bss:
  578. sdata->bss = NULL;
  579. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  580. list_del(&sdata->u.vlan.list);
  581. /* might already be clear but that doesn't matter */
  582. clear_bit(SDATA_STATE_RUNNING, &sdata->state);
  583. return res;
  584. }
  585. static int ieee80211_open(struct net_device *dev)
  586. {
  587. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  588. int err;
  589. /* fail early if user set an invalid address */
  590. if (!is_valid_ether_addr(dev->dev_addr))
  591. return -EADDRNOTAVAIL;
  592. err = ieee80211_check_concurrent_iface(sdata, sdata->vif.type);
  593. if (err)
  594. return err;
  595. return ieee80211_do_open(&sdata->wdev, true);
  596. }
  597. static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
  598. bool going_down)
  599. {
  600. struct ieee80211_local *local = sdata->local;
  601. unsigned long flags;
  602. struct sk_buff *skb, *tmp;
  603. u32 hw_reconf_flags = 0;
  604. int i, flushed;
  605. struct ps_data *ps;
  606. clear_bit(SDATA_STATE_RUNNING, &sdata->state);
  607. if (rcu_access_pointer(local->scan_sdata) == sdata)
  608. ieee80211_scan_cancel(local);
  609. /*
  610. * Stop TX on this interface first.
  611. */
  612. if (sdata->dev)
  613. netif_tx_stop_all_queues(sdata->dev);
  614. ieee80211_roc_purge(local, sdata);
  615. if (sdata->vif.type == NL80211_IFTYPE_STATION)
  616. ieee80211_mgd_stop(sdata);
  617. /*
  618. * Remove all stations associated with this interface.
  619. *
  620. * This must be done before calling ops->remove_interface()
  621. * because otherwise we can later invoke ops->sta_notify()
  622. * whenever the STAs are removed, and that invalidates driver
  623. * assumptions about always getting a vif pointer that is valid
  624. * (because if we remove a STA after ops->remove_interface()
  625. * the driver will have removed the vif info already!)
  626. *
  627. * This is relevant only in WDS mode, in all other modes we've
  628. * already removed all stations when disconnecting or similar,
  629. * so warn otherwise.
  630. *
  631. * We call sta_info_flush_cleanup() later, to combine RCU waits.
  632. */
  633. flushed = sta_info_flush_defer(sdata);
  634. WARN_ON_ONCE((sdata->vif.type != NL80211_IFTYPE_WDS && flushed > 0) ||
  635. (sdata->vif.type == NL80211_IFTYPE_WDS && flushed != 1));
  636. /* don't count this interface for promisc/allmulti while it is down */
  637. if (sdata->flags & IEEE80211_SDATA_ALLMULTI)
  638. atomic_dec(&local->iff_allmultis);
  639. if (sdata->flags & IEEE80211_SDATA_PROMISC)
  640. atomic_dec(&local->iff_promiscs);
  641. if (sdata->vif.type == NL80211_IFTYPE_AP) {
  642. local->fif_pspoll--;
  643. local->fif_probe_req--;
  644. } else if (sdata->vif.type == NL80211_IFTYPE_ADHOC) {
  645. local->fif_probe_req--;
  646. }
  647. if (sdata->dev) {
  648. netif_addr_lock_bh(sdata->dev);
  649. spin_lock_bh(&local->filter_lock);
  650. __hw_addr_unsync(&local->mc_list, &sdata->dev->mc,
  651. sdata->dev->addr_len);
  652. spin_unlock_bh(&local->filter_lock);
  653. netif_addr_unlock_bh(sdata->dev);
  654. }
  655. del_timer_sync(&local->dynamic_ps_timer);
  656. cancel_work_sync(&local->dynamic_ps_enable_work);
  657. cancel_work_sync(&sdata->recalc_smps);
  658. cancel_delayed_work_sync(&sdata->dfs_cac_timer_work);
  659. if (sdata->wdev.cac_started) {
  660. WARN_ON(local->suspended);
  661. mutex_lock(&local->iflist_mtx);
  662. ieee80211_vif_release_channel(sdata);
  663. mutex_unlock(&local->iflist_mtx);
  664. cfg80211_cac_event(sdata->dev, NL80211_RADAR_CAC_ABORTED,
  665. GFP_KERNEL);
  666. }
  667. /* APs need special treatment */
  668. if (sdata->vif.type == NL80211_IFTYPE_AP) {
  669. struct ieee80211_sub_if_data *vlan, *tmpsdata;
  670. /* down all dependent devices, that is VLANs */
  671. list_for_each_entry_safe(vlan, tmpsdata, &sdata->u.ap.vlans,
  672. u.vlan.list)
  673. dev_close(vlan->dev);
  674. WARN_ON(!list_empty(&sdata->u.ap.vlans));
  675. } else if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN) {
  676. /* remove all packets in parent bc_buf pointing to this dev */
  677. ps = &sdata->bss->ps;
  678. spin_lock_irqsave(&ps->bc_buf.lock, flags);
  679. skb_queue_walk_safe(&ps->bc_buf, skb, tmp) {
  680. if (skb->dev == sdata->dev) {
  681. __skb_unlink(skb, &ps->bc_buf);
  682. local->total_ps_buffered--;
  683. ieee80211_free_txskb(&local->hw, skb);
  684. }
  685. }
  686. spin_unlock_irqrestore(&ps->bc_buf.lock, flags);
  687. }
  688. if (going_down)
  689. local->open_count--;
  690. switch (sdata->vif.type) {
  691. case NL80211_IFTYPE_AP_VLAN:
  692. list_del(&sdata->u.vlan.list);
  693. rcu_assign_pointer(sdata->vif.chanctx_conf, NULL);
  694. /* no need to tell driver */
  695. break;
  696. case NL80211_IFTYPE_MONITOR:
  697. if (sdata->u.mntr_flags & MONITOR_FLAG_COOK_FRAMES) {
  698. local->cooked_mntrs--;
  699. break;
  700. }
  701. local->monitors--;
  702. if (local->monitors == 0) {
  703. local->hw.conf.flags &= ~IEEE80211_CONF_MONITOR;
  704. hw_reconf_flags |= IEEE80211_CONF_CHANGE_MONITOR;
  705. }
  706. ieee80211_adjust_monitor_flags(sdata, -1);
  707. break;
  708. case NL80211_IFTYPE_P2P_DEVICE:
  709. /* relies on synchronize_rcu() below */
  710. rcu_assign_pointer(local->p2p_sdata, NULL);
  711. /* fall through */
  712. default:
  713. cancel_work_sync(&sdata->work);
  714. /*
  715. * When we get here, the interface is marked down.
  716. *
  717. * sta_info_flush_cleanup() requires rcu_barrier()
  718. * first to wait for the station call_rcu() calls
  719. * to complete, and we also need synchronize_rcu()
  720. * to wait for the RX path in case it is using the
  721. * interface and enqueuing frames at this very time on
  722. * another CPU.
  723. */
  724. synchronize_rcu();
  725. rcu_barrier();
  726. sta_info_flush_cleanup(sdata);
  727. /*
  728. * Free all remaining keys, there shouldn't be any,
  729. * except maybe in WDS mode?
  730. */
  731. ieee80211_free_keys(sdata);
  732. /* fall through */
  733. case NL80211_IFTYPE_AP:
  734. skb_queue_purge(&sdata->skb_queue);
  735. }
  736. sdata->bss = NULL;
  737. spin_lock_irqsave(&local->queue_stop_reason_lock, flags);
  738. for (i = 0; i < IEEE80211_MAX_QUEUES; i++) {
  739. skb_queue_walk_safe(&local->pending[i], skb, tmp) {
  740. struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb);
  741. if (info->control.vif == &sdata->vif) {
  742. __skb_unlink(skb, &local->pending[i]);
  743. ieee80211_free_txskb(&local->hw, skb);
  744. }
  745. }
  746. }
  747. spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
  748. if (local->open_count == 0)
  749. ieee80211_clear_tx_pending(local);
  750. /*
  751. * If the interface goes down while suspended, presumably because
  752. * the device was unplugged and that happens before our resume,
  753. * then the driver is already unconfigured and the remainder of
  754. * this function isn't needed.
  755. * XXX: what about WoWLAN? If the device has software state, e.g.
  756. * memory allocated, it might expect teardown commands from
  757. * mac80211 here?
  758. */
  759. if (local->suspended) {
  760. WARN_ON(local->wowlan);
  761. WARN_ON(rtnl_dereference(local->monitor_sdata));
  762. return;
  763. }
  764. switch (sdata->vif.type) {
  765. case NL80211_IFTYPE_AP_VLAN:
  766. break;
  767. case NL80211_IFTYPE_MONITOR:
  768. if (local->monitors == 0)
  769. ieee80211_del_virtual_monitor(local);
  770. mutex_lock(&local->mtx);
  771. ieee80211_recalc_idle(local);
  772. mutex_unlock(&local->mtx);
  773. break;
  774. default:
  775. if (going_down)
  776. drv_remove_interface(local, sdata);
  777. }
  778. ieee80211_recalc_ps(local, -1);
  779. if (local->open_count == 0) {
  780. ieee80211_stop_device(local);
  781. /* no reconfiguring after stop! */
  782. return;
  783. }
  784. /* do after stop to avoid reconfiguring when we stop anyway */
  785. ieee80211_configure_filter(local);
  786. ieee80211_hw_config(local, hw_reconf_flags);
  787. if (local->monitors == local->open_count)
  788. ieee80211_add_virtual_monitor(local);
  789. }
  790. static int ieee80211_stop(struct net_device *dev)
  791. {
  792. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  793. ieee80211_do_stop(sdata, true);
  794. return 0;
  795. }
  796. static void ieee80211_set_multicast_list(struct net_device *dev)
  797. {
  798. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  799. struct ieee80211_local *local = sdata->local;
  800. int allmulti, promisc, sdata_allmulti, sdata_promisc;
  801. allmulti = !!(dev->flags & IFF_ALLMULTI);
  802. promisc = !!(dev->flags & IFF_PROMISC);
  803. sdata_allmulti = !!(sdata->flags & IEEE80211_SDATA_ALLMULTI);
  804. sdata_promisc = !!(sdata->flags & IEEE80211_SDATA_PROMISC);
  805. if (allmulti != sdata_allmulti) {
  806. if (dev->flags & IFF_ALLMULTI)
  807. atomic_inc(&local->iff_allmultis);
  808. else
  809. atomic_dec(&local->iff_allmultis);
  810. sdata->flags ^= IEEE80211_SDATA_ALLMULTI;
  811. }
  812. if (promisc != sdata_promisc) {
  813. if (dev->flags & IFF_PROMISC)
  814. atomic_inc(&local->iff_promiscs);
  815. else
  816. atomic_dec(&local->iff_promiscs);
  817. sdata->flags ^= IEEE80211_SDATA_PROMISC;
  818. }
  819. /*
  820. * TODO: If somebody needs this on AP interfaces,
  821. * it can be enabled easily but multicast
  822. * addresses from VLANs need to be synced.
  823. */
  824. if (sdata->vif.type != NL80211_IFTYPE_MONITOR &&
  825. sdata->vif.type != NL80211_IFTYPE_AP_VLAN &&
  826. sdata->vif.type != NL80211_IFTYPE_AP)
  827. drv_set_multicast_list(local, sdata, &dev->mc);
  828. spin_lock_bh(&local->filter_lock);
  829. __hw_addr_sync(&local->mc_list, &dev->mc, dev->addr_len);
  830. spin_unlock_bh(&local->filter_lock);
  831. ieee80211_queue_work(&local->hw, &local->reconfig_filter);
  832. }
  833. /*
  834. * Called when the netdev is removed or, by the code below, before
  835. * the interface type changes.
  836. */
  837. static void ieee80211_teardown_sdata(struct ieee80211_sub_if_data *sdata)
  838. {
  839. int flushed;
  840. int i;
  841. /* free extra data */
  842. ieee80211_free_keys(sdata);
  843. ieee80211_debugfs_remove_netdev(sdata);
  844. for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
  845. __skb_queue_purge(&sdata->fragments[i].skb_list);
  846. sdata->fragment_next = 0;
  847. if (ieee80211_vif_is_mesh(&sdata->vif))
  848. mesh_rmc_free(sdata);
  849. flushed = sta_info_flush(sdata);
  850. WARN_ON(flushed);
  851. }
  852. static void ieee80211_uninit(struct net_device *dev)
  853. {
  854. ieee80211_teardown_sdata(IEEE80211_DEV_TO_SUB_IF(dev));
  855. }
  856. static u16 ieee80211_netdev_select_queue(struct net_device *dev,
  857. struct sk_buff *skb)
  858. {
  859. return ieee80211_select_queue(IEEE80211_DEV_TO_SUB_IF(dev), skb);
  860. }
  861. static const struct net_device_ops ieee80211_dataif_ops = {
  862. .ndo_open = ieee80211_open,
  863. .ndo_stop = ieee80211_stop,
  864. .ndo_uninit = ieee80211_uninit,
  865. .ndo_start_xmit = ieee80211_subif_start_xmit,
  866. .ndo_set_rx_mode = ieee80211_set_multicast_list,
  867. .ndo_change_mtu = ieee80211_change_mtu,
  868. .ndo_set_mac_address = ieee80211_change_mac,
  869. .ndo_select_queue = ieee80211_netdev_select_queue,
  870. };
  871. static u16 ieee80211_monitor_select_queue(struct net_device *dev,
  872. struct sk_buff *skb)
  873. {
  874. struct ieee80211_sub_if_data *sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  875. struct ieee80211_local *local = sdata->local;
  876. struct ieee80211_hdr *hdr;
  877. struct ieee80211_radiotap_header *rtap = (void *)skb->data;
  878. if (local->hw.queues < IEEE80211_NUM_ACS)
  879. return 0;
  880. if (skb->len < 4 ||
  881. skb->len < le16_to_cpu(rtap->it_len) + 2 /* frame control */)
  882. return 0; /* doesn't matter, frame will be dropped */
  883. hdr = (void *)((u8 *)skb->data + le16_to_cpu(rtap->it_len));
  884. return ieee80211_select_queue_80211(sdata, skb, hdr);
  885. }
  886. static const struct net_device_ops ieee80211_monitorif_ops = {
  887. .ndo_open = ieee80211_open,
  888. .ndo_stop = ieee80211_stop,
  889. .ndo_uninit = ieee80211_uninit,
  890. .ndo_start_xmit = ieee80211_monitor_start_xmit,
  891. .ndo_set_rx_mode = ieee80211_set_multicast_list,
  892. .ndo_change_mtu = ieee80211_change_mtu,
  893. .ndo_set_mac_address = eth_mac_addr,
  894. .ndo_select_queue = ieee80211_monitor_select_queue,
  895. };
  896. static void ieee80211_if_setup(struct net_device *dev)
  897. {
  898. ether_setup(dev);
  899. dev->priv_flags &= ~IFF_TX_SKB_SHARING;
  900. dev->netdev_ops = &ieee80211_dataif_ops;
  901. dev->destructor = free_netdev;
  902. }
  903. static void ieee80211_iface_work(struct work_struct *work)
  904. {
  905. struct ieee80211_sub_if_data *sdata =
  906. container_of(work, struct ieee80211_sub_if_data, work);
  907. struct ieee80211_local *local = sdata->local;
  908. struct sk_buff *skb;
  909. struct sta_info *sta;
  910. struct ieee80211_ra_tid *ra_tid;
  911. if (!ieee80211_sdata_running(sdata))
  912. return;
  913. if (local->scanning)
  914. return;
  915. /*
  916. * ieee80211_queue_work() should have picked up most cases,
  917. * here we'll pick the rest.
  918. */
  919. if (WARN(local->suspended,
  920. "interface work scheduled while going to suspend\n"))
  921. return;
  922. /* first process frames */
  923. while ((skb = skb_dequeue(&sdata->skb_queue))) {
  924. struct ieee80211_mgmt *mgmt = (void *)skb->data;
  925. if (skb->pkt_type == IEEE80211_SDATA_QUEUE_AGG_START) {
  926. ra_tid = (void *)&skb->cb;
  927. ieee80211_start_tx_ba_cb(&sdata->vif, ra_tid->ra,
  928. ra_tid->tid);
  929. } else if (skb->pkt_type == IEEE80211_SDATA_QUEUE_AGG_STOP) {
  930. ra_tid = (void *)&skb->cb;
  931. ieee80211_stop_tx_ba_cb(&sdata->vif, ra_tid->ra,
  932. ra_tid->tid);
  933. } else if (ieee80211_is_action(mgmt->frame_control) &&
  934. mgmt->u.action.category == WLAN_CATEGORY_BACK) {
  935. int len = skb->len;
  936. mutex_lock(&local->sta_mtx);
  937. sta = sta_info_get_bss(sdata, mgmt->sa);
  938. if (sta) {
  939. switch (mgmt->u.action.u.addba_req.action_code) {
  940. case WLAN_ACTION_ADDBA_REQ:
  941. ieee80211_process_addba_request(
  942. local, sta, mgmt, len);
  943. break;
  944. case WLAN_ACTION_ADDBA_RESP:
  945. ieee80211_process_addba_resp(local, sta,
  946. mgmt, len);
  947. break;
  948. case WLAN_ACTION_DELBA:
  949. ieee80211_process_delba(sdata, sta,
  950. mgmt, len);
  951. break;
  952. default:
  953. WARN_ON(1);
  954. break;
  955. }
  956. }
  957. mutex_unlock(&local->sta_mtx);
  958. } else if (ieee80211_is_data_qos(mgmt->frame_control)) {
  959. struct ieee80211_hdr *hdr = (void *)mgmt;
  960. /*
  961. * So the frame isn't mgmt, but frame_control
  962. * is at the right place anyway, of course, so
  963. * the if statement is correct.
  964. *
  965. * Warn if we have other data frame types here,
  966. * they must not get here.
  967. */
  968. WARN_ON(hdr->frame_control &
  969. cpu_to_le16(IEEE80211_STYPE_NULLFUNC));
  970. WARN_ON(!(hdr->seq_ctrl &
  971. cpu_to_le16(IEEE80211_SCTL_FRAG)));
  972. /*
  973. * This was a fragment of a frame, received while
  974. * a block-ack session was active. That cannot be
  975. * right, so terminate the session.
  976. */
  977. mutex_lock(&local->sta_mtx);
  978. sta = sta_info_get_bss(sdata, mgmt->sa);
  979. if (sta) {
  980. u16 tid = *ieee80211_get_qos_ctl(hdr) &
  981. IEEE80211_QOS_CTL_TID_MASK;
  982. __ieee80211_stop_rx_ba_session(
  983. sta, tid, WLAN_BACK_RECIPIENT,
  984. WLAN_REASON_QSTA_REQUIRE_SETUP,
  985. true);
  986. }
  987. mutex_unlock(&local->sta_mtx);
  988. } else switch (sdata->vif.type) {
  989. case NL80211_IFTYPE_STATION:
  990. ieee80211_sta_rx_queued_mgmt(sdata, skb);
  991. break;
  992. case NL80211_IFTYPE_ADHOC:
  993. ieee80211_ibss_rx_queued_mgmt(sdata, skb);
  994. break;
  995. case NL80211_IFTYPE_MESH_POINT:
  996. if (!ieee80211_vif_is_mesh(&sdata->vif))
  997. break;
  998. ieee80211_mesh_rx_queued_mgmt(sdata, skb);
  999. break;
  1000. default:
  1001. WARN(1, "frame for unexpected interface type");
  1002. break;
  1003. }
  1004. kfree_skb(skb);
  1005. }
  1006. /* then other type-dependent work */
  1007. switch (sdata->vif.type) {
  1008. case NL80211_IFTYPE_STATION:
  1009. ieee80211_sta_work(sdata);
  1010. break;
  1011. case NL80211_IFTYPE_ADHOC:
  1012. ieee80211_ibss_work(sdata);
  1013. break;
  1014. case NL80211_IFTYPE_MESH_POINT:
  1015. if (!ieee80211_vif_is_mesh(&sdata->vif))
  1016. break;
  1017. ieee80211_mesh_work(sdata);
  1018. break;
  1019. default:
  1020. break;
  1021. }
  1022. }
  1023. static void ieee80211_recalc_smps_work(struct work_struct *work)
  1024. {
  1025. struct ieee80211_sub_if_data *sdata =
  1026. container_of(work, struct ieee80211_sub_if_data, recalc_smps);
  1027. ieee80211_recalc_smps(sdata);
  1028. }
  1029. /*
  1030. * Helper function to initialise an interface to a specific type.
  1031. */
  1032. static void ieee80211_setup_sdata(struct ieee80211_sub_if_data *sdata,
  1033. enum nl80211_iftype type)
  1034. {
  1035. /* clear type-dependent union */
  1036. memset(&sdata->u, 0, sizeof(sdata->u));
  1037. /* and set some type-dependent values */
  1038. sdata->vif.type = type;
  1039. sdata->vif.p2p = false;
  1040. sdata->wdev.iftype = type;
  1041. sdata->control_port_protocol = cpu_to_be16(ETH_P_PAE);
  1042. sdata->control_port_no_encrypt = false;
  1043. sdata->noack_map = 0;
  1044. /* only monitor/p2p-device differ */
  1045. if (sdata->dev) {
  1046. sdata->dev->netdev_ops = &ieee80211_dataif_ops;
  1047. sdata->dev->type = ARPHRD_ETHER;
  1048. }
  1049. skb_queue_head_init(&sdata->skb_queue);
  1050. INIT_WORK(&sdata->work, ieee80211_iface_work);
  1051. INIT_WORK(&sdata->recalc_smps, ieee80211_recalc_smps_work);
  1052. switch (type) {
  1053. case NL80211_IFTYPE_P2P_GO:
  1054. type = NL80211_IFTYPE_AP;
  1055. sdata->vif.type = type;
  1056. sdata->vif.p2p = true;
  1057. /* fall through */
  1058. case NL80211_IFTYPE_AP:
  1059. skb_queue_head_init(&sdata->u.ap.ps.bc_buf);
  1060. INIT_LIST_HEAD(&sdata->u.ap.vlans);
  1061. sdata->vif.bss_conf.bssid = sdata->vif.addr;
  1062. break;
  1063. case NL80211_IFTYPE_P2P_CLIENT:
  1064. type = NL80211_IFTYPE_STATION;
  1065. sdata->vif.type = type;
  1066. sdata->vif.p2p = true;
  1067. /* fall through */
  1068. case NL80211_IFTYPE_STATION:
  1069. sdata->vif.bss_conf.bssid = sdata->u.mgd.bssid;
  1070. ieee80211_sta_setup_sdata(sdata);
  1071. break;
  1072. case NL80211_IFTYPE_ADHOC:
  1073. sdata->vif.bss_conf.bssid = sdata->u.ibss.bssid;
  1074. ieee80211_ibss_setup_sdata(sdata);
  1075. break;
  1076. case NL80211_IFTYPE_MESH_POINT:
  1077. if (ieee80211_vif_is_mesh(&sdata->vif))
  1078. ieee80211_mesh_init_sdata(sdata);
  1079. break;
  1080. case NL80211_IFTYPE_MONITOR:
  1081. sdata->dev->type = ARPHRD_IEEE80211_RADIOTAP;
  1082. sdata->dev->netdev_ops = &ieee80211_monitorif_ops;
  1083. sdata->u.mntr_flags = MONITOR_FLAG_CONTROL |
  1084. MONITOR_FLAG_OTHER_BSS;
  1085. break;
  1086. case NL80211_IFTYPE_WDS:
  1087. sdata->vif.bss_conf.bssid = NULL;
  1088. break;
  1089. case NL80211_IFTYPE_AP_VLAN:
  1090. break;
  1091. case NL80211_IFTYPE_P2P_DEVICE:
  1092. sdata->vif.bss_conf.bssid = sdata->vif.addr;
  1093. break;
  1094. case NL80211_IFTYPE_UNSPECIFIED:
  1095. case NUM_NL80211_IFTYPES:
  1096. BUG();
  1097. break;
  1098. }
  1099. ieee80211_debugfs_add_netdev(sdata);
  1100. }
  1101. static int ieee80211_runtime_change_iftype(struct ieee80211_sub_if_data *sdata,
  1102. enum nl80211_iftype type)
  1103. {
  1104. struct ieee80211_local *local = sdata->local;
  1105. int ret, err;
  1106. enum nl80211_iftype internal_type = type;
  1107. bool p2p = false;
  1108. ASSERT_RTNL();
  1109. if (!local->ops->change_interface)
  1110. return -EBUSY;
  1111. switch (sdata->vif.type) {
  1112. case NL80211_IFTYPE_AP:
  1113. case NL80211_IFTYPE_STATION:
  1114. case NL80211_IFTYPE_ADHOC:
  1115. /*
  1116. * Could maybe also all others here?
  1117. * Just not sure how that interacts
  1118. * with the RX/config path e.g. for
  1119. * mesh.
  1120. */
  1121. break;
  1122. default:
  1123. return -EBUSY;
  1124. }
  1125. switch (type) {
  1126. case NL80211_IFTYPE_AP:
  1127. case NL80211_IFTYPE_STATION:
  1128. case NL80211_IFTYPE_ADHOC:
  1129. /*
  1130. * Could probably support everything
  1131. * but WDS here (WDS do_open can fail
  1132. * under memory pressure, which this
  1133. * code isn't prepared to handle).
  1134. */
  1135. break;
  1136. case NL80211_IFTYPE_P2P_CLIENT:
  1137. p2p = true;
  1138. internal_type = NL80211_IFTYPE_STATION;
  1139. break;
  1140. case NL80211_IFTYPE_P2P_GO:
  1141. p2p = true;
  1142. internal_type = NL80211_IFTYPE_AP;
  1143. break;
  1144. default:
  1145. return -EBUSY;
  1146. }
  1147. ret = ieee80211_check_concurrent_iface(sdata, internal_type);
  1148. if (ret)
  1149. return ret;
  1150. ieee80211_do_stop(sdata, false);
  1151. ieee80211_teardown_sdata(sdata);
  1152. ret = drv_change_interface(local, sdata, internal_type, p2p);
  1153. if (ret)
  1154. type = sdata->vif.type;
  1155. /*
  1156. * Ignore return value here, there's not much we can do since
  1157. * the driver changed the interface type internally already.
  1158. * The warnings will hopefully make driver authors fix it :-)
  1159. */
  1160. ieee80211_check_queues(sdata);
  1161. ieee80211_setup_sdata(sdata, type);
  1162. err = ieee80211_do_open(&sdata->wdev, false);
  1163. WARN(err, "type change: do_open returned %d", err);
  1164. return ret;
  1165. }
  1166. int ieee80211_if_change_type(struct ieee80211_sub_if_data *sdata,
  1167. enum nl80211_iftype type)
  1168. {
  1169. int ret;
  1170. ASSERT_RTNL();
  1171. if (type == ieee80211_vif_type_p2p(&sdata->vif))
  1172. return 0;
  1173. if (ieee80211_sdata_running(sdata)) {
  1174. ret = ieee80211_runtime_change_iftype(sdata, type);
  1175. if (ret)
  1176. return ret;
  1177. } else {
  1178. /* Purge and reset type-dependent state. */
  1179. ieee80211_teardown_sdata(sdata);
  1180. ieee80211_setup_sdata(sdata, type);
  1181. }
  1182. /* reset some values that shouldn't be kept across type changes */
  1183. sdata->drop_unencrypted = 0;
  1184. if (type == NL80211_IFTYPE_STATION)
  1185. sdata->u.mgd.use_4addr = false;
  1186. return 0;
  1187. }
  1188. static void ieee80211_assign_perm_addr(struct ieee80211_local *local,
  1189. u8 *perm_addr, enum nl80211_iftype type)
  1190. {
  1191. struct ieee80211_sub_if_data *sdata;
  1192. u64 mask, start, addr, val, inc;
  1193. u8 *m;
  1194. u8 tmp_addr[ETH_ALEN];
  1195. int i;
  1196. /* default ... something at least */
  1197. memcpy(perm_addr, local->hw.wiphy->perm_addr, ETH_ALEN);
  1198. if (is_zero_ether_addr(local->hw.wiphy->addr_mask) &&
  1199. local->hw.wiphy->n_addresses <= 1)
  1200. return;
  1201. mutex_lock(&local->iflist_mtx);
  1202. switch (type) {
  1203. case NL80211_IFTYPE_MONITOR:
  1204. /* doesn't matter */
  1205. break;
  1206. case NL80211_IFTYPE_WDS:
  1207. case NL80211_IFTYPE_AP_VLAN:
  1208. /* match up with an AP interface */
  1209. list_for_each_entry(sdata, &local->interfaces, list) {
  1210. if (sdata->vif.type != NL80211_IFTYPE_AP)
  1211. continue;
  1212. memcpy(perm_addr, sdata->vif.addr, ETH_ALEN);
  1213. break;
  1214. }
  1215. /* keep default if no AP interface present */
  1216. break;
  1217. case NL80211_IFTYPE_P2P_CLIENT:
  1218. case NL80211_IFTYPE_P2P_GO:
  1219. if (local->hw.flags & IEEE80211_HW_P2P_DEV_ADDR_FOR_INTF) {
  1220. list_for_each_entry(sdata, &local->interfaces, list) {
  1221. if (sdata->vif.type != NL80211_IFTYPE_P2P_DEVICE)
  1222. continue;
  1223. if (!ieee80211_sdata_running(sdata))
  1224. continue;
  1225. memcpy(perm_addr, sdata->vif.addr, ETH_ALEN);
  1226. goto out_unlock;
  1227. }
  1228. }
  1229. /* otherwise fall through */
  1230. default:
  1231. /* assign a new address if possible -- try n_addresses first */
  1232. for (i = 0; i < local->hw.wiphy->n_addresses; i++) {
  1233. bool used = false;
  1234. list_for_each_entry(sdata, &local->interfaces, list) {
  1235. if (memcmp(local->hw.wiphy->addresses[i].addr,
  1236. sdata->vif.addr, ETH_ALEN) == 0) {
  1237. used = true;
  1238. break;
  1239. }
  1240. }
  1241. if (!used) {
  1242. memcpy(perm_addr,
  1243. local->hw.wiphy->addresses[i].addr,
  1244. ETH_ALEN);
  1245. break;
  1246. }
  1247. }
  1248. /* try mask if available */
  1249. if (is_zero_ether_addr(local->hw.wiphy->addr_mask))
  1250. break;
  1251. m = local->hw.wiphy->addr_mask;
  1252. mask = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
  1253. ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
  1254. ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
  1255. if (__ffs64(mask) + hweight64(mask) != fls64(mask)) {
  1256. /* not a contiguous mask ... not handled now! */
  1257. pr_info("not contiguous\n");
  1258. break;
  1259. }
  1260. /*
  1261. * Pick address of existing interface in case user changed
  1262. * MAC address manually, default to perm_addr.
  1263. */
  1264. m = local->hw.wiphy->perm_addr;
  1265. list_for_each_entry(sdata, &local->interfaces, list) {
  1266. if (sdata->vif.type == NL80211_IFTYPE_MONITOR)
  1267. continue;
  1268. m = sdata->vif.addr;
  1269. break;
  1270. }
  1271. start = ((u64)m[0] << 5*8) | ((u64)m[1] << 4*8) |
  1272. ((u64)m[2] << 3*8) | ((u64)m[3] << 2*8) |
  1273. ((u64)m[4] << 1*8) | ((u64)m[5] << 0*8);
  1274. inc = 1ULL<<__ffs64(mask);
  1275. val = (start & mask);
  1276. addr = (start & ~mask) | (val & mask);
  1277. do {
  1278. bool used = false;
  1279. tmp_addr[5] = addr >> 0*8;
  1280. tmp_addr[4] = addr >> 1*8;
  1281. tmp_addr[3] = addr >> 2*8;
  1282. tmp_addr[2] = addr >> 3*8;
  1283. tmp_addr[1] = addr >> 4*8;
  1284. tmp_addr[0] = addr >> 5*8;
  1285. val += inc;
  1286. list_for_each_entry(sdata, &local->interfaces, list) {
  1287. if (memcmp(tmp_addr, sdata->vif.addr,
  1288. ETH_ALEN) == 0) {
  1289. used = true;
  1290. break;
  1291. }
  1292. }
  1293. if (!used) {
  1294. memcpy(perm_addr, tmp_addr, ETH_ALEN);
  1295. break;
  1296. }
  1297. addr = (start & ~mask) | (val & mask);
  1298. } while (addr != start);
  1299. break;
  1300. }
  1301. out_unlock:
  1302. mutex_unlock(&local->iflist_mtx);
  1303. }
  1304. static void ieee80211_cleanup_sdata_stas_wk(struct work_struct *wk)
  1305. {
  1306. struct ieee80211_sub_if_data *sdata;
  1307. sdata = container_of(wk, struct ieee80211_sub_if_data, cleanup_stations_wk);
  1308. ieee80211_cleanup_sdata_stas(sdata);
  1309. }
  1310. int ieee80211_if_add(struct ieee80211_local *local, const char *name,
  1311. struct wireless_dev **new_wdev, enum nl80211_iftype type,
  1312. struct vif_params *params)
  1313. {
  1314. struct net_device *ndev = NULL;
  1315. struct ieee80211_sub_if_data *sdata = NULL;
  1316. int ret, i;
  1317. int txqs = 1;
  1318. ASSERT_RTNL();
  1319. if (type == NL80211_IFTYPE_P2P_DEVICE) {
  1320. struct wireless_dev *wdev;
  1321. sdata = kzalloc(sizeof(*sdata) + local->hw.vif_data_size,
  1322. GFP_KERNEL);
  1323. if (!sdata)
  1324. return -ENOMEM;
  1325. wdev = &sdata->wdev;
  1326. sdata->dev = NULL;
  1327. strlcpy(sdata->name, name, IFNAMSIZ);
  1328. ieee80211_assign_perm_addr(local, wdev->address, type);
  1329. memcpy(sdata->vif.addr, wdev->address, ETH_ALEN);
  1330. } else {
  1331. if (local->hw.queues >= IEEE80211_NUM_ACS)
  1332. txqs = IEEE80211_NUM_ACS;
  1333. ndev = alloc_netdev_mqs(sizeof(*sdata) +
  1334. local->hw.vif_data_size,
  1335. name, ieee80211_if_setup, txqs, 1);
  1336. if (!ndev)
  1337. return -ENOMEM;
  1338. dev_net_set(ndev, wiphy_net(local->hw.wiphy));
  1339. ndev->needed_headroom = local->tx_headroom +
  1340. 4*6 /* four MAC addresses */
  1341. + 2 + 2 + 2 + 2 /* ctl, dur, seq, qos */
  1342. + 6 /* mesh */
  1343. + 8 /* rfc1042/bridge tunnel */
  1344. - ETH_HLEN /* ethernet hard_header_len */
  1345. + IEEE80211_ENCRYPT_HEADROOM;
  1346. ndev->needed_tailroom = IEEE80211_ENCRYPT_TAILROOM;
  1347. ret = dev_alloc_name(ndev, ndev->name);
  1348. if (ret < 0) {
  1349. free_netdev(ndev);
  1350. return ret;
  1351. }
  1352. ieee80211_assign_perm_addr(local, ndev->perm_addr, type);
  1353. memcpy(ndev->dev_addr, ndev->perm_addr, ETH_ALEN);
  1354. SET_NETDEV_DEV(ndev, wiphy_dev(local->hw.wiphy));
  1355. /* don't use IEEE80211_DEV_TO_SUB_IF -- it checks too much */
  1356. sdata = netdev_priv(ndev);
  1357. ndev->ieee80211_ptr = &sdata->wdev;
  1358. memcpy(sdata->vif.addr, ndev->dev_addr, ETH_ALEN);
  1359. memcpy(sdata->name, ndev->name, IFNAMSIZ);
  1360. sdata->dev = ndev;
  1361. }
  1362. /* initialise type-independent data */
  1363. sdata->wdev.wiphy = local->hw.wiphy;
  1364. sdata->local = local;
  1365. for (i = 0; i < IEEE80211_FRAGMENT_MAX; i++)
  1366. skb_queue_head_init(&sdata->fragments[i].skb_list);
  1367. INIT_LIST_HEAD(&sdata->key_list);
  1368. spin_lock_init(&sdata->cleanup_stations_lock);
  1369. INIT_LIST_HEAD(&sdata->cleanup_stations);
  1370. INIT_WORK(&sdata->cleanup_stations_wk, ieee80211_cleanup_sdata_stas_wk);
  1371. INIT_DELAYED_WORK(&sdata->dfs_cac_timer_work,
  1372. ieee80211_dfs_cac_timer_work);
  1373. INIT_DELAYED_WORK(&sdata->dec_tailroom_needed_wk,
  1374. ieee80211_delayed_tailroom_dec);
  1375. for (i = 0; i < IEEE80211_NUM_BANDS; i++) {
  1376. struct ieee80211_supported_band *sband;
  1377. sband = local->hw.wiphy->bands[i];
  1378. sdata->rc_rateidx_mask[i] =
  1379. sband ? (1 << sband->n_bitrates) - 1 : 0;
  1380. if (sband)
  1381. memcpy(sdata->rc_rateidx_mcs_mask[i],
  1382. sband->ht_cap.mcs.rx_mask,
  1383. sizeof(sdata->rc_rateidx_mcs_mask[i]));
  1384. else
  1385. memset(sdata->rc_rateidx_mcs_mask[i], 0,
  1386. sizeof(sdata->rc_rateidx_mcs_mask[i]));
  1387. }
  1388. ieee80211_set_default_queues(sdata);
  1389. sdata->ap_power_level = IEEE80211_UNSET_POWER_LEVEL;
  1390. sdata->user_power_level = local->user_power_level;
  1391. /* setup type-dependent data */
  1392. ieee80211_setup_sdata(sdata, type);
  1393. if (ndev) {
  1394. if (params) {
  1395. ndev->ieee80211_ptr->use_4addr = params->use_4addr;
  1396. if (type == NL80211_IFTYPE_STATION)
  1397. sdata->u.mgd.use_4addr = params->use_4addr;
  1398. }
  1399. ndev->features |= local->hw.netdev_features;
  1400. ret = register_netdevice(ndev);
  1401. if (ret) {
  1402. free_netdev(ndev);
  1403. return ret;
  1404. }
  1405. }
  1406. mutex_lock(&local->iflist_mtx);
  1407. list_add_tail_rcu(&sdata->list, &local->interfaces);
  1408. mutex_unlock(&local->iflist_mtx);
  1409. if (new_wdev)
  1410. *new_wdev = &sdata->wdev;
  1411. return 0;
  1412. }
  1413. void ieee80211_if_remove(struct ieee80211_sub_if_data *sdata)
  1414. {
  1415. ASSERT_RTNL();
  1416. mutex_lock(&sdata->local->iflist_mtx);
  1417. list_del_rcu(&sdata->list);
  1418. mutex_unlock(&sdata->local->iflist_mtx);
  1419. synchronize_rcu();
  1420. if (sdata->dev) {
  1421. unregister_netdevice(sdata->dev);
  1422. } else {
  1423. cfg80211_unregister_wdev(&sdata->wdev);
  1424. kfree(sdata);
  1425. }
  1426. }
  1427. void ieee80211_sdata_stop(struct ieee80211_sub_if_data *sdata)
  1428. {
  1429. if (WARN_ON_ONCE(!test_bit(SDATA_STATE_RUNNING, &sdata->state)))
  1430. return;
  1431. ieee80211_do_stop(sdata, true);
  1432. ieee80211_teardown_sdata(sdata);
  1433. }
  1434. /*
  1435. * Remove all interfaces, may only be called at hardware unregistration
  1436. * time because it doesn't do RCU-safe list removals.
  1437. */
  1438. void ieee80211_remove_interfaces(struct ieee80211_local *local)
  1439. {
  1440. struct ieee80211_sub_if_data *sdata, *tmp;
  1441. LIST_HEAD(unreg_list);
  1442. LIST_HEAD(wdev_list);
  1443. ASSERT_RTNL();
  1444. /*
  1445. * Close all AP_VLAN interfaces first, as otherwise they
  1446. * might be closed while the AP interface they belong to
  1447. * is closed, causing unregister_netdevice_many() to crash.
  1448. */
  1449. list_for_each_entry(sdata, &local->interfaces, list)
  1450. if (sdata->vif.type == NL80211_IFTYPE_AP_VLAN)
  1451. dev_close(sdata->dev);
  1452. mutex_lock(&local->iflist_mtx);
  1453. list_for_each_entry_safe(sdata, tmp, &local->interfaces, list) {
  1454. list_del(&sdata->list);
  1455. if (sdata->dev)
  1456. unregister_netdevice_queue(sdata->dev, &unreg_list);
  1457. else
  1458. list_add(&sdata->list, &wdev_list);
  1459. }
  1460. mutex_unlock(&local->iflist_mtx);
  1461. unregister_netdevice_many(&unreg_list);
  1462. list_del(&unreg_list);
  1463. list_for_each_entry_safe(sdata, tmp, &wdev_list, list) {
  1464. list_del(&sdata->list);
  1465. cfg80211_unregister_wdev(&sdata->wdev);
  1466. kfree(sdata);
  1467. }
  1468. }
  1469. static int netdev_notify(struct notifier_block *nb,
  1470. unsigned long state,
  1471. void *ndev)
  1472. {
  1473. struct net_device *dev = ndev;
  1474. struct ieee80211_sub_if_data *sdata;
  1475. if (state != NETDEV_CHANGENAME)
  1476. return 0;
  1477. if (!dev->ieee80211_ptr || !dev->ieee80211_ptr->wiphy)
  1478. return 0;
  1479. if (dev->ieee80211_ptr->wiphy->privid != mac80211_wiphy_privid)
  1480. return 0;
  1481. sdata = IEEE80211_DEV_TO_SUB_IF(dev);
  1482. memcpy(sdata->name, dev->name, IFNAMSIZ);
  1483. ieee80211_debugfs_rename_netdev(sdata);
  1484. return 0;
  1485. }
  1486. static struct notifier_block mac80211_netdev_notifier = {
  1487. .notifier_call = netdev_notify,
  1488. };
  1489. int ieee80211_iface_init(void)
  1490. {
  1491. return register_netdevice_notifier(&mac80211_netdev_notifier);
  1492. }
  1493. void ieee80211_iface_exit(void)
  1494. {
  1495. unregister_netdevice_notifier(&mac80211_netdev_notifier);
  1496. }