[PATCH batadv v2 5/6] batman-adv: tt: decrement count for committed client on local_remove
Sven Eckelmann <[email protected]>
| Newsgroups | org.open-mesh.lists.batman |
|---|---|
| Message-ID | <[email protected]> |
Local TT entries which have the BATADV_TT_CLIENT_NEW no longer set are committed. The batadv_tt_local_size_inc() was called for them and thus the batadv_tt_local_size_dec() has to be called also when batadv_tt_local_remove() is called for them when the BATADV_TT_CLIENT_NEW wasn't consumed in the remove path. Signed-off-by: Sven Eckelmann <[email protected]> --- net/batman-adv/translation-table.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index cf13ea2f..28575051 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -1418,6 +1418,7 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr, struct batadv_tt_local_entry *tt_local_entry; struct hlist_node *tt_removed_node; u16 curr_flags = BATADV_NO_FLAGS; + u16 old_flags; u16 flags; tt_local_entry = batadv_tt_local_hash_find(bat_priv, addr, vid); @@ -1463,6 +1464,15 @@ u16 batadv_tt_local_remove(struct batadv_priv *bat_priv, const u8 *addr, if (!tt_removed_node) goto out; + /* batadv_tt_local_transition_new() may have committed the entry and + * thus counted it in the local table size since the BATADV_TT_CLIENT_NEW + * check above. + */ + old_flags = atomic_fetch_andnot(BATADV_TT_CLIENT_NEW, + &tt_local_entry->common.flags); + if (!(old_flags & BATADV_TT_CLIENT_NEW)) + batadv_tt_local_size_dec(bat_priv, tt_local_entry->common.vid); + /* drop reference of remove hash entry */ batadv_tt_local_entry_put(tt_local_entry); -- 2.47.3