Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 1 | /* |
Sven Eckelmann | 567db7b | 2012-01-01 00:41:38 +0100 | [diff] [blame] | 2 | * Copyright (C) 2008-2012 B.A.T.M.A.N. contributors: |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 3 | * |
| 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 Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 33 | static void start_vis_timer(struct bat_priv *bat_priv); |
| 34 | |
| 35 | /* free the info */ |
| 36 | static 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 Eckelmann | dda9fc6 | 2011-01-28 18:34:06 +0100 | [diff] [blame] | 51 | kfree(info); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 52 | } |
| 53 | |
| 54 | /* Compare two vis packets, used by the hashing algorithm */ |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 55 | static int vis_info_cmp(const struct hlist_node *node, const void *data2) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 56 | { |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 57 | const struct vis_info *d1, *d2; |
| 58 | const struct vis_packet *p1, *p2; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 59 | |
| 60 | d1 = container_of(node, struct vis_info, hash_entry); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 61 | d2 = data2; |
| 62 | p1 = (struct vis_packet *)d1->skb_packet->data; |
| 63 | p2 = (struct vis_packet *)d2->skb_packet->data; |
Marek Lindner | 39901e7 | 2011-02-18 12:28:08 +0000 | [diff] [blame] | 64 | return compare_eth(p1->vis_orig, p2->vis_orig); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 65 | } |
| 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 */ |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 69 | static uint32_t vis_info_choose(const void *data, uint32_t size) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 70 | { |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 71 | const struct vis_info *vis_info = data; |
| 72 | const struct vis_packet *packet; |
| 73 | const unsigned char *key; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 74 | 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 Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 92 | static struct vis_info *vis_hash_find(struct bat_priv *bat_priv, |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 93 | const void *data) |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 94 | { |
| 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; |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 99 | uint32_t index; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 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 Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 120 | /* insert interface to the list of interfaces of one originator, if it |
| 121 | * does not already exist in the list */ |
| 122 | static 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 Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 130 | if (compare_eth(entry->addr, interface)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 131 | return; |
| 132 | } |
| 133 | |
Antonio Quartulli | 015758d | 2011-07-09 17:52:13 +0200 | [diff] [blame] | 134 | /* it's a new address, add it to the list */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 135 | 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 Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 143 | static ssize_t vis_data_read_prim_sec(char *buff, |
| 144 | const struct hlist_head *if_list) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 145 | { |
| 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 | |
| 160 | static 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 Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 177 | static ssize_t vis_data_read_entry(char *buff, |
| 178 | const struct vis_info_entry *entry, |
| 179 | const uint8_t *src, bool primary) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 180 | { |
| 181 | /* maximal length: max(4+17+2, 3+17+1+3+2) == 26 */ |
| 182 | if (primary && entry->quality == 0) |
Antonio Quartulli | 2dafb49 | 2011-05-05 08:42:45 +0200 | [diff] [blame] | 183 | return sprintf(buff, "TT %pM, ", entry->dest); |
Marek Lindner | 39901e7 | 2011-02-18 12:28:08 +0000 | [diff] [blame] | 184 | else if (compare_eth(entry->src, src)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 185 | return sprintf(buff, "TQ %pM %d, ", entry->dest, |
| 186 | entry->quality); |
| 187 | |
| 188 | return 0; |
| 189 | } |
| 190 | |
| 191 | int vis_seq_print_text(struct seq_file *seq, void *offset) |
| 192 | { |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 193 | struct hard_iface *primary_if; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 194 | struct hlist_node *node; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 195 | struct hlist_head *head; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 196 | 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; |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 205 | uint32_t i; |
| 206 | int j, ret = 0; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 207 | int vis_server = atomic_read(&bat_priv->vis_mode); |
| 208 | size_t buff_pos, buf_size; |
| 209 | char *buff; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 210 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 211 | 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 Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 217 | |
| 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 Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 224 | rcu_read_lock(); |
| 225 | hlist_for_each_entry_rcu(info, node, head, hash_entry) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 226 | packet = (struct vis_packet *)info->skb_packet->data; |
| 227 | entries = (struct vis_info_entry *) |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 228 | ((char *)packet + sizeof(*packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 229 | |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 230 | vis_data_insert_interface(packet->vis_orig, |
| 231 | &vis_if_list, true); |
| 232 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 233 | for (j = 0; j < packet->entries; j++) { |
| 234 | if (entries[j].quality == 0) |
| 235 | continue; |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 236 | if (compare_eth(entries[j].src, |
| 237 | packet->vis_orig)) |
| 238 | continue; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 239 | vis_data_insert_interface(entries[j].src, |
| 240 | &vis_if_list, |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 241 | false); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 242 | } |
| 243 | |
| 244 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { |
| 245 | buf_size += 18 + 26 * packet->entries; |
| 246 | |
| 247 | /* add primary/secondary records */ |
Marek Lindner | 39901e7 | 2011-02-18 12:28:08 +0000 | [diff] [blame] | 248 | if (compare_eth(entry->addr, packet->vis_orig)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 249 | buf_size += |
| 250 | vis_data_count_prim_sec(&vis_if_list); |
| 251 | |
| 252 | buf_size += 1; |
| 253 | } |
| 254 | |
| 255 | hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, |
| 256 | list) { |
| 257 | hlist_del(&entry->list); |
| 258 | kfree(entry); |
| 259 | } |
| 260 | } |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 261 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 262 | } |
| 263 | |
| 264 | buff = kmalloc(buf_size, GFP_ATOMIC); |
| 265 | if (!buff) { |
| 266 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 267 | ret = -ENOMEM; |
| 268 | goto out; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 269 | } |
| 270 | buff[0] = '\0'; |
| 271 | buff_pos = 0; |
| 272 | |
| 273 | for (i = 0; i < hash->size; i++) { |
| 274 | head = &hash->table[i]; |
| 275 | |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 276 | rcu_read_lock(); |
| 277 | hlist_for_each_entry_rcu(info, node, head, hash_entry) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 278 | packet = (struct vis_packet *)info->skb_packet->data; |
| 279 | entries = (struct vis_info_entry *) |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 280 | ((char *)packet + sizeof(*packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 281 | |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 282 | vis_data_insert_interface(packet->vis_orig, |
| 283 | &vis_if_list, true); |
| 284 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 285 | for (j = 0; j < packet->entries; j++) { |
| 286 | if (entries[j].quality == 0) |
| 287 | continue; |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 288 | if (compare_eth(entries[j].src, |
| 289 | packet->vis_orig)) |
| 290 | continue; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 291 | vis_data_insert_interface(entries[j].src, |
| 292 | &vis_if_list, |
Matthias Schiffer | beeb96a | 2012-05-05 17:51:53 +0200 | [diff] [blame] | 293 | false); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 294 | } |
| 295 | |
| 296 | hlist_for_each_entry(entry, pos, &vis_if_list, list) { |
| 297 | buff_pos += sprintf(buff + buff_pos, "%pM,", |
| 298 | entry->addr); |
| 299 | |
Linus Lüssing | dd58ddc | 2011-01-25 21:56:16 +0000 | [diff] [blame] | 300 | for (j = 0; j < packet->entries; j++) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 301 | buff_pos += vis_data_read_entry( |
| 302 | buff + buff_pos, |
Linus Lüssing | dd58ddc | 2011-01-25 21:56:16 +0000 | [diff] [blame] | 303 | &entries[j], |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 304 | entry->addr, |
| 305 | entry->primary); |
| 306 | |
| 307 | /* add primary/secondary records */ |
Marek Lindner | 39901e7 | 2011-02-18 12:28:08 +0000 | [diff] [blame] | 308 | if (compare_eth(entry->addr, packet->vis_orig)) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 309 | buff_pos += |
| 310 | vis_data_read_prim_sec(buff + buff_pos, |
| 311 | &vis_if_list); |
| 312 | |
| 313 | buff_pos += sprintf(buff + buff_pos, "\n"); |
| 314 | } |
| 315 | |
| 316 | hlist_for_each_entry_safe(entry, pos, n, &vis_if_list, |
| 317 | list) { |
| 318 | hlist_del(&entry->list); |
| 319 | kfree(entry); |
| 320 | } |
| 321 | } |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 322 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 326 | |
| 327 | seq_printf(seq, "%s", buff); |
| 328 | kfree(buff); |
| 329 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 330 | out: |
| 331 | if (primary_if) |
| 332 | hardif_free_ref(primary_if); |
| 333 | return ret; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | /* add the info packet to the send list, if it was not |
| 337 | * already linked in. */ |
| 338 | static void send_list_add(struct bat_priv *bat_priv, struct vis_info *info) |
| 339 | { |
| 340 | if (list_empty(&info->send_list)) { |
| 341 | kref_get(&info->refcount); |
| 342 | list_add_tail(&info->send_list, &bat_priv->vis_send_list); |
| 343 | } |
| 344 | } |
| 345 | |
| 346 | /* delete the info packet from the send list, if it was |
| 347 | * linked in. */ |
| 348 | static void send_list_del(struct vis_info *info) |
| 349 | { |
| 350 | if (!list_empty(&info->send_list)) { |
| 351 | list_del_init(&info->send_list); |
| 352 | kref_put(&info->refcount, free_info); |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /* tries to add one entry to the receive list. */ |
| 357 | static void recv_list_add(struct bat_priv *bat_priv, |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 358 | struct list_head *recv_list, const char *mac) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 359 | { |
| 360 | struct recvlist_node *entry; |
| 361 | |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 362 | entry = kmalloc(sizeof(*entry), GFP_ATOMIC); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 363 | if (!entry) |
| 364 | return; |
| 365 | |
| 366 | memcpy(entry->mac, mac, ETH_ALEN); |
| 367 | spin_lock_bh(&bat_priv->vis_list_lock); |
| 368 | list_add_tail(&entry->list, recv_list); |
| 369 | spin_unlock_bh(&bat_priv->vis_list_lock); |
| 370 | } |
| 371 | |
| 372 | /* returns 1 if this mac is in the recv_list */ |
| 373 | static int recv_list_is_in(struct bat_priv *bat_priv, |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 374 | const struct list_head *recv_list, const char *mac) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 375 | { |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 376 | const struct recvlist_node *entry; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 377 | |
| 378 | spin_lock_bh(&bat_priv->vis_list_lock); |
| 379 | list_for_each_entry(entry, recv_list, list) { |
Marek Lindner | 39901e7 | 2011-02-18 12:28:08 +0000 | [diff] [blame] | 380 | if (compare_eth(entry->mac, mac)) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 381 | spin_unlock_bh(&bat_priv->vis_list_lock); |
| 382 | return 1; |
| 383 | } |
| 384 | } |
| 385 | spin_unlock_bh(&bat_priv->vis_list_lock); |
| 386 | return 0; |
| 387 | } |
| 388 | |
| 389 | /* try to add the packet to the vis_hash. return NULL if invalid (e.g. too old, |
| 390 | * broken.. ). vis hash must be locked outside. is_new is set when the packet |
| 391 | * is newer than old entries in the hash. */ |
| 392 | static struct vis_info *add_packet(struct bat_priv *bat_priv, |
| 393 | struct vis_packet *vis_packet, |
| 394 | int vis_info_len, int *is_new, |
| 395 | int make_broadcast) |
| 396 | { |
| 397 | struct vis_info *info, *old_info; |
| 398 | struct vis_packet *search_packet, *old_packet; |
| 399 | struct vis_info search_elem; |
| 400 | struct vis_packet *packet; |
| 401 | int hash_added; |
| 402 | |
| 403 | *is_new = 0; |
| 404 | /* sanity check */ |
| 405 | if (!bat_priv->vis_hash) |
| 406 | return NULL; |
| 407 | |
| 408 | /* see if the packet is already in vis_hash */ |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 409 | search_elem.skb_packet = dev_alloc_skb(sizeof(*search_packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 410 | if (!search_elem.skb_packet) |
| 411 | return NULL; |
| 412 | search_packet = (struct vis_packet *)skb_put(search_elem.skb_packet, |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 413 | sizeof(*search_packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 414 | |
| 415 | memcpy(search_packet->vis_orig, vis_packet->vis_orig, ETH_ALEN); |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 416 | old_info = vis_hash_find(bat_priv, &search_elem); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 417 | kfree_skb(search_elem.skb_packet); |
| 418 | |
| 419 | if (old_info) { |
| 420 | old_packet = (struct vis_packet *)old_info->skb_packet->data; |
| 421 | if (!seq_after(ntohl(vis_packet->seqno), |
| 422 | ntohl(old_packet->seqno))) { |
| 423 | if (old_packet->seqno == vis_packet->seqno) { |
| 424 | recv_list_add(bat_priv, &old_info->recv_list, |
| 425 | vis_packet->sender_orig); |
| 426 | return old_info; |
| 427 | } else { |
| 428 | /* newer packet is already in hash. */ |
| 429 | return NULL; |
| 430 | } |
| 431 | } |
| 432 | /* remove old entry */ |
| 433 | hash_remove(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, |
| 434 | old_info); |
| 435 | send_list_del(old_info); |
| 436 | kref_put(&old_info->refcount, free_info); |
| 437 | } |
| 438 | |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 439 | info = kmalloc(sizeof(*info), GFP_ATOMIC); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 440 | if (!info) |
| 441 | return NULL; |
| 442 | |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 443 | info->skb_packet = dev_alloc_skb(sizeof(*packet) + vis_info_len + |
Antonio Quartulli | 0d12507 | 2012-02-18 11:27:34 +0100 | [diff] [blame] | 444 | ETH_HLEN); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 445 | if (!info->skb_packet) { |
| 446 | kfree(info); |
| 447 | return NULL; |
| 448 | } |
Antonio Quartulli | 0d12507 | 2012-02-18 11:27:34 +0100 | [diff] [blame] | 449 | skb_reserve(info->skb_packet, ETH_HLEN); |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 450 | packet = (struct vis_packet *)skb_put(info->skb_packet, sizeof(*packet) |
| 451 | + vis_info_len); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 452 | |
| 453 | kref_init(&info->refcount); |
| 454 | INIT_LIST_HEAD(&info->send_list); |
| 455 | INIT_LIST_HEAD(&info->recv_list); |
| 456 | info->first_seen = jiffies; |
| 457 | info->bat_priv = bat_priv; |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 458 | memcpy(packet, vis_packet, sizeof(*packet) + vis_info_len); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 459 | |
| 460 | /* initialize and add new packet. */ |
| 461 | *is_new = 1; |
| 462 | |
| 463 | /* Make it a broadcast packet, if required */ |
| 464 | if (make_broadcast) |
| 465 | memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); |
| 466 | |
| 467 | /* repair if entries is longer than packet. */ |
| 468 | if (packet->entries * sizeof(struct vis_info_entry) > vis_info_len) |
| 469 | packet->entries = vis_info_len / sizeof(struct vis_info_entry); |
| 470 | |
| 471 | recv_list_add(bat_priv, &info->recv_list, packet->sender_orig); |
| 472 | |
| 473 | /* try to add it */ |
| 474 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 475 | info, &info->hash_entry); |
Antonio Quartulli | 1a1f37d | 2011-07-10 00:36:36 +0200 | [diff] [blame] | 476 | if (hash_added != 0) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 477 | /* did not work (for some reason) */ |
Sven Eckelmann | 2674c15 | 2011-01-28 18:34:05 +0100 | [diff] [blame] | 478 | kref_put(&info->refcount, free_info); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 479 | info = NULL; |
| 480 | } |
| 481 | |
| 482 | return info; |
| 483 | } |
| 484 | |
| 485 | /* handle the server sync packet, forward if needed. */ |
| 486 | void receive_server_sync_packet(struct bat_priv *bat_priv, |
| 487 | struct vis_packet *vis_packet, |
| 488 | int vis_info_len) |
| 489 | { |
| 490 | struct vis_info *info; |
| 491 | int is_new, make_broadcast; |
| 492 | int vis_server = atomic_read(&bat_priv->vis_mode); |
| 493 | |
| 494 | make_broadcast = (vis_server == VIS_TYPE_SERVER_SYNC); |
| 495 | |
| 496 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 497 | info = add_packet(bat_priv, vis_packet, vis_info_len, |
| 498 | &is_new, make_broadcast); |
| 499 | if (!info) |
| 500 | goto end; |
| 501 | |
| 502 | /* only if we are server ourselves and packet is newer than the one in |
| 503 | * hash.*/ |
| 504 | if (vis_server == VIS_TYPE_SERVER_SYNC && is_new) |
| 505 | send_list_add(bat_priv, info); |
| 506 | end: |
| 507 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 508 | } |
| 509 | |
| 510 | /* handle an incoming client update packet and schedule forward if needed. */ |
| 511 | void receive_client_update_packet(struct bat_priv *bat_priv, |
| 512 | struct vis_packet *vis_packet, |
| 513 | int vis_info_len) |
| 514 | { |
| 515 | struct vis_info *info; |
| 516 | struct vis_packet *packet; |
| 517 | int is_new; |
| 518 | int vis_server = atomic_read(&bat_priv->vis_mode); |
| 519 | int are_target = 0; |
| 520 | |
| 521 | /* clients shall not broadcast. */ |
| 522 | if (is_broadcast_ether_addr(vis_packet->target_orig)) |
| 523 | return; |
| 524 | |
| 525 | /* Are we the target for this VIS packet? */ |
| 526 | if (vis_server == VIS_TYPE_SERVER_SYNC && |
| 527 | is_my_mac(vis_packet->target_orig)) |
| 528 | are_target = 1; |
| 529 | |
| 530 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 531 | info = add_packet(bat_priv, vis_packet, vis_info_len, |
| 532 | &is_new, are_target); |
| 533 | |
| 534 | if (!info) |
| 535 | goto end; |
| 536 | /* note that outdated packets will be dropped at this point. */ |
| 537 | |
| 538 | packet = (struct vis_packet *)info->skb_packet->data; |
| 539 | |
| 540 | /* send only if we're the target server or ... */ |
| 541 | if (are_target && is_new) { |
| 542 | packet->vis_type = VIS_TYPE_SERVER_SYNC; /* upgrade! */ |
| 543 | send_list_add(bat_priv, info); |
| 544 | |
| 545 | /* ... we're not the recipient (and thus need to forward). */ |
| 546 | } else if (!is_my_mac(packet->target_orig)) { |
| 547 | send_list_add(bat_priv, info); |
| 548 | } |
| 549 | |
| 550 | end: |
| 551 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 552 | } |
| 553 | |
| 554 | /* Walk the originators and find the VIS server with the best tq. Set the packet |
| 555 | * address to its address and return the best_tq. |
| 556 | * |
| 557 | * Must be called with the originator hash locked */ |
| 558 | static int find_best_vis_server(struct bat_priv *bat_priv, |
| 559 | struct vis_info *info) |
| 560 | { |
| 561 | struct hashtable_t *hash = bat_priv->orig_hash; |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 562 | struct neigh_node *router; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 563 | struct hlist_node *node; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 564 | struct hlist_head *head; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 565 | struct orig_node *orig_node; |
| 566 | struct vis_packet *packet; |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 567 | int best_tq = -1; |
| 568 | uint32_t i; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 569 | |
| 570 | packet = (struct vis_packet *)info->skb_packet->data; |
| 571 | |
| 572 | for (i = 0; i < hash->size; i++) { |
| 573 | head = &hash->table[i]; |
| 574 | |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 575 | rcu_read_lock(); |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 576 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 577 | router = batadv_orig_node_get_router(orig_node); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 578 | if (!router) |
| 579 | continue; |
| 580 | |
| 581 | if ((orig_node->flags & VIS_SERVER) && |
| 582 | (router->tq_avg > best_tq)) { |
| 583 | best_tq = router->tq_avg; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 584 | memcpy(packet->target_orig, orig_node->orig, |
| 585 | ETH_ALEN); |
| 586 | } |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 587 | batadv_neigh_node_free_ref(router); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 588 | } |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 589 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | return best_tq; |
| 593 | } |
| 594 | |
| 595 | /* Return true if the vis packet is full. */ |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 596 | static bool vis_packet_full(const struct vis_info *info) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 597 | { |
Sven Eckelmann | 747e422 | 2011-05-14 23:14:50 +0200 | [diff] [blame] | 598 | const struct vis_packet *packet; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 599 | packet = (struct vis_packet *)info->skb_packet->data; |
| 600 | |
| 601 | if (MAX_VIS_PACKET_SIZE / sizeof(struct vis_info_entry) |
| 602 | < packet->entries + 1) |
| 603 | return true; |
| 604 | return false; |
| 605 | } |
| 606 | |
| 607 | /* generates a packet of own vis data, |
| 608 | * returns 0 on success, -1 if no packet could be generated */ |
| 609 | static int generate_vis_packet(struct bat_priv *bat_priv) |
| 610 | { |
| 611 | struct hashtable_t *hash = bat_priv->orig_hash; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 612 | struct hlist_node *node; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 613 | struct hlist_head *head; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 614 | struct orig_node *orig_node; |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 615 | struct neigh_node *router; |
Sven Eckelmann | 958ca59 | 2011-05-14 23:14:53 +0200 | [diff] [blame] | 616 | struct vis_info *info = bat_priv->my_vis_info; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 617 | struct vis_packet *packet = (struct vis_packet *)info->skb_packet->data; |
| 618 | struct vis_info_entry *entry; |
Antonio Quartulli | 48100ba | 2011-10-30 12:17:33 +0100 | [diff] [blame] | 619 | struct tt_common_entry *tt_common_entry; |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 620 | int best_tq = -1; |
| 621 | uint32_t i; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 622 | |
| 623 | info->first_seen = jiffies; |
| 624 | packet->vis_type = atomic_read(&bat_priv->vis_mode); |
| 625 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 626 | memcpy(packet->target_orig, broadcast_addr, ETH_ALEN); |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 627 | packet->header.ttl = TTL; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 628 | packet->seqno = htonl(ntohl(packet->seqno) + 1); |
| 629 | packet->entries = 0; |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 630 | skb_trim(info->skb_packet, sizeof(*packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 631 | |
| 632 | if (packet->vis_type == VIS_TYPE_CLIENT_UPDATE) { |
| 633 | best_tq = find_best_vis_server(bat_priv, info); |
| 634 | |
Marek Lindner | d007260 | 2011-01-19 20:01:44 +0000 | [diff] [blame] | 635 | if (best_tq < 0) |
Sven Eckelmann | 5346c35 | 2012-05-05 13:27:28 +0200 | [diff] [blame] | 636 | return best_tq; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 637 | } |
| 638 | |
| 639 | for (i = 0; i < hash->size; i++) { |
| 640 | head = &hash->table[i]; |
| 641 | |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 642 | rcu_read_lock(); |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 643 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 644 | router = batadv_orig_node_get_router(orig_node); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 645 | if (!router) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 646 | continue; |
| 647 | |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 648 | if (!compare_eth(router->addr, orig_node->orig)) |
| 649 | goto next; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 650 | |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 651 | if (router->if_incoming->if_status != IF_ACTIVE) |
| 652 | goto next; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 653 | |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 654 | if (router->tq_avg < 1) |
| 655 | goto next; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 656 | |
| 657 | /* fill one entry into buffer. */ |
| 658 | entry = (struct vis_info_entry *) |
| 659 | skb_put(info->skb_packet, sizeof(*entry)); |
| 660 | memcpy(entry->src, |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 661 | router->if_incoming->net_dev->dev_addr, |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 662 | ETH_ALEN); |
| 663 | memcpy(entry->dest, orig_node->orig, ETH_ALEN); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 664 | entry->quality = router->tq_avg; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 665 | packet->entries++; |
| 666 | |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 667 | next: |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 668 | batadv_neigh_node_free_ref(router); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 669 | |
Marek Lindner | d007260 | 2011-01-19 20:01:44 +0000 | [diff] [blame] | 670 | if (vis_packet_full(info)) |
| 671 | goto unlock; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 672 | } |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 673 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Antonio Quartulli | 2dafb49 | 2011-05-05 08:42:45 +0200 | [diff] [blame] | 676 | hash = bat_priv->tt_local_hash; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 677 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 678 | for (i = 0; i < hash->size; i++) { |
| 679 | head = &hash->table[i]; |
| 680 | |
Antonio Quartulli | 7683fdc | 2011-04-27 14:28:07 +0200 | [diff] [blame] | 681 | rcu_read_lock(); |
Antonio Quartulli | 48100ba | 2011-10-30 12:17:33 +0100 | [diff] [blame] | 682 | hlist_for_each_entry_rcu(tt_common_entry, node, head, |
Antonio Quartulli | 7683fdc | 2011-04-27 14:28:07 +0200 | [diff] [blame] | 683 | hash_entry) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 684 | entry = (struct vis_info_entry *) |
| 685 | skb_put(info->skb_packet, |
| 686 | sizeof(*entry)); |
| 687 | memset(entry->src, 0, ETH_ALEN); |
Antonio Quartulli | 48100ba | 2011-10-30 12:17:33 +0100 | [diff] [blame] | 688 | memcpy(entry->dest, tt_common_entry->addr, ETH_ALEN); |
Antonio Quartulli | 2dafb49 | 2011-05-05 08:42:45 +0200 | [diff] [blame] | 689 | entry->quality = 0; /* 0 means TT */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 690 | packet->entries++; |
| 691 | |
Antonio Quartulli | 7683fdc | 2011-04-27 14:28:07 +0200 | [diff] [blame] | 692 | if (vis_packet_full(info)) |
| 693 | goto unlock; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 694 | } |
Antonio Quartulli | 7683fdc | 2011-04-27 14:28:07 +0200 | [diff] [blame] | 695 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 696 | } |
| 697 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 698 | return 0; |
Marek Lindner | d007260 | 2011-01-19 20:01:44 +0000 | [diff] [blame] | 699 | |
| 700 | unlock: |
| 701 | rcu_read_unlock(); |
| 702 | return 0; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 703 | } |
| 704 | |
| 705 | /* free old vis packets. Must be called with this vis_hash_lock |
| 706 | * held */ |
| 707 | static void purge_vis_packets(struct bat_priv *bat_priv) |
| 708 | { |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 709 | uint32_t i; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 710 | struct hashtable_t *hash = bat_priv->vis_hash; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 711 | struct hlist_node *node, *node_tmp; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 712 | struct hlist_head *head; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 713 | struct vis_info *info; |
| 714 | |
| 715 | for (i = 0; i < hash->size; i++) { |
| 716 | head = &hash->table[i]; |
| 717 | |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 718 | hlist_for_each_entry_safe(info, node, node_tmp, |
| 719 | head, hash_entry) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 720 | /* never purge own data. */ |
| 721 | if (info == bat_priv->my_vis_info) |
| 722 | continue; |
| 723 | |
Marek Lindner | 032b796 | 2011-12-20 19:30:40 +0800 | [diff] [blame] | 724 | if (has_timed_out(info->first_seen, VIS_TIMEOUT)) { |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 725 | hlist_del(node); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 726 | send_list_del(info); |
| 727 | kref_put(&info->refcount, free_info); |
| 728 | } |
| 729 | } |
| 730 | } |
| 731 | } |
| 732 | |
| 733 | static void broadcast_vis_packet(struct bat_priv *bat_priv, |
| 734 | struct vis_info *info) |
| 735 | { |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 736 | struct neigh_node *router; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 737 | struct hashtable_t *hash = bat_priv->orig_hash; |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 738 | struct hlist_node *node; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 739 | struct hlist_head *head; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 740 | struct orig_node *orig_node; |
| 741 | struct vis_packet *packet; |
| 742 | struct sk_buff *skb; |
Marek Lindner | e6c10f4 | 2011-02-18 12:33:20 +0000 | [diff] [blame] | 743 | struct hard_iface *hard_iface; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 744 | uint8_t dstaddr[ETH_ALEN]; |
Antonio Quartulli | c90681b | 2011-10-05 17:05:25 +0200 | [diff] [blame] | 745 | uint32_t i; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 746 | |
| 747 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 748 | packet = (struct vis_packet *)info->skb_packet->data; |
| 749 | |
| 750 | /* send to all routers in range. */ |
| 751 | for (i = 0; i < hash->size; i++) { |
| 752 | head = &hash->table[i]; |
| 753 | |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 754 | rcu_read_lock(); |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 755 | hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 756 | /* if it's a vis server and reachable, send it. */ |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 757 | if (!(orig_node->flags & VIS_SERVER)) |
| 758 | continue; |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 759 | |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 760 | router = batadv_orig_node_get_router(orig_node); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 761 | if (!router) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 762 | continue; |
| 763 | |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 764 | /* don't send it if we already received the packet from |
| 765 | * this node. */ |
| 766 | if (recv_list_is_in(bat_priv, &info->recv_list, |
| 767 | orig_node->orig)) { |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 768 | batadv_neigh_node_free_ref(router); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 769 | continue; |
| 770 | } |
| 771 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 772 | memcpy(packet->target_orig, orig_node->orig, ETH_ALEN); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 773 | hard_iface = router->if_incoming; |
| 774 | memcpy(dstaddr, router->addr, ETH_ALEN); |
| 775 | |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 776 | batadv_neigh_node_free_ref(router); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 777 | |
| 778 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); |
| 779 | if (skb) |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame^] | 780 | batadv_send_skb_packet(skb, hard_iface, |
| 781 | dstaddr); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 782 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 783 | } |
Marek Lindner | fb778ea | 2011-01-19 20:01:40 +0000 | [diff] [blame] | 784 | rcu_read_unlock(); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 785 | } |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 786 | } |
| 787 | |
| 788 | static void unicast_vis_packet(struct bat_priv *bat_priv, |
| 789 | struct vis_info *info) |
| 790 | { |
| 791 | struct orig_node *orig_node; |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 792 | struct neigh_node *router = NULL; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 793 | struct sk_buff *skb; |
| 794 | struct vis_packet *packet; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 795 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 796 | packet = (struct vis_packet *)info->skb_packet->data; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 797 | |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 798 | orig_node = orig_hash_find(bat_priv, packet->target_orig); |
Marek Lindner | 44524fc | 2011-02-10 14:33:53 +0000 | [diff] [blame] | 799 | if (!orig_node) |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 800 | goto out; |
Marek Lindner | 44524fc | 2011-02-10 14:33:53 +0000 | [diff] [blame] | 801 | |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 802 | router = batadv_orig_node_get_router(orig_node); |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 803 | if (!router) |
| 804 | goto out; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 805 | |
| 806 | skb = skb_clone(info->skb_packet, GFP_ATOMIC); |
| 807 | if (skb) |
Sven Eckelmann | 9455e34 | 2012-05-12 02:09:37 +0200 | [diff] [blame^] | 808 | batadv_send_skb_packet(skb, router->if_incoming, router->addr); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 809 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 810 | out: |
Linus Lüssing | e1a5382f | 2011-03-14 22:43:37 +0000 | [diff] [blame] | 811 | if (router) |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 812 | batadv_neigh_node_free_ref(router); |
Marek Lindner | 44524fc | 2011-02-10 14:33:53 +0000 | [diff] [blame] | 813 | if (orig_node) |
Sven Eckelmann | 7d211ef | 2012-05-12 02:09:34 +0200 | [diff] [blame] | 814 | batadv_orig_node_free_ref(orig_node); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 815 | } |
| 816 | |
| 817 | /* only send one vis packet. called from send_vis_packets() */ |
| 818 | static void send_vis_packet(struct bat_priv *bat_priv, struct vis_info *info) |
| 819 | { |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 820 | struct hard_iface *primary_if; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 821 | struct vis_packet *packet; |
| 822 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 823 | primary_if = primary_if_get_selected(bat_priv); |
| 824 | if (!primary_if) |
| 825 | goto out; |
| 826 | |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 827 | packet = (struct vis_packet *)info->skb_packet->data; |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 828 | if (packet->header.ttl < 2) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 829 | pr_debug("Error - can't send vis packet: ttl exceeded\n"); |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 830 | goto out; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 831 | } |
| 832 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 833 | memcpy(packet->sender_orig, primary_if->net_dev->dev_addr, ETH_ALEN); |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 834 | packet->header.ttl--; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 835 | |
| 836 | if (is_broadcast_ether_addr(packet->target_orig)) |
| 837 | broadcast_vis_packet(bat_priv, info); |
| 838 | else |
| 839 | unicast_vis_packet(bat_priv, info); |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 840 | packet->header.ttl++; /* restore TTL */ |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 841 | |
| 842 | out: |
| 843 | if (primary_if) |
| 844 | hardif_free_ref(primary_if); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /* called from timer; send (and maybe generate) vis packet. */ |
| 848 | static void send_vis_packets(struct work_struct *work) |
| 849 | { |
| 850 | struct delayed_work *delayed_work = |
| 851 | container_of(work, struct delayed_work, work); |
| 852 | struct bat_priv *bat_priv = |
| 853 | container_of(delayed_work, struct bat_priv, vis_work); |
Sven Eckelmann | 1181e1d | 2011-01-28 18:34:07 +0100 | [diff] [blame] | 854 | struct vis_info *info; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 855 | |
| 856 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 857 | purge_vis_packets(bat_priv); |
| 858 | |
| 859 | if (generate_vis_packet(bat_priv) == 0) { |
| 860 | /* schedule if generation was successful */ |
| 861 | send_list_add(bat_priv, bat_priv->my_vis_info); |
| 862 | } |
| 863 | |
Sven Eckelmann | 1181e1d | 2011-01-28 18:34:07 +0100 | [diff] [blame] | 864 | while (!list_empty(&bat_priv->vis_send_list)) { |
| 865 | info = list_first_entry(&bat_priv->vis_send_list, |
| 866 | typeof(*info), send_list); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 867 | |
| 868 | kref_get(&info->refcount); |
| 869 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 870 | |
Marek Lindner | 32ae9b2 | 2011-04-20 15:40:58 +0200 | [diff] [blame] | 871 | send_vis_packet(bat_priv, info); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 872 | |
| 873 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 874 | send_list_del(info); |
| 875 | kref_put(&info->refcount, free_info); |
| 876 | } |
| 877 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 878 | start_vis_timer(bat_priv); |
| 879 | } |
| 880 | |
| 881 | /* init the vis server. this may only be called when if_list is already |
| 882 | * initialized (e.g. bat0 is initialized, interfaces have been added) */ |
| 883 | int vis_init(struct bat_priv *bat_priv) |
| 884 | { |
| 885 | struct vis_packet *packet; |
| 886 | int hash_added; |
| 887 | |
| 888 | if (bat_priv->vis_hash) |
Sven Eckelmann | 5346c35 | 2012-05-05 13:27:28 +0200 | [diff] [blame] | 889 | return 0; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 890 | |
| 891 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 892 | |
Sven Eckelmann | 1a8eaf0 | 2012-05-12 02:09:32 +0200 | [diff] [blame] | 893 | bat_priv->vis_hash = batadv_hash_new(256); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 894 | if (!bat_priv->vis_hash) { |
| 895 | pr_err("Can't initialize vis_hash\n"); |
| 896 | goto err; |
| 897 | } |
| 898 | |
| 899 | bat_priv->my_vis_info = kmalloc(MAX_VIS_PACKET_SIZE, GFP_ATOMIC); |
Joe Perches | 320f422 | 2011-08-29 14:17:24 -0700 | [diff] [blame] | 900 | if (!bat_priv->my_vis_info) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 901 | goto err; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 902 | |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 903 | bat_priv->my_vis_info->skb_packet = dev_alloc_skb(sizeof(*packet) + |
| 904 | MAX_VIS_PACKET_SIZE + |
Antonio Quartulli | 0d12507 | 2012-02-18 11:27:34 +0100 | [diff] [blame] | 905 | ETH_HLEN); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 906 | if (!bat_priv->my_vis_info->skb_packet) |
| 907 | goto free_info; |
| 908 | |
Antonio Quartulli | 0d12507 | 2012-02-18 11:27:34 +0100 | [diff] [blame] | 909 | skb_reserve(bat_priv->my_vis_info->skb_packet, ETH_HLEN); |
Sven Eckelmann | 704509b | 2011-05-14 23:14:54 +0200 | [diff] [blame] | 910 | packet = (struct vis_packet *)skb_put(bat_priv->my_vis_info->skb_packet, |
| 911 | sizeof(*packet)); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 912 | |
| 913 | /* prefill the vis info */ |
| 914 | bat_priv->my_vis_info->first_seen = jiffies - |
| 915 | msecs_to_jiffies(VIS_INTERVAL); |
| 916 | INIT_LIST_HEAD(&bat_priv->my_vis_info->recv_list); |
| 917 | INIT_LIST_HEAD(&bat_priv->my_vis_info->send_list); |
| 918 | kref_init(&bat_priv->my_vis_info->refcount); |
| 919 | bat_priv->my_vis_info->bat_priv = bat_priv; |
Sven Eckelmann | 76543d1 | 2011-11-20 15:47:38 +0100 | [diff] [blame] | 920 | packet->header.version = COMPAT_VERSION; |
| 921 | packet->header.packet_type = BAT_VIS; |
| 922 | packet->header.ttl = TTL; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 923 | packet->seqno = 0; |
| 924 | packet->entries = 0; |
| 925 | |
| 926 | INIT_LIST_HEAD(&bat_priv->vis_send_list); |
| 927 | |
| 928 | hash_added = hash_add(bat_priv->vis_hash, vis_info_cmp, vis_info_choose, |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 929 | bat_priv->my_vis_info, |
| 930 | &bat_priv->my_vis_info->hash_entry); |
Antonio Quartulli | 1a1f37d | 2011-07-10 00:36:36 +0200 | [diff] [blame] | 931 | if (hash_added != 0) { |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 932 | pr_err("Can't add own vis packet into hash\n"); |
| 933 | /* not in hash, need to remove it manually. */ |
| 934 | kref_put(&bat_priv->my_vis_info->refcount, free_info); |
| 935 | goto err; |
| 936 | } |
| 937 | |
| 938 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 939 | start_vis_timer(bat_priv); |
Sven Eckelmann | 5346c35 | 2012-05-05 13:27:28 +0200 | [diff] [blame] | 940 | return 0; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 941 | |
| 942 | free_info: |
| 943 | kfree(bat_priv->my_vis_info); |
| 944 | bat_priv->my_vis_info = NULL; |
| 945 | err: |
| 946 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 947 | vis_quit(bat_priv); |
Sven Eckelmann | 5346c35 | 2012-05-05 13:27:28 +0200 | [diff] [blame] | 948 | return -ENOMEM; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 949 | } |
| 950 | |
| 951 | /* Decrease the reference count on a hash item info */ |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 952 | static void free_info_ref(struct hlist_node *node, void *arg) |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 953 | { |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 954 | struct vis_info *info; |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 955 | |
Marek Lindner | 7aadf88 | 2011-02-18 12:28:09 +0000 | [diff] [blame] | 956 | info = container_of(node, struct vis_info, hash_entry); |
Sven Eckelmann | c6c8fea | 2010-12-13 11:19:28 +0000 | [diff] [blame] | 957 | send_list_del(info); |
| 958 | kref_put(&info->refcount, free_info); |
| 959 | } |
| 960 | |
| 961 | /* shutdown vis-server */ |
| 962 | void vis_quit(struct bat_priv *bat_priv) |
| 963 | { |
| 964 | if (!bat_priv->vis_hash) |
| 965 | return; |
| 966 | |
| 967 | cancel_delayed_work_sync(&bat_priv->vis_work); |
| 968 | |
| 969 | spin_lock_bh(&bat_priv->vis_hash_lock); |
| 970 | /* properly remove, kill timers ... */ |
| 971 | hash_delete(bat_priv->vis_hash, free_info_ref, NULL); |
| 972 | bat_priv->vis_hash = NULL; |
| 973 | bat_priv->my_vis_info = NULL; |
| 974 | spin_unlock_bh(&bat_priv->vis_hash_lock); |
| 975 | } |
| 976 | |
| 977 | /* schedule packets for (re)transmission */ |
| 978 | static void start_vis_timer(struct bat_priv *bat_priv) |
| 979 | { |
| 980 | INIT_DELAYED_WORK(&bat_priv->vis_work, send_vis_packets); |
| 981 | queue_delayed_work(bat_event_workqueue, &bat_priv->vis_work, |
| 982 | msecs_to_jiffies(VIS_INTERVAL)); |
| 983 | } |