diff options
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r-- | net/batman-adv/translation-table.c | 77 |
1 files changed, 39 insertions, 38 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 112edd371b2f..a570d957a5a0 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -434,22 +434,10 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
434 | struct hlist_node *node; | 434 | struct hlist_node *node; |
435 | struct hlist_head *head; | 435 | struct hlist_head *head; |
436 | uint32_t i; | 436 | uint32_t i; |
437 | int ret = 0; | ||
438 | |||
439 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
440 | if (!primary_if) { | ||
441 | ret = seq_printf(seq, | ||
442 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
443 | net_dev->name); | ||
444 | goto out; | ||
445 | } | ||
446 | 437 | ||
447 | if (primary_if->if_status != BATADV_IF_ACTIVE) { | 438 | primary_if = batadv_seq_print_text_primary_if_get(seq); |
448 | ret = seq_printf(seq, | 439 | if (!primary_if) |
449 | "BATMAN mesh %s disabled - primary interface not active\n", | ||
450 | net_dev->name); | ||
451 | goto out; | 440 | goto out; |
452 | } | ||
453 | 441 | ||
454 | seq_printf(seq, | 442 | seq_printf(seq, |
455 | "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", | 443 | "Locally retrieved addresses (from %s) announced via TT (TTVN: %u):\n", |
@@ -479,7 +467,7 @@ int batadv_tt_local_seq_print_text(struct seq_file *seq, void *offset) | |||
479 | out: | 467 | out: |
480 | if (primary_if) | 468 | if (primary_if) |
481 | batadv_hardif_free_ref(primary_if); | 469 | batadv_hardif_free_ref(primary_if); |
482 | return ret; | 470 | return 0; |
483 | } | 471 | } |
484 | 472 | ||
485 | static void | 473 | static void |
@@ -501,24 +489,39 @@ batadv_tt_local_set_pending(struct batadv_priv *bat_priv, | |||
501 | tt_local_entry->common.addr, message); | 489 | tt_local_entry->common.addr, message); |
502 | } | 490 | } |
503 | 491 | ||
504 | void batadv_tt_local_remove(struct batadv_priv *bat_priv, const uint8_t *addr, | 492 | /** |
505 | const char *message, bool roaming) | 493 | * batadv_tt_local_remove - logically remove an entry from the local table |
494 | * @bat_priv: the bat priv with all the soft interface information | ||
495 | * @addr: the MAC address of the client to remove | ||
496 | * @message: message to append to the log on deletion | ||
497 | * @roaming: true if the deletion is due to a roaming event | ||
498 | * | ||
499 | * Returns the flags assigned to the local entry before being deleted | ||
500 | */ | ||
501 | uint16_t batadv_tt_local_remove(struct batadv_priv *bat_priv, | ||
502 | const uint8_t *addr, const char *message, | ||
503 | bool roaming) | ||
506 | { | 504 | { |
507 | struct batadv_tt_local_entry *tt_local_entry = NULL; | 505 | struct batadv_tt_local_entry *tt_local_entry = NULL; |
508 | uint16_t flags; | 506 | uint16_t flags, curr_flags = BATADV_NO_FLAGS; |
509 | 507 | ||
510 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); | 508 | tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr); |
511 | if (!tt_local_entry) | 509 | if (!tt_local_entry) |
512 | goto out; | 510 | goto out; |
513 | 511 | ||
512 | curr_flags = tt_local_entry->common.flags; | ||
513 | |||
514 | flags = BATADV_TT_CLIENT_DEL; | 514 | flags = BATADV_TT_CLIENT_DEL; |
515 | if (roaming) | 515 | if (roaming) |
516 | flags |= BATADV_TT_CLIENT_ROAM; | 516 | flags |= BATADV_TT_CLIENT_ROAM; |
517 | 517 | ||
518 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); | 518 | batadv_tt_local_set_pending(bat_priv, tt_local_entry, flags, message); |
519 | |||
519 | out: | 520 | out: |
520 | if (tt_local_entry) | 521 | if (tt_local_entry) |
521 | batadv_tt_local_entry_free_ref(tt_local_entry); | 522 | batadv_tt_local_entry_free_ref(tt_local_entry); |
523 | |||
524 | return curr_flags; | ||
522 | } | 525 | } |
523 | 526 | ||
524 | static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv, | 527 | static void batadv_tt_local_purge_list(struct batadv_priv *bat_priv, |
@@ -725,6 +728,7 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
725 | int ret = 0; | 728 | int ret = 0; |
726 | int hash_added; | 729 | int hash_added; |
727 | struct batadv_tt_common_entry *common; | 730 | struct batadv_tt_common_entry *common; |
731 | uint16_t local_flags; | ||
728 | 732 | ||
729 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); | 733 | tt_global_entry = batadv_tt_global_hash_find(bat_priv, tt_addr); |
730 | 734 | ||
@@ -738,6 +742,12 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
738 | 742 | ||
739 | common->flags = flags; | 743 | common->flags = flags; |
740 | tt_global_entry->roam_at = 0; | 744 | tt_global_entry->roam_at = 0; |
745 | /* node must store current time in case of roaming. This is | ||
746 | * needed to purge this entry out on timeout (if nobody claims | ||
747 | * it) | ||
748 | */ | ||
749 | if (flags & BATADV_TT_CLIENT_ROAM) | ||
750 | tt_global_entry->roam_at = jiffies; | ||
741 | atomic_set(&common->refcount, 2); | 751 | atomic_set(&common->refcount, 2); |
742 | common->added_at = jiffies; | 752 | common->added_at = jiffies; |
743 | 753 | ||
@@ -788,13 +798,16 @@ int batadv_tt_global_add(struct batadv_priv *bat_priv, | |||
788 | batadv_dbg(BATADV_DBG_TT, bat_priv, | 798 | batadv_dbg(BATADV_DBG_TT, bat_priv, |
789 | "Creating new global tt entry: %pM (via %pM)\n", | 799 | "Creating new global tt entry: %pM (via %pM)\n", |
790 | tt_global_entry->common.addr, orig_node->orig); | 800 | tt_global_entry->common.addr, orig_node->orig); |
801 | ret = 1; | ||
791 | 802 | ||
792 | out_remove: | 803 | out_remove: |
804 | |||
793 | /* remove address from local hash if present */ | 805 | /* remove address from local hash if present */ |
794 | batadv_tt_local_remove(bat_priv, tt_global_entry->common.addr, | 806 | local_flags = batadv_tt_local_remove(bat_priv, tt_addr, |
795 | "global tt received", | 807 | "global tt received", |
796 | flags & BATADV_TT_CLIENT_ROAM); | 808 | flags & BATADV_TT_CLIENT_ROAM); |
797 | ret = 1; | 809 | tt_global_entry->common.flags |= local_flags & BATADV_TT_CLIENT_WIFI; |
810 | |||
798 | out: | 811 | out: |
799 | if (tt_global_entry) | 812 | if (tt_global_entry) |
800 | batadv_tt_global_entry_free_ref(tt_global_entry); | 813 | batadv_tt_global_entry_free_ref(tt_global_entry); |
@@ -842,22 +855,10 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
842 | struct hlist_node *node; | 855 | struct hlist_node *node; |
843 | struct hlist_head *head; | 856 | struct hlist_head *head; |
844 | uint32_t i; | 857 | uint32_t i; |
845 | int ret = 0; | ||
846 | |||
847 | primary_if = batadv_primary_if_get_selected(bat_priv); | ||
848 | if (!primary_if) { | ||
849 | ret = seq_printf(seq, | ||
850 | "BATMAN mesh %s disabled - please specify interfaces to enable it\n", | ||
851 | net_dev->name); | ||
852 | goto out; | ||
853 | } | ||
854 | 858 | ||
855 | if (primary_if->if_status != BATADV_IF_ACTIVE) { | 859 | primary_if = batadv_seq_print_text_primary_if_get(seq); |
856 | ret = seq_printf(seq, | 860 | if (!primary_if) |
857 | "BATMAN mesh %s disabled - primary interface not active\n", | ||
858 | net_dev->name); | ||
859 | goto out; | 861 | goto out; |
860 | } | ||
861 | 862 | ||
862 | seq_printf(seq, | 863 | seq_printf(seq, |
863 | "Globally announced TT entries received via the mesh %s\n", | 864 | "Globally announced TT entries received via the mesh %s\n", |
@@ -881,7 +882,7 @@ int batadv_tt_global_seq_print_text(struct seq_file *seq, void *offset) | |||
881 | out: | 882 | out: |
882 | if (primary_if) | 883 | if (primary_if) |
883 | batadv_hardif_free_ref(primary_if); | 884 | batadv_hardif_free_ref(primary_if); |
884 | return ret; | 885 | return 0; |
885 | } | 886 | } |
886 | 887 | ||
887 | /* deletes the orig list of a tt_global_entry */ | 888 | /* deletes the orig list of a tt_global_entry */ |
@@ -2438,7 +2439,7 @@ bool batadv_tt_global_client_is_roaming(struct batadv_priv *bat_priv, | |||
2438 | if (!tt_global_entry) | 2439 | if (!tt_global_entry) |
2439 | goto out; | 2440 | goto out; |
2440 | 2441 | ||
2441 | ret = tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM; | 2442 | ret = !!(tt_global_entry->common.flags & BATADV_TT_CLIENT_ROAM); |
2442 | batadv_tt_global_entry_free_ref(tt_global_entry); | 2443 | batadv_tt_global_entry_free_ref(tt_global_entry); |
2443 | out: | 2444 | out: |
2444 | return ret; | 2445 | return ret; |