hard-interface.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689
  1. /*
  2. * Copyright (C) 2007-2012 B.A.T.M.A.N. contributors:
  3. *
  4. * Marek Lindner, Simon Wunderlich
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of version 2 of the GNU General Public
  8. * License as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA
  19. *
  20. */
  21. #include "main.h"
  22. #include "hard-interface.h"
  23. #include "soft-interface.h"
  24. #include "send.h"
  25. #include "translation-table.h"
  26. #include "routing.h"
  27. #include "bat_sysfs.h"
  28. #include "originator.h"
  29. #include "hash.h"
  30. #include <linux/if_arp.h>
  31. static int batman_skb_recv(struct sk_buff *skb,
  32. struct net_device *dev,
  33. struct packet_type *ptype,
  34. struct net_device *orig_dev);
  35. void hardif_free_rcu(struct rcu_head *rcu)
  36. {
  37. struct hard_iface *hard_iface;
  38. hard_iface = container_of(rcu, struct hard_iface, rcu);
  39. dev_put(hard_iface->net_dev);
  40. kfree(hard_iface);
  41. }
  42. struct hard_iface *hardif_get_by_netdev(const struct net_device *net_dev)
  43. {
  44. struct hard_iface *hard_iface;
  45. rcu_read_lock();
  46. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  47. if (hard_iface->net_dev == net_dev &&
  48. atomic_inc_not_zero(&hard_iface->refcount))
  49. goto out;
  50. }
  51. hard_iface = NULL;
  52. out:
  53. rcu_read_unlock();
  54. return hard_iface;
  55. }
  56. static int is_valid_iface(const struct net_device *net_dev)
  57. {
  58. if (net_dev->flags & IFF_LOOPBACK)
  59. return 0;
  60. if (net_dev->type != ARPHRD_ETHER)
  61. return 0;
  62. if (net_dev->addr_len != ETH_ALEN)
  63. return 0;
  64. /* no batman over batman */
  65. if (softif_is_valid(net_dev))
  66. return 0;
  67. /* Device is being bridged */
  68. /* if (net_dev->priv_flags & IFF_BRIDGE_PORT)
  69. return 0; */
  70. return 1;
  71. }
  72. static struct hard_iface *hardif_get_active(const struct net_device *soft_iface)
  73. {
  74. struct hard_iface *hard_iface;
  75. rcu_read_lock();
  76. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  77. if (hard_iface->soft_iface != soft_iface)
  78. continue;
  79. if (hard_iface->if_status == IF_ACTIVE &&
  80. atomic_inc_not_zero(&hard_iface->refcount))
  81. goto out;
  82. }
  83. hard_iface = NULL;
  84. out:
  85. rcu_read_unlock();
  86. return hard_iface;
  87. }
  88. static void primary_if_update_addr(struct bat_priv *bat_priv)
  89. {
  90. struct vis_packet *vis_packet;
  91. struct hard_iface *primary_if;
  92. primary_if = primary_if_get_selected(bat_priv);
  93. if (!primary_if)
  94. goto out;
  95. vis_packet = (struct vis_packet *)
  96. bat_priv->my_vis_info->skb_packet->data;
  97. memcpy(vis_packet->vis_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
  98. memcpy(vis_packet->sender_orig,
  99. primary_if->net_dev->dev_addr, ETH_ALEN);
  100. out:
  101. if (primary_if)
  102. hardif_free_ref(primary_if);
  103. }
  104. static void primary_if_select(struct bat_priv *bat_priv,
  105. struct hard_iface *new_hard_iface)
  106. {
  107. struct hard_iface *curr_hard_iface;
  108. ASSERT_RTNL();
  109. if (new_hard_iface && !atomic_inc_not_zero(&new_hard_iface->refcount))
  110. new_hard_iface = NULL;
  111. curr_hard_iface = rcu_dereference_protected(bat_priv->primary_if, 1);
  112. rcu_assign_pointer(bat_priv->primary_if, new_hard_iface);
  113. if (curr_hard_iface)
  114. hardif_free_ref(curr_hard_iface);
  115. if (!new_hard_iface)
  116. return;
  117. bat_priv->bat_algo_ops->bat_ogm_init_primary(new_hard_iface);
  118. primary_if_update_addr(bat_priv);
  119. }
  120. static bool hardif_is_iface_up(const struct hard_iface *hard_iface)
  121. {
  122. if (hard_iface->net_dev->flags & IFF_UP)
  123. return true;
  124. return false;
  125. }
  126. static void check_known_mac_addr(const struct net_device *net_dev)
  127. {
  128. const struct hard_iface *hard_iface;
  129. rcu_read_lock();
  130. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  131. if ((hard_iface->if_status != IF_ACTIVE) &&
  132. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  133. continue;
  134. if (hard_iface->net_dev == net_dev)
  135. continue;
  136. if (!compare_eth(hard_iface->net_dev->dev_addr,
  137. net_dev->dev_addr))
  138. continue;
  139. pr_warning("The newly added mac address (%pM) already exists on: %s\n",
  140. net_dev->dev_addr, hard_iface->net_dev->name);
  141. pr_warning("It is strongly recommended to keep mac addresses unique to avoid problems!\n");
  142. }
  143. rcu_read_unlock();
  144. }
  145. int hardif_min_mtu(struct net_device *soft_iface)
  146. {
  147. const struct bat_priv *bat_priv = netdev_priv(soft_iface);
  148. const struct hard_iface *hard_iface;
  149. /* allow big frames if all devices are capable to do so
  150. * (have MTU > 1500 + BAT_HEADER_LEN) */
  151. int min_mtu = ETH_DATA_LEN;
  152. if (atomic_read(&bat_priv->fragmentation))
  153. goto out;
  154. rcu_read_lock();
  155. list_for_each_entry_rcu(hard_iface, &hardif_list, list) {
  156. if ((hard_iface->if_status != IF_ACTIVE) &&
  157. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  158. continue;
  159. if (hard_iface->soft_iface != soft_iface)
  160. continue;
  161. min_mtu = min_t(int, hard_iface->net_dev->mtu - BAT_HEADER_LEN,
  162. min_mtu);
  163. }
  164. rcu_read_unlock();
  165. out:
  166. return min_mtu;
  167. }
  168. /* adjusts the MTU if a new interface with a smaller MTU appeared. */
  169. void update_min_mtu(struct net_device *soft_iface)
  170. {
  171. int min_mtu;
  172. min_mtu = hardif_min_mtu(soft_iface);
  173. if (soft_iface->mtu != min_mtu)
  174. soft_iface->mtu = min_mtu;
  175. }
  176. static void hardif_activate_interface(struct hard_iface *hard_iface)
  177. {
  178. struct bat_priv *bat_priv;
  179. struct hard_iface *primary_if = NULL;
  180. if (hard_iface->if_status != IF_INACTIVE)
  181. goto out;
  182. bat_priv = netdev_priv(hard_iface->soft_iface);
  183. bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
  184. hard_iface->if_status = IF_TO_BE_ACTIVATED;
  185. /**
  186. * the first active interface becomes our primary interface or
  187. * the next active interface after the old primary interface was removed
  188. */
  189. primary_if = primary_if_get_selected(bat_priv);
  190. if (!primary_if)
  191. primary_if_select(bat_priv, hard_iface);
  192. bat_info(hard_iface->soft_iface, "Interface activated: %s\n",
  193. hard_iface->net_dev->name);
  194. update_min_mtu(hard_iface->soft_iface);
  195. out:
  196. if (primary_if)
  197. hardif_free_ref(primary_if);
  198. }
  199. static void hardif_deactivate_interface(struct hard_iface *hard_iface)
  200. {
  201. if ((hard_iface->if_status != IF_ACTIVE) &&
  202. (hard_iface->if_status != IF_TO_BE_ACTIVATED))
  203. return;
  204. hard_iface->if_status = IF_INACTIVE;
  205. bat_info(hard_iface->soft_iface, "Interface deactivated: %s\n",
  206. hard_iface->net_dev->name);
  207. update_min_mtu(hard_iface->soft_iface);
  208. }
  209. int hardif_enable_interface(struct hard_iface *hard_iface,
  210. const char *iface_name)
  211. {
  212. struct bat_priv *bat_priv;
  213. struct net_device *soft_iface;
  214. int ret;
  215. if (hard_iface->if_status != IF_NOT_IN_USE)
  216. goto out;
  217. if (!atomic_inc_not_zero(&hard_iface->refcount))
  218. goto out;
  219. /* hard-interface is part of a bridge */
  220. if (hard_iface->net_dev->priv_flags & IFF_BRIDGE_PORT)
  221. pr_err("You are about to enable batman-adv on '%s' which already is part of a bridge. Unless you know exactly what you are doing this is probably wrong and won't work the way you think it would.\n",
  222. hard_iface->net_dev->name);
  223. soft_iface = dev_get_by_name(&init_net, iface_name);
  224. if (!soft_iface) {
  225. soft_iface = softif_create(iface_name);
  226. if (!soft_iface) {
  227. ret = -ENOMEM;
  228. goto err;
  229. }
  230. /* dev_get_by_name() increases the reference counter for us */
  231. dev_hold(soft_iface);
  232. }
  233. if (!softif_is_valid(soft_iface)) {
  234. pr_err("Can't create batman mesh interface %s: already exists as regular interface\n",
  235. soft_iface->name);
  236. dev_put(soft_iface);
  237. ret = -EINVAL;
  238. goto err;
  239. }
  240. hard_iface->soft_iface = soft_iface;
  241. bat_priv = netdev_priv(hard_iface->soft_iface);
  242. bat_priv->bat_algo_ops->bat_ogm_init(hard_iface);
  243. if (!hard_iface->packet_buff) {
  244. bat_err(hard_iface->soft_iface,
  245. "Can't add interface packet (%s): out of memory\n",
  246. hard_iface->net_dev->name);
  247. ret = -ENOMEM;
  248. goto err;
  249. }
  250. hard_iface->if_num = bat_priv->num_ifaces;
  251. bat_priv->num_ifaces++;
  252. hard_iface->if_status = IF_INACTIVE;
  253. orig_hash_add_if(hard_iface, bat_priv->num_ifaces);
  254. hard_iface->batman_adv_ptype.type = __constant_htons(ETH_P_BATMAN);
  255. hard_iface->batman_adv_ptype.func = batman_skb_recv;
  256. hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
  257. dev_add_pack(&hard_iface->batman_adv_ptype);
  258. atomic_set(&hard_iface->seqno, 1);
  259. atomic_set(&hard_iface->frag_seqno, 1);
  260. bat_info(hard_iface->soft_iface, "Adding interface: %s\n",
  261. hard_iface->net_dev->name);
  262. if (atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  263. ETH_DATA_LEN + BAT_HEADER_LEN)
  264. bat_info(hard_iface->soft_iface,
  265. "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. Packets going over this interface will be fragmented on layer2 which could impact the performance. Setting the MTU to %zi would solve the problem.\n",
  266. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  267. ETH_DATA_LEN + BAT_HEADER_LEN);
  268. if (!atomic_read(&bat_priv->fragmentation) && hard_iface->net_dev->mtu <
  269. ETH_DATA_LEN + BAT_HEADER_LEN)
  270. bat_info(hard_iface->soft_iface,
  271. "The MTU of interface %s is too small (%i) to handle the transport of batman-adv packets. If you experience problems getting traffic through try increasing the MTU to %zi.\n",
  272. hard_iface->net_dev->name, hard_iface->net_dev->mtu,
  273. ETH_DATA_LEN + BAT_HEADER_LEN);
  274. if (hardif_is_iface_up(hard_iface))
  275. hardif_activate_interface(hard_iface);
  276. else
  277. bat_err(hard_iface->soft_iface,
  278. "Not using interface %s (retrying later): interface not active\n",
  279. hard_iface->net_dev->name);
  280. /* begin scheduling originator messages on that interface */
  281. schedule_bat_ogm(hard_iface);
  282. out:
  283. return 0;
  284. err:
  285. hardif_free_ref(hard_iface);
  286. return ret;
  287. }
  288. void hardif_disable_interface(struct hard_iface *hard_iface)
  289. {
  290. struct bat_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
  291. struct hard_iface *primary_if = NULL;
  292. if (hard_iface->if_status == IF_ACTIVE)
  293. hardif_deactivate_interface(hard_iface);
  294. if (hard_iface->if_status != IF_INACTIVE)
  295. goto out;
  296. bat_info(hard_iface->soft_iface, "Removing interface: %s\n",
  297. hard_iface->net_dev->name);
  298. dev_remove_pack(&hard_iface->batman_adv_ptype);
  299. bat_priv->num_ifaces--;
  300. orig_hash_del_if(hard_iface, bat_priv->num_ifaces);
  301. primary_if = primary_if_get_selected(bat_priv);
  302. if (hard_iface == primary_if) {
  303. struct hard_iface *new_if;
  304. new_if = hardif_get_active(hard_iface->soft_iface);
  305. primary_if_select(bat_priv, new_if);
  306. if (new_if)
  307. hardif_free_ref(new_if);
  308. }
  309. kfree(hard_iface->packet_buff);
  310. hard_iface->packet_buff = NULL;
  311. hard_iface->if_status = IF_NOT_IN_USE;
  312. /* delete all references to this hard_iface */
  313. purge_orig_ref(bat_priv);
  314. purge_outstanding_packets(bat_priv, hard_iface);
  315. dev_put(hard_iface->soft_iface);
  316. /* nobody uses this interface anymore */
  317. if (!bat_priv->num_ifaces)
  318. softif_destroy(hard_iface->soft_iface);
  319. hard_iface->soft_iface = NULL;
  320. hardif_free_ref(hard_iface);
  321. out:
  322. if (primary_if)
  323. hardif_free_ref(primary_if);
  324. }
  325. static struct hard_iface *hardif_add_interface(struct net_device *net_dev)
  326. {
  327. struct hard_iface *hard_iface;
  328. int ret;
  329. ASSERT_RTNL();
  330. ret = is_valid_iface(net_dev);
  331. if (ret != 1)
  332. goto out;
  333. dev_hold(net_dev);
  334. hard_iface = kmalloc(sizeof(*hard_iface), GFP_ATOMIC);
  335. if (!hard_iface)
  336. goto release_dev;
  337. ret = sysfs_add_hardif(&hard_iface->hardif_obj, net_dev);
  338. if (ret)
  339. goto free_if;
  340. hard_iface->if_num = -1;
  341. hard_iface->net_dev = net_dev;
  342. hard_iface->soft_iface = NULL;
  343. hard_iface->if_status = IF_NOT_IN_USE;
  344. INIT_LIST_HEAD(&hard_iface->list);
  345. /* extra reference for return */
  346. atomic_set(&hard_iface->refcount, 2);
  347. check_known_mac_addr(hard_iface->net_dev);
  348. list_add_tail_rcu(&hard_iface->list, &hardif_list);
  349. return hard_iface;
  350. free_if:
  351. kfree(hard_iface);
  352. release_dev:
  353. dev_put(net_dev);
  354. out:
  355. return NULL;
  356. }
  357. static void hardif_remove_interface(struct hard_iface *hard_iface)
  358. {
  359. ASSERT_RTNL();
  360. /* first deactivate interface */
  361. if (hard_iface->if_status != IF_NOT_IN_USE)
  362. hardif_disable_interface(hard_iface);
  363. if (hard_iface->if_status != IF_NOT_IN_USE)
  364. return;
  365. hard_iface->if_status = IF_TO_BE_REMOVED;
  366. sysfs_del_hardif(&hard_iface->hardif_obj);
  367. hardif_free_ref(hard_iface);
  368. }
  369. void hardif_remove_interfaces(void)
  370. {
  371. struct hard_iface *hard_iface, *hard_iface_tmp;
  372. rtnl_lock();
  373. list_for_each_entry_safe(hard_iface, hard_iface_tmp,
  374. &hardif_list, list) {
  375. list_del_rcu(&hard_iface->list);
  376. hardif_remove_interface(hard_iface);
  377. }
  378. rtnl_unlock();
  379. }
  380. static int hard_if_event(struct notifier_block *this,
  381. unsigned long event, void *ptr)
  382. {
  383. struct net_device *net_dev = ptr;
  384. struct hard_iface *hard_iface = hardif_get_by_netdev(net_dev);
  385. struct hard_iface *primary_if = NULL;
  386. struct bat_priv *bat_priv;
  387. if (!hard_iface && event == NETDEV_REGISTER)
  388. hard_iface = hardif_add_interface(net_dev);
  389. if (!hard_iface)
  390. goto out;
  391. switch (event) {
  392. case NETDEV_UP:
  393. hardif_activate_interface(hard_iface);
  394. break;
  395. case NETDEV_GOING_DOWN:
  396. case NETDEV_DOWN:
  397. hardif_deactivate_interface(hard_iface);
  398. break;
  399. case NETDEV_UNREGISTER:
  400. list_del_rcu(&hard_iface->list);
  401. hardif_remove_interface(hard_iface);
  402. break;
  403. case NETDEV_CHANGEMTU:
  404. if (hard_iface->soft_iface)
  405. update_min_mtu(hard_iface->soft_iface);
  406. break;
  407. case NETDEV_CHANGEADDR:
  408. if (hard_iface->if_status == IF_NOT_IN_USE)
  409. goto hardif_put;
  410. check_known_mac_addr(hard_iface->net_dev);
  411. bat_priv = netdev_priv(hard_iface->soft_iface);
  412. bat_priv->bat_algo_ops->bat_ogm_update_mac(hard_iface);
  413. primary_if = primary_if_get_selected(bat_priv);
  414. if (!primary_if)
  415. goto hardif_put;
  416. if (hard_iface == primary_if)
  417. primary_if_update_addr(bat_priv);
  418. break;
  419. default:
  420. break;
  421. }
  422. hardif_put:
  423. hardif_free_ref(hard_iface);
  424. out:
  425. if (primary_if)
  426. hardif_free_ref(primary_if);
  427. return NOTIFY_DONE;
  428. }
  429. /* incoming packets with the batman ethertype received on any active hard
  430. * interface */
  431. static int batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
  432. struct packet_type *ptype,
  433. struct net_device *orig_dev)
  434. {
  435. struct bat_priv *bat_priv;
  436. struct batman_ogm_packet *batman_ogm_packet;
  437. struct hard_iface *hard_iface;
  438. int ret;
  439. hard_iface = container_of(ptype, struct hard_iface, batman_adv_ptype);
  440. skb = skb_share_check(skb, GFP_ATOMIC);
  441. /* skb was released by skb_share_check() */
  442. if (!skb)
  443. goto err_out;
  444. /* packet should hold at least type and version */
  445. if (unlikely(!pskb_may_pull(skb, 2)))
  446. goto err_free;
  447. /* expect a valid ethernet header here. */
  448. if (unlikely(skb->mac_len != sizeof(struct ethhdr) ||
  449. !skb_mac_header(skb)))
  450. goto err_free;
  451. if (!hard_iface->soft_iface)
  452. goto err_free;
  453. bat_priv = netdev_priv(hard_iface->soft_iface);
  454. if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
  455. goto err_free;
  456. /* discard frames on not active interfaces */
  457. if (hard_iface->if_status != IF_ACTIVE)
  458. goto err_free;
  459. batman_ogm_packet = (struct batman_ogm_packet *)skb->data;
  460. if (batman_ogm_packet->header.version != COMPAT_VERSION) {
  461. bat_dbg(DBG_BATMAN, bat_priv,
  462. "Drop packet: incompatible batman version (%i)\n",
  463. batman_ogm_packet->header.version);
  464. goto err_free;
  465. }
  466. /* all receive handlers return whether they received or reused
  467. * the supplied skb. if not, we have to free the skb. */
  468. switch (batman_ogm_packet->header.packet_type) {
  469. /* batman originator packet */
  470. case BAT_OGM:
  471. ret = recv_bat_ogm_packet(skb, hard_iface);
  472. break;
  473. /* batman icmp packet */
  474. case BAT_ICMP:
  475. ret = recv_icmp_packet(skb, hard_iface);
  476. break;
  477. /* unicast packet */
  478. case BAT_UNICAST:
  479. ret = recv_unicast_packet(skb, hard_iface);
  480. break;
  481. /* fragmented unicast packet */
  482. case BAT_UNICAST_FRAG:
  483. ret = recv_ucast_frag_packet(skb, hard_iface);
  484. break;
  485. /* broadcast packet */
  486. case BAT_BCAST:
  487. ret = recv_bcast_packet(skb, hard_iface);
  488. break;
  489. /* vis packet */
  490. case BAT_VIS:
  491. ret = recv_vis_packet(skb, hard_iface);
  492. break;
  493. /* Translation table query (request or response) */
  494. case BAT_TT_QUERY:
  495. ret = recv_tt_query(skb, hard_iface);
  496. break;
  497. /* Roaming advertisement */
  498. case BAT_ROAM_ADV:
  499. ret = recv_roam_adv(skb, hard_iface);
  500. break;
  501. default:
  502. ret = NET_RX_DROP;
  503. }
  504. if (ret == NET_RX_DROP)
  505. kfree_skb(skb);
  506. /* return NET_RX_SUCCESS in any case as we
  507. * most probably dropped the packet for
  508. * routing-logical reasons. */
  509. return NET_RX_SUCCESS;
  510. err_free:
  511. kfree_skb(skb);
  512. err_out:
  513. return NET_RX_DROP;
  514. }
  515. /* This function returns true if the interface represented by ifindex is a
  516. * 802.11 wireless device */
  517. bool is_wifi_iface(int ifindex)
  518. {
  519. struct net_device *net_device = NULL;
  520. bool ret = false;
  521. if (ifindex == NULL_IFINDEX)
  522. goto out;
  523. net_device = dev_get_by_index(&init_net, ifindex);
  524. if (!net_device)
  525. goto out;
  526. #ifdef CONFIG_WIRELESS_EXT
  527. /* pre-cfg80211 drivers have to implement WEXT, so it is possible to
  528. * check for wireless_handlers != NULL */
  529. if (net_device->wireless_handlers)
  530. ret = true;
  531. else
  532. #endif
  533. /* cfg80211 drivers have to set ieee80211_ptr */
  534. if (net_device->ieee80211_ptr)
  535. ret = true;
  536. out:
  537. if (net_device)
  538. dev_put(net_device);
  539. return ret;
  540. }
  541. struct notifier_block hard_if_notifier = {
  542. .notifier_call = hard_if_event,
  543. };