blob: f81a6b668b0c524d33f4f3b7794e2181a1897a9b [file] [log] [blame]
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00001/*
Sven Eckelmann64afe352011-01-27 10:38:15 +01002 * Copyright (C) 2008-2011 B.A.T.M.A.N. contributors:
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +00003 *
4 * 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
22#include "main.h"
23#include "send.h"
24#include "translation-table.h"
25#include "vis.h"
26#include "soft-interface.h"
27#include "hard-interface.h"
28#include "hash.h"
29#include "originator.h"
30
31#define MAX_VIS_PACKET_SIZE 1000
32
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000033static void start_vis_timer(struct bat_priv *bat_priv);
34
35/* free the info */
36static void free_info(struct kref *ref)
37{
38 struct vis_info *info = container_of(ref, struct vis_info, refcount);
39 struct bat_priv *bat_priv = info->bat_priv;
40 struct recvlist_node *entry, *tmp;
41
42 list_del_init(&info->send_list);
43 spin_lock_bh(&bat_priv->vis_list_lock);
44 list_for_each_entry_safe(entry, tmp, &info->recv_list, list) {
45 list_del(&entry->list);
46 kfree(entry);
47 }
48
49 spin_unlock_bh(&bat_priv->vis_list_lock);
50 kfree_skb(info->skb_packet);
Sven Eckelmanndda9fc62011-01-28 18:34:06 +010051 kfree(info);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000052}
53
54/* Compare two vis packets, used by the hashing algorithm */
Sven Eckelmann747e4222011-05-14 23:14:50 +020055static int vis_info_cmp(const struct hlist_node *node, const void *data2)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000056{
Sven Eckelmann747e4222011-05-14 23:14:50 +020057 const struct vis_info *d1, *d2;
58 const struct vis_packet *p1, *p2;
Marek Lindner7aadf882011-02-18 12:28:09 +000059
60 d1 = container_of(node, struct vis_info, hash_entry);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000061 d2 = data2;
62 p1 = (struct vis_packet *)d1->skb_packet->data;
63 p2 = (struct vis_packet *)d2->skb_packet->data;
Marek Lindner39901e72011-02-18 12:28:08 +000064 return compare_eth(p1->vis_orig, p2->vis_orig);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000065}
66
67/* hash function to choose an entry in a hash table of given size */
68/* hash algorithm from http://en.wikipedia.org/wiki/Hash_table */
Sven Eckelmann747e4222011-05-14 23:14:50 +020069static int vis_info_choose(const void *data, int size)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000070{
Sven Eckelmann747e4222011-05-14 23:14:50 +020071 const struct vis_info *vis_info = data;
72 const struct vis_packet *packet;
73 const unsigned char *key;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +000074 uint32_t hash = 0;
75 size_t i;
76
77 packet = (struct vis_packet *)vis_info->skb_packet->data;
78 key = packet->vis_orig;
79 for (i = 0; i < ETH_ALEN; i++) {
80 hash += key[i];
81 hash += (hash << 10);
82 hash ^= (hash >> 6);
83 }
84
85 hash += (hash << 3);
86 hash ^= (hash >> 11);
87 hash += (hash << 15);
88
89 return hash % size;
90}
91
Marek Lindner7aadf882011-02-18 12:28:09 +000092static struct vis_info *vis_hash_find(struct bat_priv *bat_priv,
Sven Eckelmann747e4222011-05-14 23:14:50 +020093 const void *data)
Marek Lindner7aadf882011-02-18 12:28:09 +000094{
95 struct hashtable_t *hash = bat_priv->vis_hash;
96 struct hlist_head *head;
97 struct hlist_node *node;
98 struct vis_info *vis_info, *vis_info_tmp = NULL;
99 int index;
100
101 if (!hash)
102 return NULL;
103
104 index = vis_info_choose(data, hash->size);
105 head = &hash->table[index];
106
107 rcu_read_lock();
108 hlist_for_each_entry_rcu(vis_info, node, head, hash_entry) {
109 if (!vis_info_cmp(node, data))
110 continue;
111
112 vis_info_tmp = vis_info;
113 break;
114 }
115 rcu_read_unlock();
116
117 return vis_info_tmp;
118}
119
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000120/* insert interface to the list of interfaces of one originator, if it
121 * does not already exist in the list */
122static void vis_data_insert_interface(const uint8_t *interface,
123 struct hlist_head *if_list,
124 bool primary)
125{
126 struct if_list_entry *entry;
127 struct hlist_node *pos;
128
129 hlist_for_each_entry(entry, pos, if_list, list) {
Sven Eckelmann747e4222011-05-14 23:14:50 +0200130 if (compare_eth(entry->addr, interface))
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000131 return;
132 }
133
Antonio Quartulli015758d2011-07-09 17:52:13 +0200134 /* it's a new address, add it to the list */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000135 entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
136 if (!entry)
137 return;
138 memcpy(entry->addr, interface, ETH_ALEN);
139 entry->primary = primary;
140 hlist_add_head(&entry->list, if_list);
141}
142
Sven Eckelmann747e4222011-05-14 23:14:50 +0200143static ssize_t vis_data_read_prim_sec(char *buff,
144 const struct hlist_head *if_list)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000145{
146 struct if_list_entry *entry;
147 struct hlist_node *pos;
148 size_t len = 0;
149
150 hlist_for_each_entry(entry, pos, if_list, list) {
151 if (entry->primary)
152 len += sprintf(buff + len, "PRIMARY, ");
153 else
154 len += sprintf(buff + len, "SEC %pM, ", entry->addr);
155 }
156
157 return len;
158}
159
160static size_t vis_data_count_prim_sec(struct hlist_head *if_list)
161{
162 struct if_list_entry *entry;
163 struct hlist_node *pos;
164 size_t count = 0;
165
166 hlist_for_each_entry(entry, pos, if_list, list) {
167 if (entry->primary)
168 count += 9;
169 else
170 count += 23;
171 }
172
173 return count;
174}
175
176/* read an entry */
Sven Eckelmann747e4222011-05-14 23:14:50 +0200177static ssize_t vis_data_read_entry(char *buff,
178 const struct vis_info_entry *entry,
179 const uint8_t *src, bool primary)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000180{
181 /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */
182 if (primary && entry->quality == 0)
Antonio Quartulli2dafb492011-05-05 08:42:45 +0200183 return sprintf(buff, "TT %pM, ", entry->dest);
Marek Lindner39901e72011-02-18 12:28:08 +0000184 else if (compare_eth(entry->src, src))
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000185 return sprintf(buff, "TQ %pM %d, ", entry->dest,
186 entry->quality);
187
188 return 0;
189}
190
191int vis_seq_print_text(struct seq_file *seq, void *offset)
192{
Marek Lindner32ae9b22011-04-20 15:40:58 +0200193 struct hard_iface *primary_if;
Marek Lindner7aadf882011-02-18 12:28:09 +0000194 struct hlist_node *node;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000195 struct hlist_head *head;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000196 struct vis_info *info;
197 struct vis_packet *packet;
198 struct vis_info_entry *entries;
199 struct net_device *net_dev = (struct net_device *)seq->private;
200 struct bat_priv *bat_priv = netdev_priv(net_dev);
201 struct hashtable_t *hash = bat_priv->vis_hash;
202 HLIST_HEAD(vis_if_list);
203 struct if_list_entry *entry;
204 struct hlist_node *pos, *n;
Marek Lindner32ae9b22011-04-20 15:40:58 +0200205 int i, j, ret = 0;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000206 int vis_server = atomic_read(&bat_priv->vis_mode);
207 size_t buff_pos, buf_size;
208 char *buff;
209 int compare;
210
Marek Lindner32ae9b22011-04-20 15:40:58 +0200211 primary_if = primary_if_get_selected(bat_priv);
212 if (!primary_if)
213 goto out;
214
215 if (vis_server == VIS_TYPE_CLIENT_UPDATE)
216 goto out;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000217
218 buf_size = 1;
219 /* Estimate length */
220 spin_lock_bh(&bat_priv->vis_hash_lock);
221 for (i = 0; i < hash->size; i++) {
222 head = &hash->table[i];
223
Marek Lindner7aadf882011-02-18 12:28:09 +0000224 rcu_read_lock();
225 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000226 packet = (struct vis_packet *)info->skb_packet->data;
227 entries = (struct vis_info_entry *)
Sven Eckelmann704509b2011-05-14 23:14:54 +0200228 ((char *)packet + sizeof(*packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000229
230 for (j = 0; j < packet->entries; j++) {
231 if (entries[j].quality == 0)
232 continue;
233 compare =
Marek Lindner39901e72011-02-18 12:28:08 +0000234 compare_eth(entries[j].src, packet->vis_orig);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000235 vis_data_insert_interface(entries[j].src,
236 &vis_if_list,
237 compare);
238 }
239
240 hlist_for_each_entry(entry, pos, &vis_if_list, list) {
241 buf_size += 18 + 26 * packet->entries;
242
243 /* add primary/secondary records */
Marek Lindner39901e72011-02-18 12:28:08 +0000244 if (compare_eth(entry->addr, packet->vis_orig))
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000245 buf_size +=
246 vis_data_count_prim_sec(&vis_if_list);
247
248 buf_size += 1;
249 }
250
251 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list,
252 list) {
253 hlist_del(&entry->list);
254 kfree(entry);
255 }
256 }
Marek Lindner7aadf882011-02-18 12:28:09 +0000257 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000258 }
259
260 buff = kmalloc(buf_size, GFP_ATOMIC);
261 if (!buff) {
262 spin_unlock_bh(&bat_priv->vis_hash_lock);
Marek Lindner32ae9b22011-04-20 15:40:58 +0200263 ret = -ENOMEM;
264 goto out;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000265 }
266 buff[0] = '\0';
267 buff_pos = 0;
268
269 for (i = 0; i < hash->size; i++) {
270 head = &hash->table[i];
271
Marek Lindner7aadf882011-02-18 12:28:09 +0000272 rcu_read_lock();
273 hlist_for_each_entry_rcu(info, node, head, hash_entry) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000274 packet = (struct vis_packet *)info->skb_packet->data;
275 entries = (struct vis_info_entry *)
Sven Eckelmann704509b2011-05-14 23:14:54 +0200276 ((char *)packet + sizeof(*packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000277
278 for (j = 0; j < packet->entries; j++) {
279 if (entries[j].quality == 0)
280 continue;
281 compare =
Marek Lindner39901e72011-02-18 12:28:08 +0000282 compare_eth(entries[j].src, packet->vis_orig);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000283 vis_data_insert_interface(entries[j].src,
284 &vis_if_list,
285 compare);
286 }
287
288 hlist_for_each_entry(entry, pos, &vis_if_list, list) {
289 buff_pos += sprintf(buff + buff_pos, "%pM,",
290 entry->addr);
291
Linus Lüssingdd58ddc2011-01-25 21:56:16 +0000292 for (j = 0; j < packet->entries; j++)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000293 buff_pos += vis_data_read_entry(
294 buff + buff_pos,
Linus Lüssingdd58ddc2011-01-25 21:56:16 +0000295 &entries[j],
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000296 entry->addr,
297 entry->primary);
298
299 /* add primary/secondary records */
Marek Lindner39901e72011-02-18 12:28:08 +0000300 if (compare_eth(entry->addr, packet->vis_orig))
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000301 buff_pos +=
302 vis_data_read_prim_sec(buff + buff_pos,
303 &vis_if_list);
304
305 buff_pos += sprintf(buff + buff_pos, "\n");
306 }
307
308 hlist_for_each_entry_safe(entry, pos, n, &vis_if_list,
309 list) {
310 hlist_del(&entry->list);
311 kfree(entry);
312 }
313 }
Marek Lindner7aadf882011-02-18 12:28:09 +0000314 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000315 }
316
317 spin_unlock_bh(&bat_priv->vis_hash_lock);
318
319 seq_printf(seq, "%s", buff);
320 kfree(buff);
321
Marek Lindner32ae9b22011-04-20 15:40:58 +0200322out:
323 if (primary_if)
324 hardif_free_ref(primary_if);
325 return ret;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000326}
327
328/* add the info packet to the send list, if it was not
329 * already linked in. */
330static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info)
331{
332 if (list_empty(&info->send_list)) {
333 kref_get(&info->refcount);
334 list_add_tail(&info->send_list, &bat_priv->vis_send_list);
335 }
336}
337
338/* delete the info packet from the send list, if it was
339 * linked in. */
340static void send_list_del(struct vis_info *info)
341{
342 if (!list_empty(&info->send_list)) {
343 list_del_init(&info->send_list);
344 kref_put(&info->refcount, free_info);
345 }
346}
347
348/* tries to add one entry to the receive list. */
349static void recv_list_add(struct bat_priv *bat_priv,
Sven Eckelmann747e4222011-05-14 23:14:50 +0200350 struct list_head *recv_list, const char *mac)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000351{
352 struct recvlist_node *entry;
353
Sven Eckelmann704509b2011-05-14 23:14:54 +0200354 entry = kmalloc(sizeof(*entry), GFP_ATOMIC);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000355 if (!entry)
356 return;
357
358 memcpy(entry->mac, mac, ETH_ALEN);
359 spin_lock_bh(&bat_priv->vis_list_lock);
360 list_add_tail(&entry->list, recv_list);
361 spin_unlock_bh(&bat_priv->vis_list_lock);
362}
363
364/* returns 1 if this mac is in the recv_list */
365static int recv_list_is_in(struct bat_priv *bat_priv,
Sven Eckelmann747e4222011-05-14 23:14:50 +0200366 const struct list_head *recv_list, const char *mac)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000367{
Sven Eckelmann747e4222011-05-14 23:14:50 +0200368 const struct recvlist_node *entry;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000369
370 spin_lock_bh(&bat_priv->vis_list_lock);
371 list_for_each_entry(entry, recv_list, list) {
Marek Lindner39901e72011-02-18 12:28:08 +0000372 if (compare_eth(entry->mac, mac)) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000373 spin_unlock_bh(&bat_priv->vis_list_lock);
374 return 1;
375 }
376 }
377 spin_unlock_bh(&bat_priv->vis_list_lock);
378 return 0;
379}
380
381/* try to add the packet to the vis_hash. return NULL if invalid (e.g. too old,
382 * broken.. ). vis hash must be locked outside. is_new is set when the packet
383 * is newer than old entries in the hash. */
384static struct vis_info *add_packet(struct bat_priv *bat_priv,
385 struct vis_packet *vis_packet,
386 int vis_info_len, int *is_new,
387 int make_broadcast)
388{
389 struct vis_info *info, *old_info;
390 struct vis_packet *search_packet, *old_packet;
391 struct vis_info search_elem;
392 struct vis_packet *packet;
393 int hash_added;
394
395 *is_new = 0;
396 /* sanity check */
397 if (!bat_priv->vis_hash)
398 return NULL;
399
400 /* see if the packet is already in vis_hash */
Sven Eckelmann704509b2011-05-14 23:14:54 +0200401 search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000402 if (!search_elem.skb_packet)
403 return NULL;
404 search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet,
Sven Eckelmann704509b2011-05-14 23:14:54 +0200405 sizeof(*search_packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000406
407 memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN);
Marek Lindner7aadf882011-02-18 12:28:09 +0000408 old_info = vis_hash_find(bat_priv, &search_elem);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000409 kfree_skb(search_elem.skb_packet);
410
411 if (old_info) {
412 old_packet = (struct vis_packet *)old_info->skb_packet->data;
413 if (!seq_after(ntohl(vis_packet->seqno),
414 ntohl(old_packet->seqno))) {
415 if (old_packet->seqno == vis_packet->seqno) {
416 recv_list_add(bat_priv, &old_info->recv_list,
417 vis_packet->sender_orig);
418 return old_info;
419 } else {
420 /* newer packet is already in hash. */
421 return NULL;
422 }
423 }
424 /* remove old entry */
425 hash_remove(bat_priv->vis_hash, vis_info_cmp, vis_info_choose,
426 old_info);
427 send_list_del(old_info);
428 kref_put(&old_info->refcount, free_info);
429 }
430
Sven Eckelmann704509b2011-05-14 23:14:54 +0200431 info = kmalloc(sizeof(*info), GFP_ATOMIC);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000432 if (!info)
433 return NULL;
434
Sven Eckelmann704509b2011-05-14 23:14:54 +0200435 info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len +
436 sizeof(struct ethhdr));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000437 if (!info->skb_packet) {
438 kfree(info);
439 return NULL;
440 }
441 skb_reserve(info->skb_packet, sizeof(struct ethhdr));
Sven Eckelmann704509b2011-05-14 23:14:54 +0200442 packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet)
443 + vis_info_len);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000444
445 kref_init(&info->refcount);
446 INIT_LIST_HEAD(&info->send_list);
447 INIT_LIST_HEAD(&info->recv_list);
448 info->first_seen = jiffies;
449 info->bat_priv = bat_priv;
Sven Eckelmann704509b2011-05-14 23:14:54 +0200450 memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000451
452 /* initialize and add new packet. */
453 *is_new = 1;
454
455 /* Make it a broadcast packet, if required */
456 if (make_broadcast)
457 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN);
458
459 /* repair if entries is longer than packet. */
460 if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len)
461 packet->entries = vis_info_len / sizeof(struct vis_info_entry);
462
463 recv_list_add(bat_priv, &info->recv_list, packet->sender_orig);
464
465 /* try to add it */
466 hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose,
Marek Lindner7aadf882011-02-18 12:28:09 +0000467 info, &info->hash_entry);
Antonio Quartulli1a1f37d2011-07-10 00:36:36 +0200468 if (hash_added != 0) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000469 /* did not work (for some reason) */
Sven Eckelmann2674c152011-01-28 18:34:05 +0100470 kref_put(&info->refcount, free_info);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000471 info = NULL;
472 }
473
474 return info;
475}
476
477/* handle the server sync packet, forward if needed. */
478void receive_server_sync_packet(struct bat_priv *bat_priv,
479 struct vis_packet *vis_packet,
480 int vis_info_len)
481{
482 struct vis_info *info;
483 int is_new, make_broadcast;
484 int vis_server = atomic_read(&bat_priv->vis_mode);
485
486 make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC);
487
488 spin_lock_bh(&bat_priv->vis_hash_lock);
489 info = add_packet(bat_priv, vis_packet, vis_info_len,
490 &is_new, make_broadcast);
491 if (!info)
492 goto end;
493
494 /* only if we are server ourselves and packet is newer than the one in
495 * hash.*/
496 if (vis_server == VIS_TYPE_SERVER_SYNC && is_new)
497 send_list_add(bat_priv, info);
498end:
499 spin_unlock_bh(&bat_priv->vis_hash_lock);
500}
501
502/* handle an incoming client update packet and schedule forward if needed. */
503void receive_client_update_packet(struct bat_priv *bat_priv,
504 struct vis_packet *vis_packet,
505 int vis_info_len)
506{
507 struct vis_info *info;
508 struct vis_packet *packet;
509 int is_new;
510 int vis_server = atomic_read(&bat_priv->vis_mode);
511 int are_target = 0;
512
513 /* clients shall not broadcast. */
514 if (is_broadcast_ether_addr(vis_packet->target_orig))
515 return;
516
517 /* Are we the target for this VIS packet? */
518 if (vis_server == VIS_TYPE_SERVER_SYNC &&
519 is_my_mac(vis_packet->target_orig))
520 are_target = 1;
521
522 spin_lock_bh(&bat_priv->vis_hash_lock);
523 info = add_packet(bat_priv, vis_packet, vis_info_len,
524 &is_new, are_target);
525
526 if (!info)
527 goto end;
528 /* note that outdated packets will be dropped at this point. */
529
530 packet = (struct vis_packet *)info->skb_packet->data;
531
532 /* send only if we're the target server or ... */
533 if (are_target && is_new) {
534 packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */
535 send_list_add(bat_priv, info);
536
537 /* ... we're not the recipient (and thus need to forward). */
538 } else if (!is_my_mac(packet->target_orig)) {
539 send_list_add(bat_priv, info);
540 }
541
542end:
543 spin_unlock_bh(&bat_priv->vis_hash_lock);
544}
545
546/* Walk the originators and find the VIS server with the best tq. Set the packet
547 * address to its address and return the best_tq.
548 *
549 * Must be called with the originator hash locked */
550static int find_best_vis_server(struct bat_priv *bat_priv,
551 struct vis_info *info)
552{
553 struct hashtable_t *hash = bat_priv->orig_hash;
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000554 struct neigh_node *router;
Marek Lindner7aadf882011-02-18 12:28:09 +0000555 struct hlist_node *node;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000556 struct hlist_head *head;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000557 struct orig_node *orig_node;
558 struct vis_packet *packet;
559 int best_tq = -1, i;
560
561 packet = (struct vis_packet *)info->skb_packet->data;
562
563 for (i = 0; i < hash->size; i++) {
564 head = &hash->table[i];
565
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000566 rcu_read_lock();
Marek Lindner7aadf882011-02-18 12:28:09 +0000567 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000568 router = orig_node_get_router(orig_node);
569 if (!router)
570 continue;
571
572 if ((orig_node->flags & VIS_SERVER) &&
573 (router->tq_avg > best_tq)) {
574 best_tq = router->tq_avg;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000575 memcpy(packet->target_orig, orig_node->orig,
576 ETH_ALEN);
577 }
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000578 neigh_node_free_ref(router);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000579 }
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000580 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000581 }
582
583 return best_tq;
584}
585
586/* Return true if the vis packet is full. */
Sven Eckelmann747e4222011-05-14 23:14:50 +0200587static bool vis_packet_full(const struct vis_info *info)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000588{
Sven Eckelmann747e4222011-05-14 23:14:50 +0200589 const struct vis_packet *packet;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000590 packet = (struct vis_packet *)info->skb_packet->data;
591
592 if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry)
593 < packet->entries + 1)
594 return true;
595 return false;
596}
597
598/* generates a packet of own vis data,
599 * returns 0 on success, -1 if no packet could be generated */
600static int generate_vis_packet(struct bat_priv *bat_priv)
601{
602 struct hashtable_t *hash = bat_priv->orig_hash;
Marek Lindner7aadf882011-02-18 12:28:09 +0000603 struct hlist_node *node;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000604 struct hlist_head *head;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000605 struct orig_node *orig_node;
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000606 struct neigh_node *router;
Sven Eckelmann958ca592011-05-14 23:14:53 +0200607 struct vis_info *info = bat_priv->my_vis_info;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000608 struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data;
609 struct vis_info_entry *entry;
Antonio Quartulli2dafb492011-05-05 08:42:45 +0200610 struct tt_local_entry *tt_local_entry;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000611 int best_tq = -1, i;
612
613 info->first_seen = jiffies;
614 packet->vis_type = atomic_read(&bat_priv->vis_mode);
615
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000616 memcpy(packet->target_orig, broadcast_addr, ETH_ALEN);
617 packet->ttl = TTL;
618 packet->seqno = htonl(ntohl(packet->seqno) + 1);
619 packet->entries = 0;
Sven Eckelmann704509b2011-05-14 23:14:54 +0200620 skb_trim(info->skb_packet, sizeof(*packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000621
622 if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) {
623 best_tq = find_best_vis_server(bat_priv, info);
624
Marek Lindnerd0072602011-01-19 20:01:44 +0000625 if (best_tq < 0)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000626 return -1;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000627 }
628
629 for (i = 0; i < hash->size; i++) {
630 head = &hash->table[i];
631
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000632 rcu_read_lock();
Marek Lindner7aadf882011-02-18 12:28:09 +0000633 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000634 router = orig_node_get_router(orig_node);
635 if (!router)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000636 continue;
637
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000638 if (!compare_eth(router->addr, orig_node->orig))
639 goto next;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000640
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000641 if (router->if_incoming->if_status != IF_ACTIVE)
642 goto next;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000643
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000644 if (router->tq_avg < 1)
645 goto next;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000646
647 /* fill one entry into buffer. */
648 entry = (struct vis_info_entry *)
649 skb_put(info->skb_packet, sizeof(*entry));
650 memcpy(entry->src,
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000651 router->if_incoming->net_dev->dev_addr,
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000652 ETH_ALEN);
653 memcpy(entry->dest, orig_node->orig, ETH_ALEN);
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000654 entry->quality = router->tq_avg;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000655 packet->entries++;
656
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000657next:
658 neigh_node_free_ref(router);
659
Marek Lindnerd0072602011-01-19 20:01:44 +0000660 if (vis_packet_full(info))
661 goto unlock;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000662 }
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000663 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000664 }
665
Antonio Quartulli2dafb492011-05-05 08:42:45 +0200666 hash = bat_priv->tt_local_hash;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000667
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000668 for (i = 0; i < hash->size; i++) {
669 head = &hash->table[i];
670
Antonio Quartulli7683fdc2011-04-27 14:28:07 +0200671 rcu_read_lock();
672 hlist_for_each_entry_rcu(tt_local_entry, node, head,
673 hash_entry) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000674 entry = (struct vis_info_entry *)
675 skb_put(info->skb_packet,
676 sizeof(*entry));
677 memset(entry->src, 0, ETH_ALEN);
Antonio Quartulli2dafb492011-05-05 08:42:45 +0200678 memcpy(entry->dest, tt_local_entry->addr, ETH_ALEN);
679 entry->quality = 0; /* 0 means TT */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000680 packet->entries++;
681
Antonio Quartulli7683fdc2011-04-27 14:28:07 +0200682 if (vis_packet_full(info))
683 goto unlock;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000684 }
Antonio Quartulli7683fdc2011-04-27 14:28:07 +0200685 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000686 }
687
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000688 return 0;
Marek Lindnerd0072602011-01-19 20:01:44 +0000689
690unlock:
691 rcu_read_unlock();
692 return 0;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000693}
694
695/* free old vis packets. Must be called with this vis_hash_lock
696 * held */
697static void purge_vis_packets(struct bat_priv *bat_priv)
698{
699 int i;
700 struct hashtable_t *hash = bat_priv->vis_hash;
Marek Lindner7aadf882011-02-18 12:28:09 +0000701 struct hlist_node *node, *node_tmp;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000702 struct hlist_head *head;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000703 struct vis_info *info;
704
705 for (i = 0; i < hash->size; i++) {
706 head = &hash->table[i];
707
Marek Lindner7aadf882011-02-18 12:28:09 +0000708 hlist_for_each_entry_safe(info, node, node_tmp,
709 head, hash_entry) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000710 /* never purge own data. */
711 if (info == bat_priv->my_vis_info)
712 continue;
713
714 if (time_after(jiffies,
715 info->first_seen + VIS_TIMEOUT * HZ)) {
Marek Lindner7aadf882011-02-18 12:28:09 +0000716 hlist_del(node);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000717 send_list_del(info);
718 kref_put(&info->refcount, free_info);
719 }
720 }
721 }
722}
723
724static void broadcast_vis_packet(struct bat_priv *bat_priv,
725 struct vis_info *info)
726{
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000727 struct neigh_node *router;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000728 struct hashtable_t *hash = bat_priv->orig_hash;
Marek Lindner7aadf882011-02-18 12:28:09 +0000729 struct hlist_node *node;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000730 struct hlist_head *head;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000731 struct orig_node *orig_node;
732 struct vis_packet *packet;
733 struct sk_buff *skb;
Marek Lindnere6c10f42011-02-18 12:33:20 +0000734 struct hard_iface *hard_iface;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000735 uint8_t dstaddr[ETH_ALEN];
736 int i;
737
738
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000739 packet = (struct vis_packet *)info->skb_packet->data;
740
741 /* send to all routers in range. */
742 for (i = 0; i < hash->size; i++) {
743 head = &hash->table[i];
744
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000745 rcu_read_lock();
Marek Lindner7aadf882011-02-18 12:28:09 +0000746 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000747 /* if it's a vis server and reachable, send it. */
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000748 if (!(orig_node->flags & VIS_SERVER))
749 continue;
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000750
751 router = orig_node_get_router(orig_node);
752 if (!router)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000753 continue;
754
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000755 /* don't send it if we already received the packet from
756 * this node. */
757 if (recv_list_is_in(bat_priv, &info->recv_list,
758 orig_node->orig)) {
759 neigh_node_free_ref(router);
760 continue;
761 }
762
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000763 memcpy(packet->target_orig, orig_node->orig, ETH_ALEN);
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000764 hard_iface = router->if_incoming;
765 memcpy(dstaddr, router->addr, ETH_ALEN);
766
767 neigh_node_free_ref(router);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000768
769 skb = skb_clone(info->skb_packet, GFP_ATOMIC);
770 if (skb)
Marek Lindnere6c10f42011-02-18 12:33:20 +0000771 send_skb_packet(skb, hard_iface, dstaddr);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000772
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000773 }
Marek Lindnerfb778ea2011-01-19 20:01:40 +0000774 rcu_read_unlock();
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000775 }
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000776}
777
778static void unicast_vis_packet(struct bat_priv *bat_priv,
779 struct vis_info *info)
780{
781 struct orig_node *orig_node;
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000782 struct neigh_node *router = NULL;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000783 struct sk_buff *skb;
784 struct vis_packet *packet;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000785
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000786 packet = (struct vis_packet *)info->skb_packet->data;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000787
Marek Lindner7aadf882011-02-18 12:28:09 +0000788 orig_node = orig_hash_find(bat_priv, packet->target_orig);
Marek Lindner44524fc2011-02-10 14:33:53 +0000789 if (!orig_node)
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000790 goto out;
Marek Lindner44524fc2011-02-10 14:33:53 +0000791
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000792 router = orig_node_get_router(orig_node);
793 if (!router)
794 goto out;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000795
796 skb = skb_clone(info->skb_packet, GFP_ATOMIC);
797 if (skb)
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000798 send_skb_packet(skb, router->if_incoming, router->addr);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000799
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000800out:
Linus Lüssinge1a5382f2011-03-14 22:43:37 +0000801 if (router)
802 neigh_node_free_ref(router);
Marek Lindner44524fc2011-02-10 14:33:53 +0000803 if (orig_node)
Marek Lindner7b36e8e2011-02-18 12:28:10 +0000804 orig_node_free_ref(orig_node);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000805}
806
807/* only send one vis packet. called from send_vis_packets() */
808static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info)
809{
Marek Lindner32ae9b22011-04-20 15:40:58 +0200810 struct hard_iface *primary_if;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000811 struct vis_packet *packet;
812
Marek Lindner32ae9b22011-04-20 15:40:58 +0200813 primary_if = primary_if_get_selected(bat_priv);
814 if (!primary_if)
815 goto out;
816
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000817 packet = (struct vis_packet *)info->skb_packet->data;
818 if (packet->ttl < 2) {
819 pr_debug("Error - can't send vis packet: ttl exceeded\n");
Marek Lindner32ae9b22011-04-20 15:40:58 +0200820 goto out;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000821 }
822
Marek Lindner32ae9b22011-04-20 15:40:58 +0200823 memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000824 packet->ttl--;
825
826 if (is_broadcast_ether_addr(packet->target_orig))
827 broadcast_vis_packet(bat_priv, info);
828 else
829 unicast_vis_packet(bat_priv, info);
830 packet->ttl++; /* restore TTL */
Marek Lindner32ae9b22011-04-20 15:40:58 +0200831
832out:
833 if (primary_if)
834 hardif_free_ref(primary_if);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000835}
836
837/* called from timer; send (and maybe generate) vis packet. */
838static void send_vis_packets(struct work_struct *work)
839{
840 struct delayed_work *delayed_work =
841 container_of(work, struct delayed_work, work);
842 struct bat_priv *bat_priv =
843 container_of(delayed_work, struct bat_priv, vis_work);
Sven Eckelmann1181e1d2011-01-28 18:34:07 +0100844 struct vis_info *info;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000845
846 spin_lock_bh(&bat_priv->vis_hash_lock);
847 purge_vis_packets(bat_priv);
848
849 if (generate_vis_packet(bat_priv) == 0) {
850 /* schedule if generation was successful */
851 send_list_add(bat_priv, bat_priv->my_vis_info);
852 }
853
Sven Eckelmann1181e1d2011-01-28 18:34:07 +0100854 while (!list_empty(&bat_priv->vis_send_list)) {
855 info = list_first_entry(&bat_priv->vis_send_list,
856 typeof(*info), send_list);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000857
858 kref_get(&info->refcount);
859 spin_unlock_bh(&bat_priv->vis_hash_lock);
860
Marek Lindner32ae9b22011-04-20 15:40:58 +0200861 send_vis_packet(bat_priv, info);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000862
863 spin_lock_bh(&bat_priv->vis_hash_lock);
864 send_list_del(info);
865 kref_put(&info->refcount, free_info);
866 }
867 spin_unlock_bh(&bat_priv->vis_hash_lock);
868 start_vis_timer(bat_priv);
869}
870
871/* init the vis server. this may only be called when if_list is already
872 * initialized (e.g. bat0 is initialized, interfaces have been added) */
873int vis_init(struct bat_priv *bat_priv)
874{
875 struct vis_packet *packet;
876 int hash_added;
877
878 if (bat_priv->vis_hash)
879 return 1;
880
881 spin_lock_bh(&bat_priv->vis_hash_lock);
882
883 bat_priv->vis_hash = hash_new(256);
884 if (!bat_priv->vis_hash) {
885 pr_err("Can't initialize vis_hash\n");
886 goto err;
887 }
888
889 bat_priv->my_vis_info = kmalloc(MAX_VIS_PACKET_SIZE, GFP_ATOMIC);
Joe Perches320f4222011-08-29 14:17:24 -0700890 if (!bat_priv->my_vis_info)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000891 goto err;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000892
Sven Eckelmann704509b2011-05-14 23:14:54 +0200893 bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) +
894 MAX_VIS_PACKET_SIZE +
895 sizeof(struct ethhdr));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000896 if (!bat_priv->my_vis_info->skb_packet)
897 goto free_info;
898
899 skb_reserve(bat_priv->my_vis_info->skb_packet, sizeof(struct ethhdr));
Sven Eckelmann704509b2011-05-14 23:14:54 +0200900 packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet,
901 sizeof(*packet));
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000902
903 /* prefill the vis info */
904 bat_priv->my_vis_info->first_seen = jiffies -
905 msecs_to_jiffies(VIS_INTERVAL);
906 INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list);
907 INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list);
908 kref_init(&bat_priv->my_vis_info->refcount);
909 bat_priv->my_vis_info->bat_priv = bat_priv;
910 packet->version = COMPAT_VERSION;
911 packet->packet_type = BAT_VIS;
912 packet->ttl = TTL;
913 packet->seqno = 0;
914 packet->entries = 0;
915
916 INIT_LIST_HEAD(&bat_priv->vis_send_list);
917
918 hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose,
Marek Lindner7aadf882011-02-18 12:28:09 +0000919 bat_priv->my_vis_info,
920 &bat_priv->my_vis_info->hash_entry);
Antonio Quartulli1a1f37d2011-07-10 00:36:36 +0200921 if (hash_added != 0) {
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000922 pr_err("Can't add own vis packet into hash\n");
923 /* not in hash, need to remove it manually. */
924 kref_put(&bat_priv->my_vis_info->refcount, free_info);
925 goto err;
926 }
927
928 spin_unlock_bh(&bat_priv->vis_hash_lock);
929 start_vis_timer(bat_priv);
930 return 1;
931
932free_info:
933 kfree(bat_priv->my_vis_info);
934 bat_priv->my_vis_info = NULL;
935err:
936 spin_unlock_bh(&bat_priv->vis_hash_lock);
937 vis_quit(bat_priv);
938 return 0;
939}
940
941/* Decrease the reference count on a hash item info */
Marek Lindner7aadf882011-02-18 12:28:09 +0000942static void free_info_ref(struct hlist_node *node, void *arg)
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000943{
Marek Lindner7aadf882011-02-18 12:28:09 +0000944 struct vis_info *info;
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000945
Marek Lindner7aadf882011-02-18 12:28:09 +0000946 info = container_of(node, struct vis_info, hash_entry);
Sven Eckelmannc6c8fea2010-12-13 11:19:28 +0000947 send_list_del(info);
948 kref_put(&info->refcount, free_info);
949}
950
951/* shutdown vis-server */
952void vis_quit(struct bat_priv *bat_priv)
953{
954 if (!bat_priv->vis_hash)
955 return;
956
957 cancel_delayed_work_sync(&bat_priv->vis_work);
958
959 spin_lock_bh(&bat_priv->vis_hash_lock);
960 /* properly remove, kill timers ... */
961 hash_delete(bat_priv->vis_hash, free_info_ref, NULL);
962 bat_priv->vis_hash = NULL;
963 bat_priv->my_vis_info = NULL;
964 spin_unlock_bh(&bat_priv->vis_hash_lock);
965}
966
967/* schedule packets for (re)transmission */
968static void start_vis_timer(struct bat_priv *bat_priv)
969{
970 INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets);
971 queue_delayed_work(bat_event_workqueue, &bat_priv->vis_work,
972 msecs_to_jiffies(VIS_INTERVAL));
973}