diff options
| -rw-r--r-- | net/batman-adv/debugfs.c | 15 | ||||
| -rw-r--r-- | net/batman-adv/distributed-arp-table.c | 296 | ||||
| -rw-r--r-- | net/batman-adv/distributed-arp-table.h | 4 | ||||
| -rw-r--r-- | net/batman-adv/main.c | 7 | ||||
| -rw-r--r-- | net/batman-adv/main.h | 1 | ||||
| -rw-r--r-- | net/batman-adv/types.h | 23 |
6 files changed, 346 insertions, 0 deletions
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index bd032bc4e262..ebc5f4d1f53c 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c | |||
| @@ -31,6 +31,7 @@ | |||
| 31 | #include "vis.h" | 31 | #include "vis.h" |
| 32 | #include "icmp_socket.h" | 32 | #include "icmp_socket.h" |
| 33 | #include "bridge_loop_avoidance.h" | 33 | #include "bridge_loop_avoidance.h" |
| 34 | #include "distributed-arp-table.h" | ||
| 34 | 35 | ||
| 35 | static struct dentry *batadv_debugfs; | 36 | static struct dentry *batadv_debugfs; |
| 36 | 37 | ||
| @@ -280,6 +281,18 @@ static int batadv_bla_backbone_table_open(struct inode *inode, | |||
| 280 | 281 | ||
| 281 | #endif | 282 | #endif |
| 282 | 283 | ||
| 284 | /** | ||
| 285 | * batadv_dat_cache_open - Prepare file handler for reads from dat_chache | ||
| 286 | * @inode: inode which was opened | ||
| 287 | * @file: file handle to be initialized | ||
| 288 | */ | ||
| 289 | static int batadv_dat_cache_open(struct inode *inode, struct file *file) | ||
| 290 | { | ||
| 291 | struct net_device *net_dev = (struct net_device *)inode->i_private; | ||
| 292 | return single_open(file, batadv_dat_cache_seq_print_text, net_dev); | ||
| 293 | } | ||
| 294 | |||
| 295 | |||
| 283 | static int batadv_transtable_local_open(struct inode *inode, struct file *file) | 296 | static int batadv_transtable_local_open(struct inode *inode, struct file *file) |
| 284 | { | 297 | { |
| 285 | struct net_device *net_dev = (struct net_device *)inode->i_private; | 298 | struct net_device *net_dev = (struct net_device *)inode->i_private; |
| @@ -319,6 +332,7 @@ static BATADV_DEBUGINFO(bla_claim_table, S_IRUGO, batadv_bla_claim_table_open); | |||
| 319 | static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, | 332 | static BATADV_DEBUGINFO(bla_backbone_table, S_IRUGO, |
| 320 | batadv_bla_backbone_table_open); | 333 | batadv_bla_backbone_table_open); |
| 321 | #endif | 334 | #endif |
| 335 | static BATADV_DEBUGINFO(dat_cache, S_IRUGO, batadv_dat_cache_open); | ||
| 322 | static BATADV_DEBUGINFO(transtable_local, S_IRUGO, | 336 | static BATADV_DEBUGINFO(transtable_local, S_IRUGO, |
| 323 | batadv_transtable_local_open); | 337 | batadv_transtable_local_open); |
| 324 | static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); | 338 | static BATADV_DEBUGINFO(vis_data, S_IRUGO, batadv_vis_data_open); |
| @@ -331,6 +345,7 @@ static struct batadv_debuginfo *batadv_mesh_debuginfos[] = { | |||
| 331 | &batadv_debuginfo_bla_claim_table, | 345 | &batadv_debuginfo_bla_claim_table, |
| 332 | &batadv_debuginfo_bla_backbone_table, | 346 | &batadv_debuginfo_bla_backbone_table, |
| 333 | #endif | 347 | #endif |
| 348 | &batadv_debuginfo_dat_cache, | ||
| 334 | &batadv_debuginfo_transtable_local, | 349 | &batadv_debuginfo_transtable_local, |
| 335 | &batadv_debuginfo_vis_data, | 350 | &batadv_debuginfo_vis_data, |
| 336 | NULL, | 351 | NULL, |
diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index ce39e8a5be38..2ef90e3ea2c4 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c | |||
| @@ -28,6 +28,119 @@ | |||
| 28 | #include "types.h" | 28 | #include "types.h" |
| 29 | #include "unicast.h" | 29 | #include "unicast.h" |
| 30 | 30 | ||
| 31 | static void batadv_dat_purge(struct work_struct *work); | ||
| 32 | |||
| 33 | /** | ||
| 34 | * batadv_dat_start_timer - initialise the DAT periodic worker | ||
| 35 | * @bat_priv: the bat priv with all the soft interface information | ||
| 36 | */ | ||
| 37 | static void batadv_dat_start_timer(struct batadv_priv *bat_priv) | ||
| 38 | { | ||
| 39 | INIT_DELAYED_WORK(&bat_priv->dat.work, batadv_dat_purge); | ||
| 40 | queue_delayed_work(batadv_event_workqueue, &bat_priv->dat.work, | ||
| 41 | msecs_to_jiffies(10000)); | ||
| 42 | } | ||
| 43 | |||
| 44 | /** | ||
| 45 | * batadv_dat_entry_free_ref - decrements the dat_entry refcounter and possibly | ||
| 46 | * free it | ||
| 47 | * @dat_entry: the oentry to free | ||
| 48 | */ | ||
| 49 | static void batadv_dat_entry_free_ref(struct batadv_dat_entry *dat_entry) | ||
| 50 | { | ||
| 51 | if (atomic_dec_and_test(&dat_entry->refcount)) | ||
| 52 | kfree_rcu(dat_entry, rcu); | ||
| 53 | } | ||
| 54 | |||
| 55 | /** | ||
| 56 | * batadv_dat_to_purge - checks whether a dat_entry has to be purged or not | ||
| 57 | * @dat_entry: the entry to check | ||
| 58 | * | ||
| 59 | * Returns true if the entry has to be purged now, false otherwise | ||
| 60 | */ | ||
| 61 | static bool batadv_dat_to_purge(struct batadv_dat_entry *dat_entry) | ||
| 62 | { | ||
| 63 | return batadv_has_timed_out(dat_entry->last_update, | ||
| 64 | BATADV_DAT_ENTRY_TIMEOUT); | ||
| 65 | } | ||
| 66 | |||
| 67 | /** | ||
| 68 | * __batadv_dat_purge - delete entries from the DAT local storage | ||
| 69 | * @bat_priv: the bat priv with all the soft interface information | ||
| 70 | * @to_purge: function in charge to decide whether an entry has to be purged or | ||
| 71 | * not. This function takes the dat_entry as argument and has to | ||
| 72 | * returns a boolean value: true is the entry has to be deleted, | ||
| 73 | * false otherwise | ||
| 74 | * | ||
| 75 | * Loops over each entry in the DAT local storage and delete it if and only if | ||
| 76 | * the to_purge function passed as argument returns true | ||
| 77 | */ | ||
| 78 | static void __batadv_dat_purge(struct batadv_priv *bat_priv, | ||
| 79 | bool (*to_purge)(struct batadv_dat_entry *)) | ||
| 80 | { | ||
| 81 | spinlock_t *list_lock; /* protects write access to the hash lists */ | ||
| 82 | struct batadv_dat_entry *dat_entry; | ||
| 83 | struct hlist_node *node, *node_tmp; | ||
| 84 | struct hlist_head *head; | ||
| 85 | uint32_t i; | ||
| 86 | |||
| 87 | if (!bat_priv->dat.hash) | ||
| 88 | return; | ||
| 89 | |||
| 90 | for (i = 0; i < bat_priv->dat.hash->size; i++) { | ||
| 91 | head = &bat_priv->dat.hash->table[i]; | ||
| 92 | list_lock = &bat_priv->dat.hash->list_locks[i]; | ||
| 93 | |||
| 94 | spin_lock_bh(list_lock); | ||
| 95 | hlist_for_each_entry_safe(dat_entry, node, node_tmp, head, | ||
| 96 | hash_entry) { | ||
| 97 | /* if an helper function has been passed as parameter, | ||
| 98 | * ask it if the entry has to be purged or not | ||
| 99 | */ | ||
| 100 | if (to_purge && !to_purge(dat_entry)) | ||
| 101 | continue; | ||
| 102 | |||
| 103 | hlist_del_rcu(node); | ||
| 104 | batadv_dat_entry_free_ref(dat_entry); | ||
| 105 | } | ||
| 106 | spin_unlock_bh(list_lock); | ||
| 107 | } | ||
| 108 | } | ||
| 109 | |||
| 110 | /** | ||
| 111 | * batadv_dat_purge - periodic task that deletes old entries from the local DAT | ||
| 112 | * hash table | ||
| 113 | * @work: kernel work struct | ||
| 114 | */ | ||
| 115 | static void batadv_dat_purge(struct work_struct *work) | ||
| 116 | { | ||
| 117 | struct delayed_work *delayed_work; | ||
| 118 | struct batadv_priv_dat *priv_dat; | ||
| 119 | struct batadv_priv *bat_priv; | ||
| 120 | |||
| 121 | delayed_work = container_of(work, struct delayed_work, work); | ||
| 122 | priv_dat = container_of(delayed_work, struct batadv_priv_dat, work); | ||
| 123 | bat_priv = container_of(priv_dat, struct batadv_priv, dat); | ||
| 124 | |||
| 125 | __batadv_dat_purge(bat_priv, batadv_dat_to_purge); | ||
| 126 | batadv_dat_start_timer(bat_priv); | ||
| 127 | } | ||
| 128 | |||
| 129 | /** | ||
| 130 | * batadv_compare_dat - comparing function used in the local DAT hash table | ||
| 131 | * @node: node in the local table | ||
| 132 | * @data2: second object to compare the node to | ||
| 133 | * | ||
| 134 | * Returns 1 if the two entry are the same, 0 otherwise | ||
| 135 | */ | ||
| 136 | static int batadv_compare_dat(const struct hlist_node *node, const void *data2) | ||
| 137 | { | ||
| 138 | const void *data1 = container_of(node, struct batadv_dat_entry, | ||
| 139 | hash_entry); | ||
| 140 | |||
| 141 | return (memcmp(data1, data2, sizeof(__be32)) == 0 ? 1 : 0); | ||
| 142 | } | ||
| 143 | |||
| 31 | /** | 144 | /** |
| 32 | * batadv_hash_dat - compute the hash value for an IP address | 145 | * batadv_hash_dat - compute the hash value for an IP address |
| 33 | * @data: data to hash | 146 | * @data: data to hash |
| @@ -55,6 +168,96 @@ static uint32_t batadv_hash_dat(const void *data, uint32_t size) | |||
| 55 | } | 168 | } |
| 56 | 169 | ||
| 57 | /** | 170 | /** |
| 171 | * batadv_dat_entry_hash_find - looks for a given dat_entry in the local hash | ||
| 172 | * table | ||
| 173 | * @bat_priv: the bat priv with all the soft interface information | ||
| 174 | * @ip: search key | ||
| 175 | * | ||
| 176 | * Returns the dat_entry if found, NULL otherwise | ||
| 177 | */ | ||
| 178 | static struct batadv_dat_entry * | ||
| 179 | batadv_dat_entry_hash_find(struct batadv_priv *bat_priv, __be32 ip) | ||
| 180 | { | ||
| 181 | struct hlist_head *head; | ||
| 182 | struct hlist_node *node; | ||
| 183 | struct batadv_dat_entry *dat_entry, *dat_entry_tmp = NULL; | ||
| 184 | struct batadv_hashtable *hash = bat_priv->dat.hash; | ||
| 185 | uint32_t index; | ||
| 186 | |||
| 187 | if (!hash) | ||
| 188 | return NULL; | ||
| 189 | |||
| 190 | index = batadv_hash_dat(&ip, hash->size); | ||
| 191 | head = &hash->table[index]; | ||
| 192 | |||
| 193 | rcu_read_lock(); | ||
| 194 | hlist_for_each_entry_rcu(dat_entry, node, head, hash_entry) { | ||
| 195 | if (dat_entry->ip != ip) | ||
| 196 | continue; | ||
| 197 | |||
| 198 | if (!atomic_inc_not_zero(&dat_entry->refcount)) | ||
| 199 | continue; | ||
| 200 | |||
| 201 | dat_entry_tmp = dat_entry; | ||
| 202 | break; | ||
| 203 | } | ||
| 204 | rcu_read_unlock(); | ||
| 205 | |||
| 206 | return dat_entry_tmp; | ||
| 207 | } | ||
| 208 | |||
| 209 | /** | ||
| 210 | * batadv_dat_entry_add - add a new dat entry or update it if already exists | ||
| 211 | * @bat_priv: the bat priv with all the soft interface information | ||
| 212 | * @ip: ipv4 to add/edit | ||
| 213 | * @mac_addr: mac address to assign to the given ipv4 | ||
| 214 | */ | ||
| 215 | static void batadv_dat_entry_add(struct batadv_priv *bat_priv, __be32 ip, | ||
| 216 | uint8_t *mac_addr) | ||
| 217 | { | ||
| 218 | struct batadv_dat_entry *dat_entry; | ||
| 219 | int hash_added; | ||
| 220 | |||
| 221 | dat_entry = batadv_dat_entry_hash_find(bat_priv, ip); | ||
| 222 | /* if this entry is already known, just update it */ | ||
| 223 | if (dat_entry) { | ||
| 224 | if (!batadv_compare_eth(dat_entry->mac_addr, mac_addr)) | ||
| 225 | memcpy(dat_entry->mac_addr, mac_addr, ETH_ALEN); | ||
| 226 | dat_entry->last_update = jiffies; | ||
| 227 | batadv_dbg(BATADV_DBG_DAT, bat_priv, | ||
| 228 | "Entry updated: %pI4 %pM\n", &dat_entry->ip, | ||
| 229 | dat_entry->mac_addr); | ||
| 230 | goto out; | ||
| 231 | } | ||
| 232 | |||
| 233 | dat_entry = kmalloc(sizeof(*dat_entry), GFP_ATOMIC); | ||
| 234 | if (!dat_entry) | ||
| 235 | goto out; | ||
| 236 | |||
| 237 | dat_entry->ip = ip; | ||
| 238 | memcpy(dat_entry->mac_addr, mac_addr, ETH_ALEN); | ||
| 239 | dat_entry->last_update = jiffies; | ||
| 240 | atomic_set(&dat_entry->refcount, 2); | ||
| 241 | |||
| 242 | hash_added = batadv_hash_add(bat_priv->dat.hash, batadv_compare_dat, | ||
| 243 | batadv_hash_dat, &dat_entry->ip, | ||
| 244 | &dat_entry->hash_entry); | ||
| 245 | |||
| 246 | if (unlikely(hash_added != 0)) { | ||
| 247 | /* remove the reference for the hash */ | ||
| 248 | batadv_dat_entry_free_ref(dat_entry); | ||
| 249 | goto out; | ||
| 250 | } | ||
| 251 | |||
| 252 | batadv_dbg(BATADV_DBG_DAT, bat_priv, "New entry added: %pI4 %pM\n", | ||
| 253 | &dat_entry->ip, dat_entry->mac_addr); | ||
| 254 | |||
| 255 | out: | ||
| 256 | if (dat_entry) | ||
| 257 | batadv_dat_entry_free_ref(dat_entry); | ||
| 258 | } | ||
| 259 | |||
| 260 | /** | ||
| 58 | * batadv_is_orig_node_eligible - check whether a node can be a DHT candidate | 261 | * batadv_is_orig_node_eligible - check whether a node can be a DHT candidate |
| 59 | * @res: the array with the already selected candidates | 262 | * @res: the array with the already selected candidates |
| 60 | * @select: number of already selected candidates | 263 | * @select: number of already selected candidates |
| @@ -268,3 +471,96 @@ out: | |||
| 268 | kfree(cand); | 471 | kfree(cand); |
| 269 | return ret; | 472 | return ret; |
| 270 | } | 473 | } |
| 474 | |||
| 475 | /** | ||
| 476 | * batadv_dat_hash_free - free the local DAT hash table | ||
| 477 | * @bat_priv: the bat priv with all the soft interface information | ||
| 478 | */ | ||
| 479 | static void batadv_dat_hash_free(struct batadv_priv *bat_priv) | ||
| 480 | { | ||
| 481 | __batadv_dat_purge(bat_priv, NULL); | ||
| 482 | |||
| 483 | batadv_hash_destroy(bat_priv->dat.hash); | ||
| 484 | |||
| 485 | bat_priv->dat.hash = NULL; | ||
| 486 | } | ||
| 487 | |||
| 488 | /** | ||
| 489 | * batadv_dat_init - initialise the DAT internals | ||
| 490 | * @bat_priv: the bat priv with all the soft interface information | ||
| 491 | */ | ||
| 492 | int batadv_dat_init(struct batadv_priv *bat_priv) | ||
| 493 | { | ||
| 494 | if (bat_priv->dat.hash) | ||
| 495 | return 0; | ||
| 496 | |||
| 497 | bat_priv->dat.hash = batadv_hash_new(1024); | ||
| 498 | |||
| 499 | if (!bat_priv->dat.hash) | ||
| 500 | return -ENOMEM; | ||
| 501 | |||
| 502 | batadv_dat_start_timer(bat_priv); | ||
| 503 | |||
| 504 | return 0; | ||
| 505 | } | ||
| 506 | |||
| 507 | /** | ||
| 508 | * batadv_dat_free - free the DAT internals | ||
| 509 | * @bat_priv: the bat priv with all the soft interface information | ||
| 510 | */ | ||
| 511 | void batadv_dat_free(struct batadv_priv *bat_priv) | ||
| 512 | { | ||
| 513 | cancel_delayed_work_sync(&bat_priv->dat.work); | ||
| 514 | |||
| 515 | batadv_dat_hash_free(bat_priv); | ||
| 516 | } | ||
| 517 | |||
| 518 | /** | ||
| 519 | * batadv_dat_cache_seq_print_text - print the local DAT hash table | ||
| 520 | * @seq: seq file to print on | ||
| 521 | * @offset: not used | ||
| 522 | */ | ||
| 523 | int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset) | ||
| 524 | { | ||
| 525 | struct net_device *net_dev = (struct net_device *)seq->private; | ||
| 526 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | ||
| 527 | struct batadv_hashtable *hash = bat_priv->dat.hash; | ||
| 528 | struct batadv_dat_entry *dat_entry; | ||
| 529 | struct batadv_hard_iface *primary_if; | ||
| 530 | struct hlist_node *node; | ||
| 531 | struct hlist_head *head; | ||
| 532 | unsigned long last_seen_jiffies; | ||
| 533 | int last_seen_msecs, last_seen_secs, last_seen_mins; | ||
| 534 | uint32_t i; | ||
| 535 | |||
| 536 | primary_if = batadv_seq_print_text_primary_if_get(seq); | ||
| 537 | if (!primary_if) | ||
| 538 | goto out; | ||
| 539 | |||
| 540 | seq_printf(seq, "Distributed ARP Table (%s):\n", net_dev->name); | ||
| 541 | seq_printf(seq, " %-7s %-13s %5s\n", "IPv4", "MAC", | ||
| 542 | "last-seen"); | ||
| 543 | |||
| 544 | for (i = 0; i < hash->size; i++) { | ||
| 545 | head = &hash->table[i]; | ||
| 546 | |||
| 547 | rcu_read_lock(); | ||
| 548 | hlist_for_each_entry_rcu(dat_entry, node, head, hash_entry) { | ||
| 549 | last_seen_jiffies = jiffies - dat_entry->last_update; | ||
| 550 | last_seen_msecs = jiffies_to_msecs(last_seen_jiffies); | ||
| 551 | last_seen_mins = last_seen_msecs / 60000; | ||
| 552 | last_seen_msecs = last_seen_msecs % 60000; | ||
| 553 | last_seen_secs = last_seen_msecs / 1000; | ||
| 554 | |||
| 555 | seq_printf(seq, " * %15pI4 %14pM %6i:%02i\n", | ||
| 556 | &dat_entry->ip, dat_entry->mac_addr, | ||
| 557 | last_seen_mins, last_seen_secs); | ||
| 558 | } | ||
| 559 | rcu_read_unlock(); | ||
| 560 | } | ||
| 561 | |||
| 562 | out: | ||
| 563 | if (primary_if) | ||
| 564 | batadv_hardif_free_ref(primary_if); | ||
| 565 | return 0; | ||
| 566 | } | ||
diff --git a/net/batman-adv/distributed-arp-table.h b/net/batman-adv/distributed-arp-table.h index ea9cbd806a1f..1b88303ed6c2 100644 --- a/net/batman-adv/distributed-arp-table.h +++ b/net/batman-adv/distributed-arp-table.h | |||
| @@ -55,4 +55,8 @@ batadv_dat_init_own_addr(struct batadv_priv *bat_priv, | |||
| 55 | bat_priv->dat.addr = (batadv_dat_addr_t)addr; | 55 | bat_priv->dat.addr = (batadv_dat_addr_t)addr; |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | int batadv_dat_init(struct batadv_priv *bat_priv); | ||
| 59 | void batadv_dat_free(struct batadv_priv *bat_priv); | ||
| 60 | int batadv_dat_cache_seq_print_text(struct seq_file *seq, void *offset); | ||
| 61 | |||
| 58 | #endif /* _NET_BATMAN_ADV_ARP_H_ */ | 62 | #endif /* _NET_BATMAN_ADV_ARP_H_ */ |
diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index afc07a865be4..dc33a0c484a4 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c | |||
| @@ -29,6 +29,7 @@ | |||
| 29 | #include "hard-interface.h" | 29 | #include "hard-interface.h" |
| 30 | #include "gateway_client.h" | 30 | #include "gateway_client.h" |
| 31 | #include "bridge_loop_avoidance.h" | 31 | #include "bridge_loop_avoidance.h" |
| 32 | #include "distributed-arp-table.h" | ||
| 32 | #include "vis.h" | 33 | #include "vis.h" |
| 33 | #include "hash.h" | 34 | #include "hash.h" |
| 34 | #include "bat_algo.h" | 35 | #include "bat_algo.h" |
| @@ -128,6 +129,10 @@ int batadv_mesh_init(struct net_device *soft_iface) | |||
| 128 | if (ret < 0) | 129 | if (ret < 0) |
| 129 | goto err; | 130 | goto err; |
| 130 | 131 | ||
| 132 | ret = batadv_dat_init(bat_priv); | ||
| 133 | if (ret < 0) | ||
| 134 | goto err; | ||
| 135 | |||
| 131 | atomic_set(&bat_priv->gw.reselect, 0); | 136 | atomic_set(&bat_priv->gw.reselect, 0); |
| 132 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE); | 137 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_ACTIVE); |
| 133 | 138 | ||
| @@ -155,6 +160,8 @@ void batadv_mesh_free(struct net_device *soft_iface) | |||
| 155 | 160 | ||
| 156 | batadv_bla_free(bat_priv); | 161 | batadv_bla_free(bat_priv); |
| 157 | 162 | ||
| 163 | batadv_dat_free(bat_priv); | ||
| 164 | |||
| 158 | free_percpu(bat_priv->bat_counters); | 165 | free_percpu(bat_priv->bat_counters); |
| 159 | 166 | ||
| 160 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); | 167 | atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); |
diff --git a/net/batman-adv/main.h b/net/batman-adv/main.h index 5699f2b3b557..25adfd29cc92 100644 --- a/net/batman-adv/main.h +++ b/net/batman-adv/main.h | |||
| @@ -44,6 +44,7 @@ | |||
| 44 | #define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in milliseconds */ | 44 | #define BATADV_TT_LOCAL_TIMEOUT 3600000 /* in milliseconds */ |
| 45 | #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ | 45 | #define BATADV_TT_CLIENT_ROAM_TIMEOUT 600000 /* in milliseconds */ |
| 46 | #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ | 46 | #define BATADV_TT_CLIENT_TEMP_TIMEOUT 600000 /* in milliseconds */ |
| 47 | #define BATADV_DAT_ENTRY_TIMEOUT (5*60000) /* 5 mins in milliseconds */ | ||
| 47 | /* sliding packet range of received originator messages in sequence numbers | 48 | /* sliding packet range of received originator messages in sequence numbers |
| 48 | * (should be a multiple of our word size) | 49 | * (should be a multiple of our word size) |
| 49 | */ | 50 | */ |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index b57d93bdafa6..9ed1bb275d31 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
| @@ -249,9 +249,13 @@ struct batadv_priv_vis { | |||
| 249 | /** | 249 | /** |
| 250 | * struct batadv_priv_dat - per mesh interface DAT private data | 250 | * struct batadv_priv_dat - per mesh interface DAT private data |
| 251 | * @addr: node DAT address | 251 | * @addr: node DAT address |
| 252 | * @hash: hashtable representing the local ARP cache | ||
| 253 | * @work: work queue callback item for cache purging | ||
| 252 | */ | 254 | */ |
| 253 | struct batadv_priv_dat { | 255 | struct batadv_priv_dat { |
| 254 | batadv_dat_addr_t addr; | 256 | batadv_dat_addr_t addr; |
| 257 | struct batadv_hashtable *hash; | ||
| 258 | struct delayed_work work; | ||
| 255 | }; | 259 | }; |
| 256 | 260 | ||
| 257 | struct batadv_priv { | 261 | struct batadv_priv { |
| @@ -465,6 +469,25 @@ struct batadv_algo_ops { | |||
| 465 | }; | 469 | }; |
| 466 | 470 | ||
| 467 | /** | 471 | /** |
| 472 | * struct batadv_dat_entry - it is a single entry of batman-adv ARP backend. It | ||
| 473 | * is used to stored ARP entries needed for the global DAT cache | ||
| 474 | * @ip: the IPv4 corresponding to this DAT/ARP entry | ||
| 475 | * @mac_addr: the MAC address associated to the stored IPv4 | ||
| 476 | * @last_update: time in jiffies when this entry was refreshed last time | ||
| 477 | * @hash_entry: hlist node for batadv_priv_dat::hash | ||
| 478 | * @refcount: number of contexts the object is used | ||
| 479 | * @rcu: struct used for freeing in an RCU-safe manner | ||
| 480 | */ | ||
| 481 | struct batadv_dat_entry { | ||
| 482 | __be32 ip; | ||
| 483 | uint8_t mac_addr[ETH_ALEN]; | ||
| 484 | unsigned long last_update; | ||
| 485 | struct hlist_node hash_entry; | ||
| 486 | atomic_t refcount; | ||
| 487 | struct rcu_head rcu; | ||
| 488 | }; | ||
| 489 | |||
| 490 | /** | ||
| 468 | * struct batadv_dat_candidate - candidate destination for DAT operations | 491 | * struct batadv_dat_candidate - candidate destination for DAT operations |
| 469 | * @type: the type of the selected candidate. It can one of the following: | 492 | * @type: the type of the selected candidate. It can one of the following: |
| 470 | * - BATADV_DAT_CANDIDATE_NOT_FOUND | 493 | * - BATADV_DAT_CANDIDATE_NOT_FOUND |
