diff options
author | Sven Eckelmann <sven@narfation.org> | 2012-07-15 16:26:51 -0400 |
---|---|---|
committer | Antonio Quartulli <ordex@autistici.org> | 2012-08-23 08:20:13 -0400 |
commit | 807736f6e00714fdeb443b31061d1c27fa903296 (patch) | |
tree | a070c2e9316365424e4d08e2fa50e5a28729670d /net/batman-adv/translation-table.c | |
parent | 624463079e0af455a2d70d2a59b9e2f6b5827aea (diff) |
batman-adv: Split batadv_priv in sub-structures for features
The structure batadv_priv grows everytime a new feature is introduced. It gets
hard to find the parts of the struct that belongs to a specific feature. This
becomes even harder by the fact that not every feature uses a prefix in the
member name.
The variables for bridge loop avoidence, gateway handling, translation table
and visualization server are moved into separate structs that are included in
the bat_priv main struct.
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r-- | net/batman-adv/translation-table.c | 208 |
1 files changed, 105 insertions, 103 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index eb8490e504e2..b01049a7a912 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -46,8 +46,8 @@ static int batadv_compare_tt(const struct hlist_node *node, const void *data2) | |||
46 | 46 | ||
47 | static void batadv_tt_start_timer(struct batadv_priv *bat_priv) | 47 | static void batadv_tt_start_timer(struct batadv_priv *bat_priv) |
48 | { | 48 | { |
49 | INIT_DELAYED_WORK(&bat_priv->tt_work, batadv_tt_purge); | 49 | INIT_DELAYED_WORK(&bat_priv->tt.work, batadv_tt_purge); |
50 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt_work, | 50 | queue_delayed_work(batadv_event_workqueue, &bat_priv->tt.work, |
51 | msecs_to_jiffies(5000)); | 51 | msecs_to_jiffies(5000)); |
52 | } | 52 | } |
53 | 53 | ||
@@ -88,7 +88,7 @@ batadv_tt_local_hash_find(struct batadv_priv *bat_priv, const void *data) | |||
88 | struct batadv_tt_common_entry *tt_common_entry; | 88 | struct batadv_tt_common_entry *tt_common_entry; |
89 | struct batadv_tt_local_entry *tt_local_entry = NULL; | 89 | struct batadv_tt_local_entry *tt_local_entry = NULL; |
90 | 90 | ||
91 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt_local_hash, data); | 91 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt.local_hash, data); |
92 | if (tt_common_entry) | 92 | if (tt_common_entry) |
93 | tt_local_entry = container_of(tt_common_entry, | 93 | tt_local_entry = container_of(tt_common_entry, |
94 | struct batadv_tt_local_entry, | 94 | struct batadv_tt_local_entry, |
@@ -102,7 +102,7 @@ batadv_tt_global_hash_find(struct batadv_priv *bat_priv, const void *data) | |||
102 | struct batadv_tt_common_entry *tt_common_entry; | 102 | struct batadv_tt_common_entry *tt_common_entry; |
103 | struct batadv_tt_global_entry *tt_global_entry = NULL; | 103 | struct batadv_tt_global_entry *tt_global_entry = NULL; |
104 | 104 | ||
105 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt_global_hash, data); | 105 | tt_common_entry = batadv_tt_hash_find(bat_priv->tt.global_hash, data); |
106 | if (tt_common_entry) | 106 | if (tt_common_entry) |
107 | tt_global_entry = container_of(tt_common_entry, | 107 | tt_global_entry = container_of(tt_common_entry, |
108 | struct batadv_tt_global_entry, | 108 | struct batadv_tt_global_entry, |
@@ -177,8 +177,8 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv, | |||
177 | del_op_requested = flags & BATADV_TT_CLIENT_DEL; | 177 | del_op_requested = flags & BATADV_TT_CLIENT_DEL; |
178 | 178 | ||
179 | /* check for ADD+DEL or DEL+ADD events */ | 179 | /* check for ADD+DEL or DEL+ADD events */ |
180 | spin_lock_bh(&bat_priv->tt_changes_list_lock); | 180 | spin_lock_bh(&bat_priv->tt.changes_list_lock); |
181 | list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, | 181 | list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, |
182 | list) { | 182 | list) { |
183 | if (!batadv_compare_eth(entry->change.addr, addr)) | 183 | if (!batadv_compare_eth(entry->change.addr, addr)) |
184 | continue; | 184 | continue; |
@@ -205,15 +205,15 @@ del: | |||
205 | } | 205 | } |
206 | 206 | ||
207 | /* track the change in the OGMinterval list */ | 207 | /* track the change in the OGMinterval list */ |
208 | list_add_tail(&tt_change_node->list, &bat_priv->tt_changes_list); | 208 | list_add_tail(&tt_change_node->list, &bat_priv->tt.changes_list); |
209 | 209 | ||
210 | unlock: | 210 | unlock: |
211 | spin_unlock_bh(&bat_priv->tt_changes_list_lock); | 211 | spin_unlock_bh(&bat_priv->tt.changes_list_lock); |
212 | 212 | ||
213 | if (event_removed) | 213 | if (event_removed) |
214 | atomic_dec(&bat_priv->tt_local_changes); | 214 | atomic_dec(&bat_priv->tt.local_changes); |
215 | else | 215 | else |
216 | atomic_inc(&bat_priv->tt_local_changes); | 216 | atomic_inc(&bat_priv->tt.local_changes); |
217 | } | 217 | } |
218 | 218 | ||
219 | int batadv_tt_len(int changes_num) | 219 | int batadv_tt_len(int changes_num) |
@@ -223,12 +223,12 @@ int batadv_tt_len(int changes_num) | |||
223 | 223 | ||
224 | static int batadv_tt_local_init(struct batadv_priv *bat_priv) | 224 | static int batadv_tt_local_init(struct batadv_priv *bat_priv) |
225 | { | 225 | { |
226 | if (bat_priv->tt_local_hash) | 226 | if (bat_priv->tt.local_hash) |
227 | return 0; | 227 | return 0; |
228 | 228 | ||
229 | bat_priv->tt_local_hash = batadv_hash_new(1024); | 229 | bat_priv->tt.local_hash = batadv_hash_new(1024); |
230 | 230 | ||
231 | if (!bat_priv->tt_local_hash) | 231 | if (!bat_priv->tt.local_hash) |
232 | return -ENOMEM; | 232 | return -ENOMEM; |
233 | 233 | ||
234 | return 0; | 234 | return 0; |
@@ -260,7 +260,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
260 | 260 | ||
261 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 261 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
262 | "Creating new local tt entry: %pM (ttvn: %d)\n", addr, | 262 | "Creating new local tt entry: %pM (ttvn: %d)\n", addr, |
263 | (uint8_t)atomic_read(&bat_priv->ttvn)); | 263 | (uint8_t)atomic_read(&bat_priv->tt.vn)); |
264 | 264 | ||
265 | memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); | 265 | memcpy(tt_local_entry->common.addr, addr, ETH_ALEN); |
266 | tt_local_entry->common.flags = BATADV_NO_FLAGS; | 266 | tt_local_entry->common.flags = BATADV_NO_FLAGS; |
@@ -279,7 +279,7 @@ void batadv_tt_local_add(struct net_device *soft_iface, const uint8_t *addr, | |||
279 | */ | 279 | */ |
280 | tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW; | 280 | tt_local_entry->common.flags |= BATADV_TT_CLIENT_NEW; |
281 | 281 | ||
282 | hash_added = batadv_hash_add(bat_priv->tt_local_hash, batadv_compare_tt, | 282 | hash_added = batadv_hash_add(bat_priv->tt.local_hash, batadv_compare_tt, |
283 | batadv_choose_orig, | 283 | batadv_choose_orig, |
284 | &tt_local_entry->common, | 284 | &tt_local_entry->common, |
285 | &tt_local_entry->common.hash_entry); | 285 | &tt_local_entry->common.hash_entry); |
@@ -350,7 +350,7 @@ static void batadv_tt_prepare_packet_buff(struct batadv_priv *bat_priv, | |||
350 | primary_if = batadv_primary_if_get_selected(bat_priv); | 350 | primary_if = batadv_primary_if_get_selected(bat_priv); |
351 | 351 | ||
352 | req_len = min_packet_len; | 352 | req_len = min_packet_len; |
353 | req_len += batadv_tt_len(atomic_read(&bat_priv->tt_local_changes)); | 353 | req_len += batadv_tt_len(atomic_read(&bat_priv->tt.local_changes)); |
354 | 354 | ||
355 | /* if we have too many changes for one packet don't send any | 355 | /* if we have too many changes for one packet don't send any |
356 | * and wait for the tt table request which will be fragmented | 356 | * and wait for the tt table request which will be fragmented |
@@ -383,10 +383,10 @@ static int batadv_tt_changes_fill_buff(struct batadv_priv *bat_priv, | |||
383 | if (new_len > 0) | 383 | if (new_len > 0) |
384 | tot_changes = new_len / batadv_tt_len(1); | 384 | tot_changes = new_len / batadv_tt_len(1); |
385 | 385 | ||
386 | spin_lock_bh(&bat_priv->tt_changes_list_lock); | 386 | spin_lock_bh(&bat_priv->tt.changes_list_lock); |
387 | atomic_set(&bat_priv->tt_local_changes, 0); | 387 | atomic_set(&bat_priv->tt.local_changes, 0); |
388 | 388 | ||
389 | list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, | 389 | list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, |
390 | list) { | 390 | list) { |
391 | if (count < tot_changes) { | 391 | if (count < tot_changes) { |
392 | memcpy(tt_buff + batadv_tt_len(count), | 392 | memcpy(tt_buff + batadv_tt_len(count), |
@@ -396,25 +396,25 @@ static int batadv_tt_changes_fill_buff(struct batadv_priv *bat_priv, | |||
396 | list_del(&entry->list); | 396 | list_del(&entry->list); |
397 | kfree(entry); | 397 | kfree(entry); |
398 | } | 398 | } |
399 | spin_unlock_bh(&bat_priv->tt_changes_list_lock); | 399 | spin_unlock_bh(&bat_priv->tt.changes_list_lock); |
400 | 400 | ||
401 | /* Keep the buffer for possible tt_request */ | 401 | /* Keep the buffer for possible tt_request */ |
402 | spin_lock_bh(&bat_priv->tt_buff_lock); | 402 | spin_lock_bh(&bat_priv->tt.last_changeset_lock); |
403 | kfree(bat_priv->tt_buff); | 403 | kfree(bat_priv->tt.last_changeset); |
404 | bat_priv->tt_buff_len = 0; | 404 | bat_priv->tt.last_changeset_len = 0; |
405 | bat_priv->tt_buff = NULL; | 405 | bat_priv->tt.last_changeset = NULL; |
406 | /* check whether this new OGM has no changes due to size problems */ | 406 | /* check whether this new OGM has no changes due to size problems */ |
407 | if (new_len > 0) { | 407 | if (new_len > 0) { |
408 | /* if kmalloc() fails we will reply with the full table | 408 | /* if kmalloc() fails we will reply with the full table |
409 | * instead of providing the diff | 409 | * instead of providing the diff |
410 | */ | 410 | */ |
411 | bat_priv->tt_buff = kmalloc(new_len, GFP_ATOMIC); | 411 | bat_priv->tt.last_changeset = kmalloc(new_len, GFP_ATOMIC); |
412 | if (bat_priv->tt_buff) { | 412 | if (bat_priv->tt.last_changeset) { |
413 | memcpy(bat_priv->tt_buff, tt_buff, new_len); | 413 | memcpy(bat_priv->tt.last_changeset, tt_buff, new_len); |
414 | bat_priv->tt_buff_len = new_len; | 414 | bat_priv->tt.last_changeset_len = new_len; |
415 | } | 415 | } |
416 | } | 416 | } |
417 | spin_unlock_bh(&bat_priv->tt_buff_lock); | 417 | spin_unlock_bh(&bat_priv->tt.last_changeset_lock); |
418 | 418 | ||
419 | return count; | 419 | return count; |
420 | } | 420 | } |
@@ -423,7 +423,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
423 | { | 423 | { |
424 | struct net_device *net_dev = (struct net_device *)seq->private; | 424 | struct net_device *net_dev = (struct net_device *)seq->private; |
425 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | 425 | struct batadv_priv *bat_priv = netdev_priv(net_dev); |
426 | struct batadv_hashtable *hash = bat_priv->tt_local_hash; | 426 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
427 | struct batadv_tt_common_entry *tt_common_entry; | 427 | struct batadv_tt_common_entry *tt_common_entry; |
428 | struct batadv_hard_iface *primary_if; | 428 | struct batadv_hard_iface *primary_if; |
429 | struct hlist_node *node; | 429 | struct hlist_node *node; |
@@ -448,7 +448,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
448 | 448 | ||
449 | seq_printf(seq, | 449 | seq_printf(seq, |
450 | "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", | 450 | "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", |
451 | net_dev->name, (uint8_t)atomic_read(&bat_priv->ttvn)); | 451 | net_dev->name, (uint8_t)atomic_read(&bat_priv->tt.vn)); |
452 | 452 | ||
453 | for (i = 0; i < hash->size; i++) { | 453 | for (i = 0; i < hash->size; i++) { |
454 | head = &hash->table[i]; | 454 | head = &hash->table[i]; |
@@ -546,7 +546,7 @@ static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv, | |||
546 | 546 | ||
547 | static void batadv_tt_local_purge(struct batadv_priv *bat_priv) | 547 | static void batadv_tt_local_purge(struct batadv_priv *bat_priv) |
548 | { | 548 | { |
549 | struct batadv_hashtable *hash = bat_priv->tt_local_hash; | 549 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
550 | struct hlist_head *head; | 550 | struct hlist_head *head; |
551 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 551 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
552 | uint32_t i; | 552 | uint32_t i; |
@@ -572,10 +572,10 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) | |||
572 | struct hlist_head *head; | 572 | struct hlist_head *head; |
573 | uint32_t i; | 573 | uint32_t i; |
574 | 574 | ||
575 | if (!bat_priv->tt_local_hash) | 575 | if (!bat_priv->tt.local_hash) |
576 | return; | 576 | return; |
577 | 577 | ||
578 | hash = bat_priv->tt_local_hash; | 578 | hash = bat_priv->tt.local_hash; |
579 | 579 | ||
580 | for (i = 0; i < hash->size; i++) { | 580 | for (i = 0; i < hash->size; i++) { |
581 | head = &hash->table[i]; | 581 | head = &hash->table[i]; |
@@ -595,17 +595,17 @@ static void batadv_tt_local_table_free(struct batadv_priv *bat_priv) | |||
595 | 595 | ||
596 | batadv_hash_destroy(hash); | 596 | batadv_hash_destroy(hash); |
597 | 597 | ||
598 | bat_priv->tt_local_hash = NULL; | 598 | bat_priv->tt.local_hash = NULL; |
599 | } | 599 | } |
600 | 600 | ||
601 | static int batadv_tt_global_init(struct batadv_priv *bat_priv) | 601 | static int batadv_tt_global_init(struct batadv_priv *bat_priv) |
602 | { | 602 | { |
603 | if (bat_priv->tt_global_hash) | 603 | if (bat_priv->tt.global_hash) |
604 | return 0; | 604 | return 0; |
605 | 605 | ||
606 | bat_priv->tt_global_hash = batadv_hash_new(1024); | 606 | bat_priv->tt.global_hash = batadv_hash_new(1024); |
607 | 607 | ||
608 | if (!bat_priv->tt_global_hash) | 608 | if (!bat_priv->tt.global_hash) |
609 | return -ENOMEM; | 609 | return -ENOMEM; |
610 | 610 | ||
611 | return 0; | 611 | return 0; |
@@ -615,16 +615,16 @@ static void batadv_tt_changes_list_free(struct batadv_priv *bat_priv) | |||
615 | { | 615 | { |
616 | struct batadv_tt_change_node *entry, *safe; | 616 | struct batadv_tt_change_node *entry, *safe; |
617 | 617 | ||
618 | spin_lock_bh(&bat_priv->tt_changes_list_lock); | 618 | spin_lock_bh(&bat_priv->tt.changes_list_lock); |
619 | 619 | ||
620 | list_for_each_entry_safe(entry, safe, &bat_priv->tt_changes_list, | 620 | list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list, |
621 | list) { | 621 | list) { |
622 | list_del(&entry->list); | 622 | list_del(&entry->list); |
623 | kfree(entry); | 623 | kfree(entry); |
624 | } | 624 | } |
625 | 625 | ||
626 | atomic_set(&bat_priv->tt_local_changes, 0); | 626 | atomic_set(&bat_priv->tt.local_changes, 0); |
627 | spin_unlock_bh(&bat_priv->tt_changes_list_lock); | 627 | spin_unlock_bh(&bat_priv->tt.changes_list_lock); |
628 | } | 628 | } |
629 | 629 | ||
630 | /* retrieves the orig_tt_list_entry belonging to orig_node from the | 630 | /* retrieves the orig_tt_list_entry belonging to orig_node from the |
@@ -733,7 +733,7 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
733 | INIT_HLIST_HEAD(&tt_global_entry->orig_list); | 733 | INIT_HLIST_HEAD(&tt_global_entry->orig_list); |
734 | spin_lock_init(&tt_global_entry->list_lock); | 734 | spin_lock_init(&tt_global_entry->list_lock); |
735 | 735 | ||
736 | hash_added = batadv_hash_add(bat_priv->tt_global_hash, | 736 | hash_added = batadv_hash_add(bat_priv->tt.global_hash, |
737 | batadv_compare_tt, | 737 | batadv_compare_tt, |
738 | batadv_choose_orig, common, | 738 | batadv_choose_orig, common, |
739 | &common->hash_entry); | 739 | &common->hash_entry); |
@@ -812,7 +812,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
812 | { | 812 | { |
813 | struct net_device *net_dev = (struct net_device *)seq->private; | 813 | struct net_device *net_dev = (struct net_device *)seq->private; |
814 | struct batadv_priv *bat_priv = netdev_priv(net_dev); | 814 | struct batadv_priv *bat_priv = netdev_priv(net_dev); |
815 | struct batadv_hashtable *hash = bat_priv->tt_global_hash; | 815 | struct batadv_hashtable *hash = bat_priv->tt.global_hash; |
816 | struct batadv_tt_common_entry *tt_common_entry; | 816 | struct batadv_tt_common_entry *tt_common_entry; |
817 | struct batadv_tt_global_entry *tt_global; | 817 | struct batadv_tt_global_entry *tt_global; |
818 | struct batadv_hard_iface *primary_if; | 818 | struct batadv_hard_iface *primary_if; |
@@ -913,7 +913,7 @@ batadv_tt_global_del_struct(struct batadv_priv *bat_priv, | |||
913 | "Deleting global tt entry %pM: %s\n", | 913 | "Deleting global tt entry %pM: %s\n", |
914 | tt_global_entry->common.addr, message); | 914 | tt_global_entry->common.addr, message); |
915 | 915 | ||
916 | batadv_hash_remove(bat_priv->tt_global_hash, batadv_compare_tt, | 916 | batadv_hash_remove(bat_priv->tt.global_hash, batadv_compare_tt, |
917 | batadv_choose_orig, tt_global_entry->common.addr); | 917 | batadv_choose_orig, tt_global_entry->common.addr); |
918 | batadv_tt_global_entry_free_ref(tt_global_entry); | 918 | batadv_tt_global_entry_free_ref(tt_global_entry); |
919 | 919 | ||
@@ -1024,7 +1024,7 @@ void batadv_tt_global_del_orig(struct batadv_priv *bat_priv, | |||
1024 | struct batadv_tt_global_entry *tt_global; | 1024 | struct batadv_tt_global_entry *tt_global; |
1025 | struct batadv_tt_common_entry *tt_common_entry; | 1025 | struct batadv_tt_common_entry *tt_common_entry; |
1026 | uint32_t i; | 1026 | uint32_t i; |
1027 | struct batadv_hashtable *hash = bat_priv->tt_global_hash; | 1027 | struct batadv_hashtable *hash = bat_priv->tt.global_hash; |
1028 | struct hlist_node *node, *safe; | 1028 | struct hlist_node *node, *safe; |
1029 | struct hlist_head *head; | 1029 | struct hlist_head *head; |
1030 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1030 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
@@ -1088,7 +1088,7 @@ static void batadv_tt_global_roam_purge_list(struct batadv_priv *bat_priv, | |||
1088 | 1088 | ||
1089 | static void batadv_tt_global_roam_purge(struct batadv_priv *bat_priv) | 1089 | static void batadv_tt_global_roam_purge(struct batadv_priv *bat_priv) |
1090 | { | 1090 | { |
1091 | struct batadv_hashtable *hash = bat_priv->tt_global_hash; | 1091 | struct batadv_hashtable *hash = bat_priv->tt.global_hash; |
1092 | struct hlist_head *head; | 1092 | struct hlist_head *head; |
1093 | spinlock_t *list_lock; /* protects write access to the hash lists */ | 1093 | spinlock_t *list_lock; /* protects write access to the hash lists */ |
1094 | uint32_t i; | 1094 | uint32_t i; |
@@ -1114,10 +1114,10 @@ static void batadv_tt_global_table_free(struct batadv_priv *bat_priv) | |||
1114 | struct hlist_head *head; | 1114 | struct hlist_head *head; |
1115 | uint32_t i; | 1115 | uint32_t i; |
1116 | 1116 | ||
1117 | if (!bat_priv->tt_global_hash) | 1117 | if (!bat_priv->tt.global_hash) |
1118 | return; | 1118 | return; |
1119 | 1119 | ||
1120 | hash = bat_priv->tt_global_hash; | 1120 | hash = bat_priv->tt.global_hash; |
1121 | 1121 | ||
1122 | for (i = 0; i < hash->size; i++) { | 1122 | for (i = 0; i < hash->size; i++) { |
1123 | head = &hash->table[i]; | 1123 | head = &hash->table[i]; |
@@ -1137,7 +1137,7 @@ static void batadv_tt_global_table_free(struct batadv_priv *bat_priv) | |||
1137 | 1137 | ||
1138 | batadv_hash_destroy(hash); | 1138 | batadv_hash_destroy(hash); |
1139 | 1139 | ||
1140 | bat_priv->tt_global_hash = NULL; | 1140 | bat_priv->tt.global_hash = NULL; |
1141 | } | 1141 | } |
1142 | 1142 | ||
1143 | static bool | 1143 | static bool |
@@ -1216,7 +1216,7 @@ static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | |||
1216 | struct batadv_orig_node *orig_node) | 1216 | struct batadv_orig_node *orig_node) |
1217 | { | 1217 | { |
1218 | uint16_t total = 0, total_one; | 1218 | uint16_t total = 0, total_one; |
1219 | struct batadv_hashtable *hash = bat_priv->tt_global_hash; | 1219 | struct batadv_hashtable *hash = bat_priv->tt.global_hash; |
1220 | struct batadv_tt_common_entry *tt_common; | 1220 | struct batadv_tt_common_entry *tt_common; |
1221 | struct batadv_tt_global_entry *tt_global; | 1221 | struct batadv_tt_global_entry *tt_global; |
1222 | struct hlist_node *node; | 1222 | struct hlist_node *node; |
@@ -1263,7 +1263,7 @@ static uint16_t batadv_tt_global_crc(struct batadv_priv *bat_priv, | |||
1263 | static uint16_t batadv_tt_local_crc(struct batadv_priv *bat_priv) | 1263 | static uint16_t batadv_tt_local_crc(struct batadv_priv *bat_priv) |
1264 | { | 1264 | { |
1265 | uint16_t total = 0, total_one; | 1265 | uint16_t total = 0, total_one; |
1266 | struct batadv_hashtable *hash = bat_priv->tt_local_hash; | 1266 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
1267 | struct batadv_tt_common_entry *tt_common; | 1267 | struct batadv_tt_common_entry *tt_common; |
1268 | struct hlist_node *node; | 1268 | struct hlist_node *node; |
1269 | struct hlist_head *head; | 1269 | struct hlist_head *head; |
@@ -1296,14 +1296,14 @@ static void batadv_tt_req_list_free(struct batadv_priv *bat_priv) | |||
1296 | { | 1296 | { |
1297 | struct batadv_tt_req_node *node, *safe; | 1297 | struct batadv_tt_req_node *node, *safe; |
1298 | 1298 | ||
1299 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1299 | spin_lock_bh(&bat_priv->tt.req_list_lock); |
1300 | 1300 | ||
1301 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { | 1301 | list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) { |
1302 | list_del(&node->list); | 1302 | list_del(&node->list); |
1303 | kfree(node); | 1303 | kfree(node); |
1304 | } | 1304 | } |
1305 | 1305 | ||
1306 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1306 | spin_unlock_bh(&bat_priv->tt.req_list_lock); |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | static void batadv_tt_save_orig_buffer(struct batadv_priv *bat_priv, | 1309 | static void batadv_tt_save_orig_buffer(struct batadv_priv *bat_priv, |
@@ -1333,15 +1333,15 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv) | |||
1333 | { | 1333 | { |
1334 | struct batadv_tt_req_node *node, *safe; | 1334 | struct batadv_tt_req_node *node, *safe; |
1335 | 1335 | ||
1336 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1336 | spin_lock_bh(&bat_priv->tt.req_list_lock); |
1337 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { | 1337 | list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) { |
1338 | if (batadv_has_timed_out(node->issued_at, | 1338 | if (batadv_has_timed_out(node->issued_at, |
1339 | BATADV_TT_REQUEST_TIMEOUT)) { | 1339 | BATADV_TT_REQUEST_TIMEOUT)) { |
1340 | list_del(&node->list); | 1340 | list_del(&node->list); |
1341 | kfree(node); | 1341 | kfree(node); |
1342 | } | 1342 | } |
1343 | } | 1343 | } |
1344 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1344 | spin_unlock_bh(&bat_priv->tt.req_list_lock); |
1345 | } | 1345 | } |
1346 | 1346 | ||
1347 | /* returns the pointer to the new tt_req_node struct if no request | 1347 | /* returns the pointer to the new tt_req_node struct if no request |
@@ -1353,8 +1353,8 @@ batadv_new_tt_req_node(struct batadv_priv *bat_priv, | |||
1353 | { | 1353 | { |
1354 | struct batadv_tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; | 1354 | struct batadv_tt_req_node *tt_req_node_tmp, *tt_req_node = NULL; |
1355 | 1355 | ||
1356 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1356 | spin_lock_bh(&bat_priv->tt.req_list_lock); |
1357 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt_req_list, list) { | 1357 | list_for_each_entry(tt_req_node_tmp, &bat_priv->tt.req_list, list) { |
1358 | if (batadv_compare_eth(tt_req_node_tmp, orig_node) && | 1358 | if (batadv_compare_eth(tt_req_node_tmp, orig_node) && |
1359 | !batadv_has_timed_out(tt_req_node_tmp->issued_at, | 1359 | !batadv_has_timed_out(tt_req_node_tmp->issued_at, |
1360 | BATADV_TT_REQUEST_TIMEOUT)) | 1360 | BATADV_TT_REQUEST_TIMEOUT)) |
@@ -1368,9 +1368,9 @@ batadv_new_tt_req_node(struct batadv_priv *bat_priv, | |||
1368 | memcpy(tt_req_node->addr, orig_node->orig, ETH_ALEN); | 1368 | memcpy(tt_req_node->addr, orig_node->orig, ETH_ALEN); |
1369 | tt_req_node->issued_at = jiffies; | 1369 | tt_req_node->issued_at = jiffies; |
1370 | 1370 | ||
1371 | list_add(&tt_req_node->list, &bat_priv->tt_req_list); | 1371 | list_add(&tt_req_node->list, &bat_priv->tt.req_list); |
1372 | unlock: | 1372 | unlock: |
1373 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1373 | spin_unlock_bh(&bat_priv->tt.req_list_lock); |
1374 | return tt_req_node; | 1374 | return tt_req_node; |
1375 | } | 1375 | } |
1376 | 1376 | ||
@@ -1536,9 +1536,9 @@ out: | |||
1536 | if (ret) | 1536 | if (ret) |
1537 | kfree_skb(skb); | 1537 | kfree_skb(skb); |
1538 | if (ret && tt_req_node) { | 1538 | if (ret && tt_req_node) { |
1539 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1539 | spin_lock_bh(&bat_priv->tt.req_list_lock); |
1540 | list_del(&tt_req_node->list); | 1540 | list_del(&tt_req_node->list); |
1541 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1541 | spin_unlock_bh(&bat_priv->tt.req_list_lock); |
1542 | kfree(tt_req_node); | 1542 | kfree(tt_req_node); |
1543 | } | 1543 | } |
1544 | return ret; | 1544 | return ret; |
@@ -1629,7 +1629,7 @@ batadv_send_other_tt_response(struct batadv_priv *bat_priv, | |||
1629 | ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); | 1629 | ttvn = (uint8_t)atomic_read(&req_dst_orig_node->last_ttvn); |
1630 | 1630 | ||
1631 | skb = batadv_tt_response_fill_table(tt_len, ttvn, | 1631 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1632 | bat_priv->tt_global_hash, | 1632 | bat_priv->tt.global_hash, |
1633 | primary_if, | 1633 | primary_if, |
1634 | batadv_tt_global_valid, | 1634 | batadv_tt_global_valid, |
1635 | req_dst_orig_node); | 1635 | req_dst_orig_node); |
@@ -1700,7 +1700,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1700 | (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); | 1700 | (tt_request->flags & BATADV_TT_FULL_TABLE ? 'F' : '.')); |
1701 | 1701 | ||
1702 | 1702 | ||
1703 | my_ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); | 1703 | my_ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); |
1704 | req_ttvn = tt_request->ttvn; | 1704 | req_ttvn = tt_request->ttvn; |
1705 | 1705 | ||
1706 | orig_node = batadv_orig_hash_find(bat_priv, tt_request->src); | 1706 | orig_node = batadv_orig_hash_find(bat_priv, tt_request->src); |
@@ -1719,7 +1719,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1719 | * is too big send the whole local translation table | 1719 | * is too big send the whole local translation table |
1720 | */ | 1720 | */ |
1721 | if (tt_request->flags & BATADV_TT_FULL_TABLE || my_ttvn != req_ttvn || | 1721 | if (tt_request->flags & BATADV_TT_FULL_TABLE || my_ttvn != req_ttvn || |
1722 | !bat_priv->tt_buff) | 1722 | !bat_priv->tt.last_changeset) |
1723 | full_table = true; | 1723 | full_table = true; |
1724 | else | 1724 | else |
1725 | full_table = false; | 1725 | full_table = false; |
@@ -1728,8 +1728,8 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1728 | * I'll send only one packet with as much TT entries as I can | 1728 | * I'll send only one packet with as much TT entries as I can |
1729 | */ | 1729 | */ |
1730 | if (!full_table) { | 1730 | if (!full_table) { |
1731 | spin_lock_bh(&bat_priv->tt_buff_lock); | 1731 | spin_lock_bh(&bat_priv->tt.last_changeset_lock); |
1732 | tt_len = bat_priv->tt_buff_len; | 1732 | tt_len = bat_priv->tt.last_changeset_len; |
1733 | tt_tot = tt_len / sizeof(struct batadv_tt_change); | 1733 | tt_tot = tt_len / sizeof(struct batadv_tt_change); |
1734 | 1734 | ||
1735 | len = sizeof(*tt_response) + tt_len; | 1735 | len = sizeof(*tt_response) + tt_len; |
@@ -1744,16 +1744,16 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1744 | tt_response->tt_data = htons(tt_tot); | 1744 | tt_response->tt_data = htons(tt_tot); |
1745 | 1745 | ||
1746 | tt_buff = skb->data + sizeof(*tt_response); | 1746 | tt_buff = skb->data + sizeof(*tt_response); |
1747 | memcpy(tt_buff, bat_priv->tt_buff, | 1747 | memcpy(tt_buff, bat_priv->tt.last_changeset, |
1748 | bat_priv->tt_buff_len); | 1748 | bat_priv->tt.last_changeset_len); |
1749 | spin_unlock_bh(&bat_priv->tt_buff_lock); | 1749 | spin_unlock_bh(&bat_priv->tt.last_changeset_lock); |
1750 | } else { | 1750 | } else { |
1751 | tt_len = (uint16_t)atomic_read(&bat_priv->num_local_tt); | 1751 | tt_len = (uint16_t)atomic_read(&bat_priv->tt.local_entry_num); |
1752 | tt_len *= sizeof(struct batadv_tt_change); | 1752 | tt_len *= sizeof(struct batadv_tt_change); |
1753 | ttvn = (uint8_t)atomic_read(&bat_priv->ttvn); | 1753 | ttvn = (uint8_t)atomic_read(&bat_priv->tt.vn); |
1754 | 1754 | ||
1755 | skb = batadv_tt_response_fill_table(tt_len, ttvn, | 1755 | skb = batadv_tt_response_fill_table(tt_len, ttvn, |
1756 | bat_priv->tt_local_hash, | 1756 | bat_priv->tt.local_hash, |
1757 | primary_if, | 1757 | primary_if, |
1758 | batadv_tt_local_valid_entry, | 1758 | batadv_tt_local_valid_entry, |
1759 | NULL); | 1759 | NULL); |
@@ -1785,7 +1785,7 @@ batadv_send_my_tt_response(struct batadv_priv *bat_priv, | |||
1785 | goto out; | 1785 | goto out; |
1786 | 1786 | ||
1787 | unlock: | 1787 | unlock: |
1788 | spin_unlock_bh(&bat_priv->tt_buff_lock); | 1788 | spin_unlock_bh(&bat_priv->tt.last_changeset_lock); |
1789 | out: | 1789 | out: |
1790 | if (orig_node) | 1790 | if (orig_node) |
1791 | batadv_orig_node_free_ref(orig_node); | 1791 | batadv_orig_node_free_ref(orig_node); |
@@ -1938,14 +1938,14 @@ void batadv_handle_tt_response(struct batadv_priv *bat_priv, | |||
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | /* Delete the tt_req_node from pending tt_requests list */ | 1940 | /* Delete the tt_req_node from pending tt_requests list */ |
1941 | spin_lock_bh(&bat_priv->tt_req_list_lock); | 1941 | spin_lock_bh(&bat_priv->tt.req_list_lock); |
1942 | list_for_each_entry_safe(node, safe, &bat_priv->tt_req_list, list) { | 1942 | list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) { |
1943 | if (!batadv_compare_eth(node->addr, tt_response->src)) | 1943 | if (!batadv_compare_eth(node->addr, tt_response->src)) |
1944 | continue; | 1944 | continue; |
1945 | list_del(&node->list); | 1945 | list_del(&node->list); |
1946 | kfree(node); | 1946 | kfree(node); |
1947 | } | 1947 | } |
1948 | spin_unlock_bh(&bat_priv->tt_req_list_lock); | 1948 | spin_unlock_bh(&bat_priv->tt.req_list_lock); |
1949 | 1949 | ||
1950 | /* Recalculate the CRC for this orig_node and store it */ | 1950 | /* Recalculate the CRC for this orig_node and store it */ |
1951 | orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node); | 1951 | orig_node->tt_crc = batadv_tt_global_crc(bat_priv, orig_node); |
@@ -1979,22 +1979,22 @@ static void batadv_tt_roam_list_free(struct batadv_priv *bat_priv) | |||
1979 | { | 1979 | { |
1980 | struct batadv_tt_roam_node *node, *safe; | 1980 | struct batadv_tt_roam_node *node, *safe; |
1981 | 1981 | ||
1982 | spin_lock_bh(&bat_priv->tt_roam_list_lock); | 1982 | spin_lock_bh(&bat_priv->tt.roam_list_lock); |
1983 | 1983 | ||
1984 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { | 1984 | list_for_each_entry_safe(node, safe, &bat_priv->tt.roam_list, list) { |
1985 | list_del(&node->list); | 1985 | list_del(&node->list); |
1986 | kfree(node); | 1986 | kfree(node); |
1987 | } | 1987 | } |
1988 | 1988 | ||
1989 | spin_unlock_bh(&bat_priv->tt_roam_list_lock); | 1989 | spin_unlock_bh(&bat_priv->tt.roam_list_lock); |
1990 | } | 1990 | } |
1991 | 1991 | ||
1992 | static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) | 1992 | static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) |
1993 | { | 1993 | { |
1994 | struct batadv_tt_roam_node *node, *safe; | 1994 | struct batadv_tt_roam_node *node, *safe; |
1995 | 1995 | ||
1996 | spin_lock_bh(&bat_priv->tt_roam_list_lock); | 1996 | spin_lock_bh(&bat_priv->tt.roam_list_lock); |
1997 | list_for_each_entry_safe(node, safe, &bat_priv->tt_roam_list, list) { | 1997 | list_for_each_entry_safe(node, safe, &bat_priv->tt.roam_list, list) { |
1998 | if (!batadv_has_timed_out(node->first_time, | 1998 | if (!batadv_has_timed_out(node->first_time, |
1999 | BATADV_ROAMING_MAX_TIME)) | 1999 | BATADV_ROAMING_MAX_TIME)) |
2000 | continue; | 2000 | continue; |
@@ -2002,7 +2002,7 @@ static void batadv_tt_roam_purge(struct batadv_priv *bat_priv) | |||
2002 | list_del(&node->list); | 2002 | list_del(&node->list); |
2003 | kfree(node); | 2003 | kfree(node); |
2004 | } | 2004 | } |
2005 | spin_unlock_bh(&bat_priv->tt_roam_list_lock); | 2005 | spin_unlock_bh(&bat_priv->tt.roam_list_lock); |
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | /* This function checks whether the client already reached the | 2008 | /* This function checks whether the client already reached the |
@@ -2017,11 +2017,11 @@ static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, | |||
2017 | struct batadv_tt_roam_node *tt_roam_node; | 2017 | struct batadv_tt_roam_node *tt_roam_node; |
2018 | bool ret = false; | 2018 | bool ret = false; |
2019 | 2019 | ||
2020 | spin_lock_bh(&bat_priv->tt_roam_list_lock); | 2020 | spin_lock_bh(&bat_priv->tt.roam_list_lock); |
2021 | /* The new tt_req will be issued only if I'm not waiting for a | 2021 | /* The new tt_req will be issued only if I'm not waiting for a |
2022 | * reply from the same orig_node yet | 2022 | * reply from the same orig_node yet |
2023 | */ | 2023 | */ |
2024 | list_for_each_entry(tt_roam_node, &bat_priv->tt_roam_list, list) { | 2024 | list_for_each_entry(tt_roam_node, &bat_priv->tt.roam_list, list) { |
2025 | if (!batadv_compare_eth(tt_roam_node->addr, client)) | 2025 | if (!batadv_compare_eth(tt_roam_node->addr, client)) |
2026 | continue; | 2026 | continue; |
2027 | 2027 | ||
@@ -2046,12 +2046,12 @@ static bool batadv_tt_check_roam_count(struct batadv_priv *bat_priv, | |||
2046 | BATADV_ROAMING_MAX_COUNT - 1); | 2046 | BATADV_ROAMING_MAX_COUNT - 1); |
2047 | memcpy(tt_roam_node->addr, client, ETH_ALEN); | 2047 | memcpy(tt_roam_node->addr, client, ETH_ALEN); |
2048 | 2048 | ||
2049 | list_add(&tt_roam_node->list, &bat_priv->tt_roam_list); | 2049 | list_add(&tt_roam_node->list, &bat_priv->tt.roam_list); |
2050 | ret = true; | 2050 | ret = true; |
2051 | } | 2051 | } |
2052 | 2052 | ||
2053 | unlock: | 2053 | unlock: |
2054 | spin_unlock_bh(&bat_priv->tt_roam_list_lock); | 2054 | spin_unlock_bh(&bat_priv->tt.roam_list_lock); |
2055 | return ret; | 2055 | return ret; |
2056 | } | 2056 | } |
2057 | 2057 | ||
@@ -2115,10 +2115,12 @@ out: | |||
2115 | static void batadv_tt_purge(struct work_struct *work) | 2115 | static void batadv_tt_purge(struct work_struct *work) |
2116 | { | 2116 | { |
2117 | struct delayed_work *delayed_work; | 2117 | struct delayed_work *delayed_work; |
2118 | struct batadv_priv_tt *priv_tt; | ||
2118 | struct batadv_priv *bat_priv; | 2119 | struct batadv_priv *bat_priv; |
2119 | 2120 | ||
2120 | delayed_work = container_of(work, struct delayed_work, work); | 2121 | delayed_work = container_of(work, struct delayed_work, work); |
2121 | bat_priv = container_of(delayed_work, struct batadv_priv, tt_work); | 2122 | priv_tt = container_of(delayed_work, struct batadv_priv_tt, work); |
2123 | bat_priv = container_of(priv_tt, struct batadv_priv, tt); | ||
2122 | 2124 | ||
2123 | batadv_tt_local_purge(bat_priv); | 2125 | batadv_tt_local_purge(bat_priv); |
2124 | batadv_tt_global_roam_purge(bat_priv); | 2126 | batadv_tt_global_roam_purge(bat_priv); |
@@ -2130,7 +2132,7 @@ static void batadv_tt_purge(struct work_struct *work) | |||
2130 | 2132 | ||
2131 | void batadv_tt_free(struct batadv_priv *bat_priv) | 2133 | void batadv_tt_free(struct batadv_priv *bat_priv) |
2132 | { | 2134 | { |
2133 | cancel_delayed_work_sync(&bat_priv->tt_work); | 2135 | cancel_delayed_work_sync(&bat_priv->tt.work); |
2134 | 2136 | ||
2135 | batadv_tt_local_table_free(bat_priv); | 2137 | batadv_tt_local_table_free(bat_priv); |
2136 | batadv_tt_global_table_free(bat_priv); | 2138 | batadv_tt_global_table_free(bat_priv); |
@@ -2138,7 +2140,7 @@ void batadv_tt_free(struct batadv_priv *bat_priv) | |||
2138 | batadv_tt_changes_list_free(bat_priv); | 2140 | batadv_tt_changes_list_free(bat_priv); |
2139 | batadv_tt_roam_list_free(bat_priv); | 2141 | batadv_tt_roam_list_free(bat_priv); |
2140 | 2142 | ||
2141 | kfree(bat_priv->tt_buff); | 2143 | kfree(bat_priv->tt.last_changeset); |
2142 | } | 2144 | } |
2143 | 2145 | ||
2144 | /* This function will enable or disable the specified flags for all the entries | 2146 | /* This function will enable or disable the specified flags for all the entries |
@@ -2182,7 +2184,7 @@ out: | |||
2182 | /* Purge out all the tt local entries marked with BATADV_TT_CLIENT_PENDING */ | 2184 | /* Purge out all the tt local entries marked with BATADV_TT_CLIENT_PENDING */ |
2183 | static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) | 2185 | static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) |
2184 | { | 2186 | { |
2185 | struct batadv_hashtable *hash = bat_priv->tt_local_hash; | 2187 | struct batadv_hashtable *hash = bat_priv->tt.local_hash; |
2186 | struct batadv_tt_common_entry *tt_common; | 2188 | struct batadv_tt_common_entry *tt_common; |
2187 | struct batadv_tt_local_entry *tt_local; | 2189 | struct batadv_tt_local_entry *tt_local; |
2188 | struct hlist_node *node, *node_tmp; | 2190 | struct hlist_node *node, *node_tmp; |
@@ -2207,7 +2209,7 @@ static void batadv_tt_local_purge_pending_clients(struct batadv_priv *bat_priv) | |||
2207 | "Deleting local tt entry (%pM): pending\n", | 2209 | "Deleting local tt entry (%pM): pending\n", |
2208 | tt_common->addr); | 2210 | tt_common->addr); |
2209 | 2211 | ||
2210 | atomic_dec(&bat_priv->num_local_tt); | 2212 | atomic_dec(&bat_priv->tt.local_entry_num); |
2211 | hlist_del_rcu(node); | 2213 | hlist_del_rcu(node); |
2212 | tt_local = container_of(tt_common, | 2214 | tt_local = container_of(tt_common, |
2213 | struct batadv_tt_local_entry, | 2215 | struct batadv_tt_local_entry, |
@@ -2225,26 +2227,26 @@ static int batadv_tt_commit_changes(struct batadv_priv *bat_priv, | |||
2225 | { | 2227 | { |
2226 | uint16_t changed_num = 0; | 2228 | uint16_t changed_num = 0; |
2227 | 2229 | ||
2228 | if (atomic_read(&bat_priv->tt_local_changes) < 1) | 2230 | if (atomic_read(&bat_priv->tt.local_changes) < 1) |
2229 | return -ENOENT; | 2231 | return -ENOENT; |
2230 | 2232 | ||
2231 | changed_num = batadv_tt_set_flags(bat_priv->tt_local_hash, | 2233 | changed_num = batadv_tt_set_flags(bat_priv->tt.local_hash, |
2232 | BATADV_TT_CLIENT_NEW, false); | 2234 | BATADV_TT_CLIENT_NEW, false); |
2233 | 2235 | ||
2234 | /* all reset entries have to be counted as local entries */ | 2236 | /* all reset entries have to be counted as local entries */ |
2235 | atomic_add(changed_num, &bat_priv->num_local_tt); | 2237 | atomic_add(changed_num, &bat_priv->tt.local_entry_num); |
2236 | batadv_tt_local_purge_pending_clients(bat_priv); | 2238 | batadv_tt_local_purge_pending_clients(bat_priv); |
2237 | bat_priv->tt_crc = batadv_tt_local_crc(bat_priv); | 2239 | bat_priv->tt.local_crc = batadv_tt_local_crc(bat_priv); |
2238 | 2240 | ||
2239 | /* Increment the TTVN only once per OGM interval */ | 2241 | /* Increment the TTVN only once per OGM interval */ |
2240 | atomic_inc(&bat_priv->ttvn); | 2242 | atomic_inc(&bat_priv->tt.vn); |
2241 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 2243 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
2242 | "Local changes committed, updating to ttvn %u\n", | 2244 | "Local changes committed, updating to ttvn %u\n", |
2243 | (uint8_t)atomic_read(&bat_priv->ttvn)); | 2245 | (uint8_t)atomic_read(&bat_priv->tt.vn)); |
2244 | bat_priv->tt_poss_change = false; | 2246 | bat_priv->tt.poss_change = false; |
2245 | 2247 | ||
2246 | /* reset the sending counter */ | 2248 | /* reset the sending counter */ |
2247 | atomic_set(&bat_priv->tt_ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX); | 2249 | atomic_set(&bat_priv->tt.ogm_append_cnt, BATADV_TT_OGM_APPEND_MAX); |
2248 | 2250 | ||
2249 | return batadv_tt_changes_fill_buff(bat_priv, packet_buff, | 2251 | return batadv_tt_changes_fill_buff(bat_priv, packet_buff, |
2250 | packet_buff_len, packet_min_len); | 2252 | packet_buff_len, packet_min_len); |
@@ -2264,7 +2266,7 @@ int batadv_tt_append_diff(struct batadv_priv *bat_priv, | |||
2264 | 2266 | ||
2265 | /* if the changes have been sent often enough */ | 2267 | /* if the changes have been sent often enough */ |
2266 | if ((tt_num_changes < 0) && | 2268 | if ((tt_num_changes < 0) && |
2267 | (!batadv_atomic_dec_not_zero(&bat_priv->tt_ogm_append_cnt))) { | 2269 | (!batadv_atomic_dec_not_zero(&bat_priv->tt.ogm_append_cnt))) { |
2268 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, | 2270 | batadv_tt_realloc_packet_buff(packet_buff, packet_buff_len, |
2269 | packet_min_len, packet_min_len); | 2271 | packet_min_len, packet_min_len); |
2270 | tt_num_changes = 0; | 2272 | tt_num_changes = 0; |