main.c 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185
  1. /* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
  2. *
  3. * Marek Lindner, Simon Wunderlich
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of version 2 of the GNU General Public
  7. * License as published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it will be useful, but
  10. * WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. * 02110-1301, USA
  18. */
  19. #include <linux/crc32c.h>
  20. #include <linux/highmem.h>
  21. #include <linux/if_vlan.h>
  22. #include <net/ip.h>
  23. #include <net/ipv6.h>
  24. #include <net/dsfield.h>
  25. #include "main.h"
  26. #include "sysfs.h"
  27. #include "debugfs.h"
  28. #include "routing.h"
  29. #include "send.h"
  30. #include "originator.h"
  31. #include "soft-interface.h"
  32. #include "icmp_socket.h"
  33. #include "translation-table.h"
  34. #include "hard-interface.h"
  35. #include "gateway_client.h"
  36. #include "bridge_loop_avoidance.h"
  37. #include "distributed-arp-table.h"
  38. #include "gateway_common.h"
  39. #include "hash.h"
  40. #include "bat_algo.h"
  41. #include "network-coding.h"
  42. #include "fragmentation.h"
  43. /* List manipulations on hardif_list have to be rtnl_lock()'ed,
  44. * list traversals just rcu-locked
  45. */
  46. struct list_head batadv_hardif_list;
  47. static int (*batadv_rx_handler[256])(struct sk_buff *,
  48. struct batadv_hard_iface *);
  49. char batadv_routing_algo[20] = "BATMAN_IV";
  50. static struct hlist_head batadv_algo_list;
  51. unsigned char batadv_broadcast_addr[] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
  52. struct workqueue_struct *batadv_event_workqueue;
  53. static void batadv_recv_handler_init(void);
  54. static int __init batadv_init(void)
  55. {
  56. INIT_LIST_HEAD(&batadv_hardif_list);
  57. INIT_HLIST_HEAD(&batadv_algo_list);
  58. batadv_recv_handler_init();
  59. batadv_iv_init();
  60. batadv_nc_init();
  61. batadv_event_workqueue = create_singlethread_workqueue("bat_events");
  62. if (!batadv_event_workqueue)
  63. return -ENOMEM;
  64. batadv_socket_init();
  65. batadv_debugfs_init();
  66. register_netdevice_notifier(&batadv_hard_if_notifier);
  67. rtnl_link_register(&batadv_link_ops);
  68. pr_info("B.A.T.M.A.N. advanced %s (compatibility version %i) loaded\n",
  69. BATADV_SOURCE_VERSION, BATADV_COMPAT_VERSION);
  70. return 0;
  71. }
  72. static void __exit batadv_exit(void)
  73. {
  74. batadv_debugfs_destroy();
  75. rtnl_link_unregister(&batadv_link_ops);
  76. unregister_netdevice_notifier(&batadv_hard_if_notifier);
  77. batadv_hardif_remove_interfaces();
  78. flush_workqueue(batadv_event_workqueue);
  79. destroy_workqueue(batadv_event_workqueue);
  80. batadv_event_workqueue = NULL;
  81. rcu_barrier();
  82. }
  83. int batadv_mesh_init(struct net_device *soft_iface)
  84. {
  85. struct batadv_priv *bat_priv = netdev_priv(soft_iface);
  86. int ret;
  87. spin_lock_init(&bat_priv->forw_bat_list_lock);
  88. spin_lock_init(&bat_priv->forw_bcast_list_lock);
  89. spin_lock_init(&bat_priv->tt.changes_list_lock);
  90. spin_lock_init(&bat_priv->tt.req_list_lock);
  91. spin_lock_init(&bat_priv->tt.roam_list_lock);
  92. spin_lock_init(&bat_priv->tt.last_changeset_lock);
  93. spin_lock_init(&bat_priv->gw.list_lock);
  94. spin_lock_init(&bat_priv->tvlv.container_list_lock);
  95. spin_lock_init(&bat_priv->tvlv.handler_list_lock);
  96. INIT_HLIST_HEAD(&bat_priv->forw_bat_list);
  97. INIT_HLIST_HEAD(&bat_priv->forw_bcast_list);
  98. INIT_HLIST_HEAD(&bat_priv->gw.list);
  99. INIT_LIST_HEAD(&bat_priv->tt.changes_list);
  100. INIT_LIST_HEAD(&bat_priv->tt.req_list);
  101. INIT_LIST_HEAD(&bat_priv->tt.roam_list);
  102. INIT_HLIST_HEAD(&bat_priv->tvlv.container_list);
  103. INIT_HLIST_HEAD(&bat_priv->tvlv.handler_list);
  104. ret = batadv_originator_init(bat_priv);
  105. if (ret < 0)
  106. goto err;
  107. ret = batadv_tt_init(bat_priv);
  108. if (ret < 0)
  109. goto err;
  110. batadv_tt_local_add(soft_iface, soft_iface->dev_addr,
  111. BATADV_NULL_IFINDEX);
  112. ret = batadv_bla_init(bat_priv);
  113. if (ret < 0)
  114. goto err;
  115. ret = batadv_dat_init(bat_priv);
  116. if (ret < 0)
  117. goto err;
  118. ret = batadv_nc_mesh_init(bat_priv);
  119. if (ret < 0)
  120. goto err;
  121. batadv_gw_init(bat_priv);
  122. atomic_set(&bat_priv->gw.reselect, 0);
  123. atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE);
  124. return 0;
  125. err:
  126. batadv_mesh_free(soft_iface);
  127. return ret;
  128. }
  129. void batadv_mesh_free(struct net_device *soft_iface)
  130. {
  131. struct batadv_priv *bat_priv = netdev_priv(soft_iface);
  132. atomic_set(&bat_priv->mesh_state, BATADV_MESH_DEACTIVATING);
  133. batadv_purge_outstanding_packets(bat_priv, NULL);
  134. batadv_gw_node_purge(bat_priv);
  135. batadv_nc_mesh_free(bat_priv);
  136. batadv_dat_free(bat_priv);
  137. batadv_bla_free(bat_priv);
  138. /* Free the TT and the originator tables only after having terminated
  139. * all the other depending components which may use these structures for
  140. * their purposes.
  141. */
  142. batadv_tt_free(bat_priv);
  143. /* Since the originator table clean up routine is accessing the TT
  144. * tables as well, it has to be invoked after the TT tables have been
  145. * freed and marked as empty. This ensures that no cleanup RCU callbacks
  146. * accessing the TT data are scheduled for later execution.
  147. */
  148. batadv_originator_free(bat_priv);
  149. batadv_gw_free(bat_priv);
  150. free_percpu(bat_priv->bat_counters);
  151. bat_priv->bat_counters = NULL;
  152. atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
  153. }
  154. /**
  155. * batadv_is_my_mac - check if the given mac address belongs to any of the real
  156. * interfaces in the current mesh
  157. * @bat_priv: the bat priv with all the soft interface information
  158. * @addr: the address to check
  159. */
  160. int batadv_is_my_mac(struct batadv_priv *bat_priv, const uint8_t *addr)
  161. {
  162. const struct batadv_hard_iface *hard_iface;
  163. rcu_read_lock();
  164. list_for_each_entry_rcu(hard_iface, &batadv_hardif_list, list) {
  165. if (hard_iface->if_status != BATADV_IF_ACTIVE)
  166. continue;
  167. if (hard_iface->soft_iface != bat_priv->soft_iface)
  168. continue;
  169. if (batadv_compare_eth(hard_iface->net_dev->dev_addr, addr)) {
  170. rcu_read_unlock();
  171. return 1;
  172. }
  173. }
  174. rcu_read_unlock();
  175. return 0;
  176. }
  177. /**
  178. * batadv_seq_print_text_primary_if_get - called from debugfs table printing
  179. * function that requires the primary interface
  180. * @seq: debugfs table seq_file struct
  181. *
  182. * Returns primary interface if found or NULL otherwise.
  183. */
  184. struct batadv_hard_iface *
  185. batadv_seq_print_text_primary_if_get(struct seq_file *seq)
  186. {
  187. struct net_device *net_dev = (struct net_device *)seq->private;
  188. struct batadv_priv *bat_priv = netdev_priv(net_dev);
  189. struct batadv_hard_iface *primary_if;
  190. primary_if = batadv_primary_if_get_selected(bat_priv);
  191. if (!primary_if) {
  192. seq_printf(seq,
  193. "BATMAN mesh %s disabled - please specify interfaces to enable it\n",
  194. net_dev->name);
  195. goto out;
  196. }
  197. if (primary_if->if_status == BATADV_IF_ACTIVE)
  198. goto out;
  199. seq_printf(seq,
  200. "BATMAN mesh %s disabled - primary interface not active\n",
  201. net_dev->name);
  202. batadv_hardif_free_ref(primary_if);
  203. primary_if = NULL;
  204. out:
  205. return primary_if;
  206. }
  207. /**
  208. * batadv_max_header_len - calculate maximum encapsulation overhead for a
  209. * payload packet
  210. *
  211. * Return the maximum encapsulation overhead in bytes.
  212. */
  213. int batadv_max_header_len(void)
  214. {
  215. int header_len = 0;
  216. header_len = max_t(int, header_len,
  217. sizeof(struct batadv_unicast_packet));
  218. header_len = max_t(int, header_len,
  219. sizeof(struct batadv_unicast_4addr_packet));
  220. header_len = max_t(int, header_len,
  221. sizeof(struct batadv_bcast_packet));
  222. #ifdef CONFIG_BATMAN_ADV_NC
  223. header_len = max_t(int, header_len,
  224. sizeof(struct batadv_coded_packet));
  225. #endif
  226. return header_len;
  227. }
  228. /**
  229. * batadv_skb_set_priority - sets skb priority according to packet content
  230. * @skb: the packet to be sent
  231. * @offset: offset to the packet content
  232. *
  233. * This function sets a value between 256 and 263 (802.1d priority), which
  234. * can be interpreted by the cfg80211 or other drivers.
  235. */
  236. void batadv_skb_set_priority(struct sk_buff *skb, int offset)
  237. {
  238. struct iphdr ip_hdr_tmp, *ip_hdr;
  239. struct ipv6hdr ip6_hdr_tmp, *ip6_hdr;
  240. struct ethhdr ethhdr_tmp, *ethhdr;
  241. struct vlan_ethhdr *vhdr, vhdr_tmp;
  242. u32 prio;
  243. /* already set, do nothing */
  244. if (skb->priority >= 256 && skb->priority <= 263)
  245. return;
  246. ethhdr = skb_header_pointer(skb, offset, sizeof(*ethhdr), &ethhdr_tmp);
  247. if (!ethhdr)
  248. return;
  249. switch (ethhdr->h_proto) {
  250. case htons(ETH_P_8021Q):
  251. vhdr = skb_header_pointer(skb, offset + sizeof(*vhdr),
  252. sizeof(*vhdr), &vhdr_tmp);
  253. if (!vhdr)
  254. return;
  255. prio = ntohs(vhdr->h_vlan_TCI) & VLAN_PRIO_MASK;
  256. prio = prio >> VLAN_PRIO_SHIFT;
  257. break;
  258. case htons(ETH_P_IP):
  259. ip_hdr = skb_header_pointer(skb, offset + sizeof(*ethhdr),
  260. sizeof(*ip_hdr), &ip_hdr_tmp);
  261. if (!ip_hdr)
  262. return;
  263. prio = (ipv4_get_dsfield(ip_hdr) & 0xfc) >> 5;
  264. break;
  265. case htons(ETH_P_IPV6):
  266. ip6_hdr = skb_header_pointer(skb, offset + sizeof(*ethhdr),
  267. sizeof(*ip6_hdr), &ip6_hdr_tmp);
  268. if (!ip6_hdr)
  269. return;
  270. prio = (ipv6_get_dsfield(ip6_hdr) & 0xfc) >> 5;
  271. break;
  272. default:
  273. return;
  274. }
  275. skb->priority = prio + 256;
  276. }
  277. static int batadv_recv_unhandled_packet(struct sk_buff *skb,
  278. struct batadv_hard_iface *recv_if)
  279. {
  280. return NET_RX_DROP;
  281. }
  282. /* incoming packets with the batman ethertype received on any active hard
  283. * interface
  284. */
  285. int batadv_batman_skb_recv(struct sk_buff *skb, struct net_device *dev,
  286. struct packet_type *ptype,
  287. struct net_device *orig_dev)
  288. {
  289. struct batadv_priv *bat_priv;
  290. struct batadv_ogm_packet *batadv_ogm_packet;
  291. struct batadv_hard_iface *hard_iface;
  292. uint8_t idx;
  293. int ret;
  294. hard_iface = container_of(ptype, struct batadv_hard_iface,
  295. batman_adv_ptype);
  296. skb = skb_share_check(skb, GFP_ATOMIC);
  297. /* skb was released by skb_share_check() */
  298. if (!skb)
  299. goto err_out;
  300. /* packet should hold at least type and version */
  301. if (unlikely(!pskb_may_pull(skb, 2)))
  302. goto err_free;
  303. /* expect a valid ethernet header here. */
  304. if (unlikely(skb->mac_len != ETH_HLEN || !skb_mac_header(skb)))
  305. goto err_free;
  306. if (!hard_iface->soft_iface)
  307. goto err_free;
  308. bat_priv = netdev_priv(hard_iface->soft_iface);
  309. if (atomic_read(&bat_priv->mesh_state) != BATADV_MESH_ACTIVE)
  310. goto err_free;
  311. /* discard frames on not active interfaces */
  312. if (hard_iface->if_status != BATADV_IF_ACTIVE)
  313. goto err_free;
  314. batadv_ogm_packet = (struct batadv_ogm_packet *)skb->data;
  315. if (batadv_ogm_packet->header.version != BATADV_COMPAT_VERSION) {
  316. batadv_dbg(BATADV_DBG_BATMAN, bat_priv,
  317. "Drop packet: incompatible batman version (%i)\n",
  318. batadv_ogm_packet->header.version);
  319. goto err_free;
  320. }
  321. /* all receive handlers return whether they received or reused
  322. * the supplied skb. if not, we have to free the skb.
  323. */
  324. idx = batadv_ogm_packet->header.packet_type;
  325. ret = (*batadv_rx_handler[idx])(skb, hard_iface);
  326. if (ret == NET_RX_DROP)
  327. kfree_skb(skb);
  328. /* return NET_RX_SUCCESS in any case as we
  329. * most probably dropped the packet for
  330. * routing-logical reasons.
  331. */
  332. return NET_RX_SUCCESS;
  333. err_free:
  334. kfree_skb(skb);
  335. err_out:
  336. return NET_RX_DROP;
  337. }
  338. static void batadv_recv_handler_init(void)
  339. {
  340. int i;
  341. for (i = 0; i < ARRAY_SIZE(batadv_rx_handler); i++)
  342. batadv_rx_handler[i] = batadv_recv_unhandled_packet;
  343. for (i = BATADV_UNICAST_MIN; i <= BATADV_UNICAST_MAX; i++)
  344. batadv_rx_handler[i] = batadv_recv_unhandled_unicast_packet;
  345. /* compile time checks for struct member offsets */
  346. BUILD_BUG_ON(offsetof(struct batadv_unicast_4addr_packet, src) != 10);
  347. BUILD_BUG_ON(offsetof(struct batadv_unicast_packet, dest) != 4);
  348. BUILD_BUG_ON(offsetof(struct batadv_unicast_tvlv_packet, dst) != 4);
  349. BUILD_BUG_ON(offsetof(struct batadv_frag_packet, dest) != 4);
  350. BUILD_BUG_ON(offsetof(struct batadv_icmp_packet, icmph.dst) != 4);
  351. BUILD_BUG_ON(offsetof(struct batadv_icmp_packet_rr, icmph.dst) != 4);
  352. /* broadcast packet */
  353. batadv_rx_handler[BATADV_BCAST] = batadv_recv_bcast_packet;
  354. /* unicast packets ... */
  355. /* unicast with 4 addresses packet */
  356. batadv_rx_handler[BATADV_UNICAST_4ADDR] = batadv_recv_unicast_packet;
  357. /* unicast packet */
  358. batadv_rx_handler[BATADV_UNICAST] = batadv_recv_unicast_packet;
  359. /* unicast tvlv packet */
  360. batadv_rx_handler[BATADV_UNICAST_TVLV] = batadv_recv_unicast_tvlv;
  361. /* batman icmp packet */
  362. batadv_rx_handler[BATADV_ICMP] = batadv_recv_icmp_packet;
  363. /* Fragmented packets */
  364. batadv_rx_handler[BATADV_UNICAST_FRAG] = batadv_recv_frag_packet;
  365. }
  366. int
  367. batadv_recv_handler_register(uint8_t packet_type,
  368. int (*recv_handler)(struct sk_buff *,
  369. struct batadv_hard_iface *))
  370. {
  371. int (*curr)(struct sk_buff *,
  372. struct batadv_hard_iface *);
  373. curr = batadv_rx_handler[packet_type];
  374. if ((curr != batadv_recv_unhandled_packet) &&
  375. (curr != batadv_recv_unhandled_unicast_packet))
  376. return -EBUSY;
  377. batadv_rx_handler[packet_type] = recv_handler;
  378. return 0;
  379. }
  380. void batadv_recv_handler_unregister(uint8_t packet_type)
  381. {
  382. batadv_rx_handler[packet_type] = batadv_recv_unhandled_packet;
  383. }
  384. static struct batadv_algo_ops *batadv_algo_get(char *name)
  385. {
  386. struct batadv_algo_ops *bat_algo_ops = NULL, *bat_algo_ops_tmp;
  387. hlist_for_each_entry(bat_algo_ops_tmp, &batadv_algo_list, list) {
  388. if (strcmp(bat_algo_ops_tmp->name, name) != 0)
  389. continue;
  390. bat_algo_ops = bat_algo_ops_tmp;
  391. break;
  392. }
  393. return bat_algo_ops;
  394. }
  395. int batadv_algo_register(struct batadv_algo_ops *bat_algo_ops)
  396. {
  397. struct batadv_algo_ops *bat_algo_ops_tmp;
  398. int ret;
  399. bat_algo_ops_tmp = batadv_algo_get(bat_algo_ops->name);
  400. if (bat_algo_ops_tmp) {
  401. pr_info("Trying to register already registered routing algorithm: %s\n",
  402. bat_algo_ops->name);
  403. ret = -EEXIST;
  404. goto out;
  405. }
  406. /* all algorithms must implement all ops (for now) */
  407. if (!bat_algo_ops->bat_iface_enable ||
  408. !bat_algo_ops->bat_iface_disable ||
  409. !bat_algo_ops->bat_iface_update_mac ||
  410. !bat_algo_ops->bat_primary_iface_set ||
  411. !bat_algo_ops->bat_ogm_schedule ||
  412. !bat_algo_ops->bat_ogm_emit) {
  413. pr_info("Routing algo '%s' does not implement required ops\n",
  414. bat_algo_ops->name);
  415. ret = -EINVAL;
  416. goto out;
  417. }
  418. INIT_HLIST_NODE(&bat_algo_ops->list);
  419. hlist_add_head(&bat_algo_ops->list, &batadv_algo_list);
  420. ret = 0;
  421. out:
  422. return ret;
  423. }
  424. int batadv_algo_select(struct batadv_priv *bat_priv, char *name)
  425. {
  426. struct batadv_algo_ops *bat_algo_ops;
  427. int ret = -EINVAL;
  428. bat_algo_ops = batadv_algo_get(name);
  429. if (!bat_algo_ops)
  430. goto out;
  431. bat_priv->bat_algo_ops = bat_algo_ops;
  432. ret = 0;
  433. out:
  434. return ret;
  435. }
  436. int batadv_algo_seq_print_text(struct seq_file *seq, void *offset)
  437. {
  438. struct batadv_algo_ops *bat_algo_ops;
  439. seq_puts(seq, "Available routing algorithms:\n");
  440. hlist_for_each_entry(bat_algo_ops, &batadv_algo_list, list) {
  441. seq_printf(seq, "%s\n", bat_algo_ops->name);
  442. }
  443. return 0;
  444. }
  445. /**
  446. * batadv_skb_crc32 - calculate CRC32 of the whole packet and skip bytes in
  447. * the header
  448. * @skb: skb pointing to fragmented socket buffers
  449. * @payload_ptr: Pointer to position inside the head buffer of the skb
  450. * marking the start of the data to be CRC'ed
  451. *
  452. * payload_ptr must always point to an address in the skb head buffer and not to
  453. * a fragment.
  454. */
  455. __be32 batadv_skb_crc32(struct sk_buff *skb, u8 *payload_ptr)
  456. {
  457. u32 crc = 0;
  458. unsigned int from;
  459. unsigned int to = skb->len;
  460. struct skb_seq_state st;
  461. const u8 *data;
  462. unsigned int len;
  463. unsigned int consumed = 0;
  464. from = (unsigned int)(payload_ptr - skb->data);
  465. skb_prepare_seq_read(skb, from, to, &st);
  466. while ((len = skb_seq_read(consumed, &data, &st)) != 0) {
  467. crc = crc32c(crc, data, len);
  468. consumed += len;
  469. }
  470. return htonl(crc);
  471. }
  472. /**
  473. * batadv_tvlv_handler_free_ref - decrement the tvlv handler refcounter and
  474. * possibly free it
  475. * @tvlv_handler: the tvlv handler to free
  476. */
  477. static void
  478. batadv_tvlv_handler_free_ref(struct batadv_tvlv_handler *tvlv_handler)
  479. {
  480. if (atomic_dec_and_test(&tvlv_handler->refcount))
  481. kfree_rcu(tvlv_handler, rcu);
  482. }
  483. /**
  484. * batadv_tvlv_handler_get - retrieve tvlv handler from the tvlv handler list
  485. * based on the provided type and version (both need to match)
  486. * @bat_priv: the bat priv with all the soft interface information
  487. * @type: tvlv handler type to look for
  488. * @version: tvlv handler version to look for
  489. *
  490. * Returns tvlv handler if found or NULL otherwise.
  491. */
  492. static struct batadv_tvlv_handler
  493. *batadv_tvlv_handler_get(struct batadv_priv *bat_priv,
  494. uint8_t type, uint8_t version)
  495. {
  496. struct batadv_tvlv_handler *tvlv_handler_tmp, *tvlv_handler = NULL;
  497. rcu_read_lock();
  498. hlist_for_each_entry_rcu(tvlv_handler_tmp,
  499. &bat_priv->tvlv.handler_list, list) {
  500. if (tvlv_handler_tmp->type != type)
  501. continue;
  502. if (tvlv_handler_tmp->version != version)
  503. continue;
  504. if (!atomic_inc_not_zero(&tvlv_handler_tmp->refcount))
  505. continue;
  506. tvlv_handler = tvlv_handler_tmp;
  507. break;
  508. }
  509. rcu_read_unlock();
  510. return tvlv_handler;
  511. }
  512. /**
  513. * batadv_tvlv_container_free_ref - decrement the tvlv container refcounter and
  514. * possibly free it
  515. * @tvlv_handler: the tvlv container to free
  516. */
  517. static void batadv_tvlv_container_free_ref(struct batadv_tvlv_container *tvlv)
  518. {
  519. if (atomic_dec_and_test(&tvlv->refcount))
  520. kfree(tvlv);
  521. }
  522. /**
  523. * batadv_tvlv_container_get - retrieve tvlv container from the tvlv container
  524. * list based on the provided type and version (both need to match)
  525. * @bat_priv: the bat priv with all the soft interface information
  526. * @type: tvlv container type to look for
  527. * @version: tvlv container version to look for
  528. *
  529. * Has to be called with the appropriate locks being acquired
  530. * (tvlv.container_list_lock).
  531. *
  532. * Returns tvlv container if found or NULL otherwise.
  533. */
  534. static struct batadv_tvlv_container
  535. *batadv_tvlv_container_get(struct batadv_priv *bat_priv,
  536. uint8_t type, uint8_t version)
  537. {
  538. struct batadv_tvlv_container *tvlv_tmp, *tvlv = NULL;
  539. hlist_for_each_entry(tvlv_tmp, &bat_priv->tvlv.container_list, list) {
  540. if (tvlv_tmp->tvlv_hdr.type != type)
  541. continue;
  542. if (tvlv_tmp->tvlv_hdr.version != version)
  543. continue;
  544. if (!atomic_inc_not_zero(&tvlv_tmp->refcount))
  545. continue;
  546. tvlv = tvlv_tmp;
  547. break;
  548. }
  549. return tvlv;
  550. }
  551. /**
  552. * batadv_tvlv_container_list_size - calculate the size of the tvlv container
  553. * list entries
  554. * @bat_priv: the bat priv with all the soft interface information
  555. *
  556. * Has to be called with the appropriate locks being acquired
  557. * (tvlv.container_list_lock).
  558. *
  559. * Returns size of all currently registered tvlv containers in bytes.
  560. */
  561. static uint16_t batadv_tvlv_container_list_size(struct batadv_priv *bat_priv)
  562. {
  563. struct batadv_tvlv_container *tvlv;
  564. uint16_t tvlv_len = 0;
  565. hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) {
  566. tvlv_len += sizeof(struct batadv_tvlv_hdr);
  567. tvlv_len += ntohs(tvlv->tvlv_hdr.len);
  568. }
  569. return tvlv_len;
  570. }
  571. /**
  572. * batadv_tvlv_container_remove - remove tvlv container from the tvlv container
  573. * list
  574. * @tvlv: the to be removed tvlv container
  575. *
  576. * Has to be called with the appropriate locks being acquired
  577. * (tvlv.container_list_lock).
  578. */
  579. static void batadv_tvlv_container_remove(struct batadv_tvlv_container *tvlv)
  580. {
  581. if (!tvlv)
  582. return;
  583. hlist_del(&tvlv->list);
  584. /* first call to decrement the counter, second call to free */
  585. batadv_tvlv_container_free_ref(tvlv);
  586. batadv_tvlv_container_free_ref(tvlv);
  587. }
  588. /**
  589. * batadv_tvlv_container_unregister - unregister tvlv container based on the
  590. * provided type and version (both need to match)
  591. * @bat_priv: the bat priv with all the soft interface information
  592. * @type: tvlv container type to unregister
  593. * @version: tvlv container type to unregister
  594. */
  595. void batadv_tvlv_container_unregister(struct batadv_priv *bat_priv,
  596. uint8_t type, uint8_t version)
  597. {
  598. struct batadv_tvlv_container *tvlv;
  599. spin_lock_bh(&bat_priv->tvlv.container_list_lock);
  600. tvlv = batadv_tvlv_container_get(bat_priv, type, version);
  601. batadv_tvlv_container_remove(tvlv);
  602. spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
  603. }
  604. /**
  605. * batadv_tvlv_container_register - register tvlv type, version and content
  606. * to be propagated with each (primary interface) OGM
  607. * @bat_priv: the bat priv with all the soft interface information
  608. * @type: tvlv container type
  609. * @version: tvlv container version
  610. * @tvlv_value: tvlv container content
  611. * @tvlv_value_len: tvlv container content length
  612. *
  613. * If a container of the same type and version was already registered the new
  614. * content is going to replace the old one.
  615. */
  616. void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
  617. uint8_t type, uint8_t version,
  618. void *tvlv_value, uint16_t tvlv_value_len)
  619. {
  620. struct batadv_tvlv_container *tvlv_old, *tvlv_new;
  621. if (!tvlv_value)
  622. tvlv_value_len = 0;
  623. tvlv_new = kzalloc(sizeof(*tvlv_new) + tvlv_value_len, GFP_ATOMIC);
  624. if (!tvlv_new)
  625. return;
  626. tvlv_new->tvlv_hdr.version = version;
  627. tvlv_new->tvlv_hdr.type = type;
  628. tvlv_new->tvlv_hdr.len = htons(tvlv_value_len);
  629. memcpy(tvlv_new + 1, tvlv_value, ntohs(tvlv_new->tvlv_hdr.len));
  630. INIT_HLIST_NODE(&tvlv_new->list);
  631. atomic_set(&tvlv_new->refcount, 1);
  632. spin_lock_bh(&bat_priv->tvlv.container_list_lock);
  633. tvlv_old = batadv_tvlv_container_get(bat_priv, type, version);
  634. batadv_tvlv_container_remove(tvlv_old);
  635. hlist_add_head(&tvlv_new->list, &bat_priv->tvlv.container_list);
  636. spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
  637. }
  638. /**
  639. * batadv_tvlv_realloc_packet_buff - reallocate packet buffer to accomodate
  640. * requested packet size
  641. * @packet_buff: packet buffer
  642. * @packet_buff_len: packet buffer size
  643. * @packet_min_len: requested packet minimum size
  644. * @additional_packet_len: requested additional packet size on top of minimum
  645. * size
  646. *
  647. * Returns true of the packet buffer could be changed to the requested size,
  648. * false otherwise.
  649. */
  650. static bool batadv_tvlv_realloc_packet_buff(unsigned char **packet_buff,
  651. int *packet_buff_len,
  652. int min_packet_len,
  653. int additional_packet_len)
  654. {
  655. unsigned char *new_buff;
  656. new_buff = kmalloc(min_packet_len + additional_packet_len, GFP_ATOMIC);
  657. /* keep old buffer if kmalloc should fail */
  658. if (new_buff) {
  659. memcpy(new_buff, *packet_buff, min_packet_len);
  660. kfree(*packet_buff);
  661. *packet_buff = new_buff;
  662. *packet_buff_len = min_packet_len + additional_packet_len;
  663. return true;
  664. }
  665. return false;
  666. }
  667. /**
  668. * batadv_tvlv_container_ogm_append - append tvlv container content to given
  669. * OGM packet buffer
  670. * @bat_priv: the bat priv with all the soft interface information
  671. * @packet_buff: ogm packet buffer
  672. * @packet_buff_len: ogm packet buffer size including ogm header and tvlv
  673. * content
  674. * @packet_min_len: ogm header size to be preserved for the OGM itself
  675. *
  676. * The ogm packet might be enlarged or shrunk depending on the current size
  677. * and the size of the to-be-appended tvlv containers.
  678. *
  679. * Returns size of all appended tvlv containers in bytes.
  680. */
  681. uint16_t batadv_tvlv_container_ogm_append(struct batadv_priv *bat_priv,
  682. unsigned char **packet_buff,
  683. int *packet_buff_len,
  684. int packet_min_len)
  685. {
  686. struct batadv_tvlv_container *tvlv;
  687. struct batadv_tvlv_hdr *tvlv_hdr;
  688. uint16_t tvlv_value_len;
  689. void *tvlv_value;
  690. bool ret;
  691. spin_lock_bh(&bat_priv->tvlv.container_list_lock);
  692. tvlv_value_len = batadv_tvlv_container_list_size(bat_priv);
  693. ret = batadv_tvlv_realloc_packet_buff(packet_buff, packet_buff_len,
  694. packet_min_len, tvlv_value_len);
  695. if (!ret)
  696. goto end;
  697. if (!tvlv_value_len)
  698. goto end;
  699. tvlv_value = (*packet_buff) + packet_min_len;
  700. hlist_for_each_entry(tvlv, &bat_priv->tvlv.container_list, list) {
  701. tvlv_hdr = tvlv_value;
  702. tvlv_hdr->type = tvlv->tvlv_hdr.type;
  703. tvlv_hdr->version = tvlv->tvlv_hdr.version;
  704. tvlv_hdr->len = tvlv->tvlv_hdr.len;
  705. tvlv_value = tvlv_hdr + 1;
  706. memcpy(tvlv_value, tvlv + 1, ntohs(tvlv->tvlv_hdr.len));
  707. tvlv_value = (uint8_t *)tvlv_value + ntohs(tvlv->tvlv_hdr.len);
  708. }
  709. end:
  710. spin_unlock_bh(&bat_priv->tvlv.container_list_lock);
  711. return tvlv_value_len;
  712. }
  713. /**
  714. * batadv_tvlv_call_handler - parse the given tvlv buffer to call the
  715. * appropriate handlers
  716. * @bat_priv: the bat priv with all the soft interface information
  717. * @tvlv_handler: tvlv callback function handling the tvlv content
  718. * @ogm_source: flag indicating wether the tvlv is an ogm or a unicast packet
  719. * @orig_node: orig node emitting the ogm packet
  720. * @src: source mac address of the unicast packet
  721. * @dst: destination mac address of the unicast packet
  722. * @tvlv_value: tvlv content
  723. * @tvlv_value_len: tvlv content length
  724. *
  725. * Returns success if handler was not found or the return value of the handler
  726. * callback.
  727. */
  728. static int batadv_tvlv_call_handler(struct batadv_priv *bat_priv,
  729. struct batadv_tvlv_handler *tvlv_handler,
  730. bool ogm_source,
  731. struct batadv_orig_node *orig_node,
  732. uint8_t *src, uint8_t *dst,
  733. void *tvlv_value, uint16_t tvlv_value_len)
  734. {
  735. if (!tvlv_handler)
  736. return NET_RX_SUCCESS;
  737. if (ogm_source) {
  738. if (!tvlv_handler->ogm_handler)
  739. return NET_RX_SUCCESS;
  740. if (!orig_node)
  741. return NET_RX_SUCCESS;
  742. tvlv_handler->ogm_handler(bat_priv, orig_node,
  743. BATADV_NO_FLAGS,
  744. tvlv_value, tvlv_value_len);
  745. tvlv_handler->flags |= BATADV_TVLV_HANDLER_OGM_CALLED;
  746. } else {
  747. if (!src)
  748. return NET_RX_SUCCESS;
  749. if (!dst)
  750. return NET_RX_SUCCESS;
  751. if (!tvlv_handler->unicast_handler)
  752. return NET_RX_SUCCESS;
  753. return tvlv_handler->unicast_handler(bat_priv, src,
  754. dst, tvlv_value,
  755. tvlv_value_len);
  756. }
  757. return NET_RX_SUCCESS;
  758. }
  759. /**
  760. * batadv_tvlv_containers_process - parse the given tvlv buffer to call the
  761. * appropriate handlers
  762. * @bat_priv: the bat priv with all the soft interface information
  763. * @ogm_source: flag indicating wether the tvlv is an ogm or a unicast packet
  764. * @orig_node: orig node emitting the ogm packet
  765. * @src: source mac address of the unicast packet
  766. * @dst: destination mac address of the unicast packet
  767. * @tvlv_value: tvlv content
  768. * @tvlv_value_len: tvlv content length
  769. *
  770. * Returns success when processing an OGM or the return value of all called
  771. * handler callbacks.
  772. */
  773. int batadv_tvlv_containers_process(struct batadv_priv *bat_priv,
  774. bool ogm_source,
  775. struct batadv_orig_node *orig_node,
  776. uint8_t *src, uint8_t *dst,
  777. void *tvlv_value, uint16_t tvlv_value_len)
  778. {
  779. struct batadv_tvlv_handler *tvlv_handler;
  780. struct batadv_tvlv_hdr *tvlv_hdr;
  781. uint16_t tvlv_value_cont_len;
  782. uint8_t cifnotfound = BATADV_TVLV_HANDLER_OGM_CIFNOTFND;
  783. int ret = NET_RX_SUCCESS;
  784. while (tvlv_value_len >= sizeof(*tvlv_hdr)) {
  785. tvlv_hdr = tvlv_value;
  786. tvlv_value_cont_len = ntohs(tvlv_hdr->len);
  787. tvlv_value = tvlv_hdr + 1;
  788. tvlv_value_len -= sizeof(*tvlv_hdr);
  789. if (tvlv_value_cont_len > tvlv_value_len)
  790. break;
  791. tvlv_handler = batadv_tvlv_handler_get(bat_priv,
  792. tvlv_hdr->type,
  793. tvlv_hdr->version);
  794. ret |= batadv_tvlv_call_handler(bat_priv, tvlv_handler,
  795. ogm_source, orig_node,
  796. src, dst, tvlv_value,
  797. tvlv_value_cont_len);
  798. if (tvlv_handler)
  799. batadv_tvlv_handler_free_ref(tvlv_handler);
  800. tvlv_value = (uint8_t *)tvlv_value + tvlv_value_cont_len;
  801. tvlv_value_len -= tvlv_value_cont_len;
  802. }
  803. if (!ogm_source)
  804. return ret;
  805. rcu_read_lock();
  806. hlist_for_each_entry_rcu(tvlv_handler,
  807. &bat_priv->tvlv.handler_list, list) {
  808. if ((tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CIFNOTFND) &&
  809. !(tvlv_handler->flags & BATADV_TVLV_HANDLER_OGM_CALLED))
  810. tvlv_handler->ogm_handler(bat_priv, orig_node,
  811. cifnotfound, NULL, 0);
  812. tvlv_handler->flags &= ~BATADV_TVLV_HANDLER_OGM_CALLED;
  813. }
  814. rcu_read_unlock();
  815. return NET_RX_SUCCESS;
  816. }
  817. /**
  818. * batadv_tvlv_ogm_receive - process an incoming ogm and call the appropriate
  819. * handlers
  820. * @bat_priv: the bat priv with all the soft interface information
  821. * @batadv_ogm_packet: ogm packet containing the tvlv containers
  822. * @orig_node: orig node emitting the ogm packet
  823. */
  824. void batadv_tvlv_ogm_receive(struct batadv_priv *bat_priv,
  825. struct batadv_ogm_packet *batadv_ogm_packet,
  826. struct batadv_orig_node *orig_node)
  827. {
  828. void *tvlv_value;
  829. uint16_t tvlv_value_len;
  830. if (!batadv_ogm_packet)
  831. return;
  832. tvlv_value_len = ntohs(batadv_ogm_packet->tvlv_len);
  833. if (!tvlv_value_len)
  834. return;
  835. tvlv_value = batadv_ogm_packet + 1;
  836. batadv_tvlv_containers_process(bat_priv, true, orig_node, NULL, NULL,
  837. tvlv_value, tvlv_value_len);
  838. }
  839. /**
  840. * batadv_tvlv_handler_register - register tvlv handler based on the provided
  841. * type and version (both need to match) for ogm tvlv payload and/or unicast
  842. * payload
  843. * @bat_priv: the bat priv with all the soft interface information
  844. * @optr: ogm tvlv handler callback function. This function receives the orig
  845. * node, flags and the tvlv content as argument to process.
  846. * @uptr: unicast tvlv handler callback function. This function receives the
  847. * source & destination of the unicast packet as well as the tvlv content
  848. * to process.
  849. * @type: tvlv handler type to be registered
  850. * @version: tvlv handler version to be registered
  851. * @flags: flags to enable or disable TVLV API behavior
  852. */
  853. void batadv_tvlv_handler_register(struct batadv_priv *bat_priv,
  854. void (*optr)(struct batadv_priv *bat_priv,
  855. struct batadv_orig_node *orig,
  856. uint8_t flags,
  857. void *tvlv_value,
  858. uint16_t tvlv_value_len),
  859. int (*uptr)(struct batadv_priv *bat_priv,
  860. uint8_t *src, uint8_t *dst,
  861. void *tvlv_value,
  862. uint16_t tvlv_value_len),
  863. uint8_t type, uint8_t version, uint8_t flags)
  864. {
  865. struct batadv_tvlv_handler *tvlv_handler;
  866. tvlv_handler = batadv_tvlv_handler_get(bat_priv, type, version);
  867. if (tvlv_handler) {
  868. batadv_tvlv_handler_free_ref(tvlv_handler);
  869. return;
  870. }
  871. tvlv_handler = kzalloc(sizeof(*tvlv_handler), GFP_ATOMIC);
  872. if (!tvlv_handler)
  873. return;
  874. tvlv_handler->ogm_handler = optr;
  875. tvlv_handler->unicast_handler = uptr;
  876. tvlv_handler->type = type;
  877. tvlv_handler->version = version;
  878. tvlv_handler->flags = flags;
  879. atomic_set(&tvlv_handler->refcount, 1);
  880. INIT_HLIST_NODE(&tvlv_handler->list);
  881. spin_lock_bh(&bat_priv->tvlv.handler_list_lock);
  882. hlist_add_head_rcu(&tvlv_handler->list, &bat_priv->tvlv.handler_list);
  883. spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
  884. }
  885. /**
  886. * batadv_tvlv_handler_unregister - unregister tvlv handler based on the
  887. * provided type and version (both need to match)
  888. * @bat_priv: the bat priv with all the soft interface information
  889. * @type: tvlv handler type to be unregistered
  890. * @version: tvlv handler version to be unregistered
  891. */
  892. void batadv_tvlv_handler_unregister(struct batadv_priv *bat_priv,
  893. uint8_t type, uint8_t version)
  894. {
  895. struct batadv_tvlv_handler *tvlv_handler;
  896. tvlv_handler = batadv_tvlv_handler_get(bat_priv, type, version);
  897. if (!tvlv_handler)
  898. return;
  899. batadv_tvlv_handler_free_ref(tvlv_handler);
  900. spin_lock_bh(&bat_priv->tvlv.handler_list_lock);
  901. hlist_del_rcu(&tvlv_handler->list);
  902. spin_unlock_bh(&bat_priv->tvlv.handler_list_lock);
  903. batadv_tvlv_handler_free_ref(tvlv_handler);
  904. }
  905. /**
  906. * batadv_tvlv_unicast_send - send a unicast packet with tvlv payload to the
  907. * specified host
  908. * @bat_priv: the bat priv with all the soft interface information
  909. * @src: source mac address of the unicast packet
  910. * @dst: destination mac address of the unicast packet
  911. * @type: tvlv type
  912. * @version: tvlv version
  913. * @tvlv_value: tvlv content
  914. * @tvlv_value_len: tvlv content length
  915. */
  916. void batadv_tvlv_unicast_send(struct batadv_priv *bat_priv, uint8_t *src,
  917. uint8_t *dst, uint8_t type, uint8_t version,
  918. void *tvlv_value, uint16_t tvlv_value_len)
  919. {
  920. struct batadv_unicast_tvlv_packet *unicast_tvlv_packet;
  921. struct batadv_tvlv_hdr *tvlv_hdr;
  922. struct batadv_orig_node *orig_node;
  923. struct sk_buff *skb = NULL;
  924. unsigned char *tvlv_buff;
  925. unsigned int tvlv_len;
  926. ssize_t hdr_len = sizeof(*unicast_tvlv_packet);
  927. bool ret = false;
  928. orig_node = batadv_orig_hash_find(bat_priv, dst);
  929. if (!orig_node)
  930. goto out;
  931. tvlv_len = sizeof(*tvlv_hdr) + tvlv_value_len;
  932. skb = netdev_alloc_skb_ip_align(NULL, ETH_HLEN + hdr_len + tvlv_len);
  933. if (!skb)
  934. goto out;
  935. skb->priority = TC_PRIO_CONTROL;
  936. skb_reserve(skb, ETH_HLEN);
  937. tvlv_buff = skb_put(skb, sizeof(*unicast_tvlv_packet) + tvlv_len);
  938. unicast_tvlv_packet = (struct batadv_unicast_tvlv_packet *)tvlv_buff;
  939. unicast_tvlv_packet->header.packet_type = BATADV_UNICAST_TVLV;
  940. unicast_tvlv_packet->header.version = BATADV_COMPAT_VERSION;
  941. unicast_tvlv_packet->header.ttl = BATADV_TTL;
  942. unicast_tvlv_packet->reserved = 0;
  943. unicast_tvlv_packet->tvlv_len = htons(tvlv_len);
  944. unicast_tvlv_packet->align = 0;
  945. memcpy(unicast_tvlv_packet->src, src, ETH_ALEN);
  946. memcpy(unicast_tvlv_packet->dst, dst, ETH_ALEN);
  947. tvlv_buff = (unsigned char *)(unicast_tvlv_packet + 1);
  948. tvlv_hdr = (struct batadv_tvlv_hdr *)tvlv_buff;
  949. tvlv_hdr->version = version;
  950. tvlv_hdr->type = type;
  951. tvlv_hdr->len = htons(tvlv_value_len);
  952. tvlv_buff += sizeof(*tvlv_hdr);
  953. memcpy(tvlv_buff, tvlv_value, tvlv_value_len);
  954. if (batadv_send_skb_to_orig(skb, orig_node, NULL) != NET_XMIT_DROP)
  955. ret = true;
  956. out:
  957. if (skb && !ret)
  958. kfree_skb(skb);
  959. if (orig_node)
  960. batadv_orig_node_free_ref(orig_node);
  961. }
  962. static int batadv_param_set_ra(const char *val, const struct kernel_param *kp)
  963. {
  964. struct batadv_algo_ops *bat_algo_ops;
  965. char *algo_name = (char *)val;
  966. size_t name_len = strlen(algo_name);
  967. if (name_len > 0 && algo_name[name_len - 1] == '\n')
  968. algo_name[name_len - 1] = '\0';
  969. bat_algo_ops = batadv_algo_get(algo_name);
  970. if (!bat_algo_ops) {
  971. pr_err("Routing algorithm '%s' is not supported\n", algo_name);
  972. return -EINVAL;
  973. }
  974. return param_set_copystring(algo_name, kp);
  975. }
  976. static const struct kernel_param_ops batadv_param_ops_ra = {
  977. .set = batadv_param_set_ra,
  978. .get = param_get_string,
  979. };
  980. static struct kparam_string batadv_param_string_ra = {
  981. .maxlen = sizeof(batadv_routing_algo),
  982. .string = batadv_routing_algo,
  983. };
  984. module_param_cb(routing_algo, &batadv_param_ops_ra, &batadv_param_string_ra,
  985. 0644);
  986. module_init(batadv_init);
  987. module_exit(batadv_exit);
  988. MODULE_LICENSE("GPL");
  989. MODULE_AUTHOR(BATADV_DRIVER_AUTHOR);
  990. MODULE_DESCRIPTION(BATADV_DRIVER_DESC);
  991. MODULE_SUPPORTED_DEVICE(BATADV_DRIVER_DEVICE);
  992. MODULE_VERSION(BATADV_SOURCE_VERSION);