aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv
diff options
context:
space:
mode:
Diffstat (limited to 'net/batman-adv')
-rw-r--r--net/batman-adv/translation-table.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index 76134bc5e513..f6bbd6423def 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1695,19 +1695,19 @@ void tt_free(struct bat_priv *bat_priv)
1695 kfree(bat_priv->tt_buff); 1695 kfree(bat_priv->tt_buff);
1696} 1696}
1697 1697
1698/* This function will reset the specified flags from all the entries in 1698/* This function will enable or disable the specified flags for all the entries
1699 * the given hash table and will increment num_local_tt for each involved 1699 * in the given hash table and returns the number of modified entries */
1700 * entry */ 1700static uint16_t tt_set_flags(struct hashtable_t *hash, uint16_t flags,
1701static void tt_local_reset_flags(struct bat_priv *bat_priv, uint16_t flags) 1701 bool enable)
1702{ 1702{
1703 uint32_t i; 1703 uint32_t i;
1704 struct hashtable_t *hash = bat_priv->tt_local_hash; 1704 uint16_t changed_num = 0;
1705 struct hlist_head *head; 1705 struct hlist_head *head;
1706 struct hlist_node *node; 1706 struct hlist_node *node;
1707 struct tt_common_entry *tt_common_entry; 1707 struct tt_common_entry *tt_common_entry;
1708 1708
1709 if (!hash) 1709 if (!hash)
1710 return; 1710 goto out;
1711 1711
1712 for (i = 0; i < hash->size; i++) { 1712 for (i = 0; i < hash->size; i++) {
1713 head = &hash->table[i]; 1713 head = &hash->table[i];
@@ -1715,14 +1715,21 @@ static void tt_local_reset_flags(struct bat_priv *bat_priv, uint16_t flags)
1715 rcu_read_lock(); 1715 rcu_read_lock();
1716 hlist_for_each_entry_rcu(tt_common_entry, node, 1716 hlist_for_each_entry_rcu(tt_common_entry, node,
1717 head, hash_entry) { 1717 head, hash_entry) {
1718 if (!(tt_common_entry->flags & flags)) 1718 if (enable) {
1719 continue; 1719 if ((tt_common_entry->flags & flags) == flags)
1720 tt_common_entry->flags &= ~flags; 1720 continue;
1721 atomic_inc(&bat_priv->num_local_tt); 1721 tt_common_entry->flags |= flags;
1722 } else {
1723 if (!(tt_common_entry->flags & flags))
1724 continue;
1725 tt_common_entry->flags &= ~flags;
1726 }
1727 changed_num++;
1722 } 1728 }
1723 rcu_read_unlock(); 1729 rcu_read_unlock();
1724 } 1730 }
1725 1731out:
1732 return changed_num;
1726} 1733}
1727 1734
1728/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */ 1735/* Purge out all the tt local entries marked with TT_CLIENT_PENDING */
@@ -1766,7 +1773,11 @@ static void tt_local_purge_pending_clients(struct bat_priv *bat_priv)
1766 1773
1767void tt_commit_changes(struct bat_priv *bat_priv) 1774void tt_commit_changes(struct bat_priv *bat_priv)
1768{ 1775{
1769 tt_local_reset_flags(bat_priv, TT_CLIENT_NEW); 1776 uint16_t changed_num = tt_set_flags(bat_priv->tt_local_hash,
1777 TT_CLIENT_NEW, false);
1778 /* all the reset entries have now to be effectively counted as local
1779 * entries */
1780 atomic_add(changed_num, &bat_priv->num_local_tt);
1770 tt_local_purge_pending_clients(bat_priv); 1781 tt_local_purge_pending_clients(bat_priv);
1771 1782
1772 /* Increment the TTVN only once per OGM interval */ 1783 /* Increment the TTVN only once per OGM interval */