Skip to content

Commit

Permalink
batman-adv: Don't keep redundant TT change events
Browse files Browse the repository at this point in the history
When adding a local TT twice within the same OGM interval (e.g. happens
when flag get updated), the flags of the first TT change entry is updated
with the second one and both change events is added to the change list.
This leads to having the same ADD change entry twice. Similarly, a
DEL+DEL scenario is also creating twice the same event.

Deduplicate ADD+ADD or DEL+DEL scenarios to reduce the TT change events
that need to be sent in both OGM and TT response.

Signed-off-by: Remi Pommarel <repk@triplefau.lt>
Co-developed-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
  • Loading branch information
Remi Pommarel authored and Simon Wunderlich committed Dec 5, 2024
1 parent 8587e0e commit fca81aa
Showing 1 changed file with 18 additions and 22 deletions.
40 changes: 18 additions & 22 deletions net/batman-adv/translation-table.c
Original file line number Diff line number Diff line change
@@ -438,38 +438,34 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,

del_op_requested = flags & BATADV_TT_CLIENT_DEL;

/* check for ADD+DEL or DEL+ADD events */
/* check for ADD+DEL, DEL+ADD, ADD+ADD or DEL+DEL events */
spin_lock_bh(&bat_priv->tt.changes_list_lock);
changes = READ_ONCE(bat_priv->tt.local_changes);
list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list,
list) {
if (!batadv_compare_eth(entry->change.addr, common->addr))
continue;

/* DEL+ADD in the same orig interval have no effect and can be
* removed to avoid silly behaviour on the receiver side. The
* other way around (ADD+DEL) can happen in case of roaming of
* a client still in the NEW state. Roaming of NEW clients is
* now possible due to automatically recognition of "temporary"
* clients
*/
del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL;
if (!del_op_requested && del_op_entry)
goto del;
if (del_op_requested && !del_op_entry)
goto del;

/* this is a second add in the same originator interval. It
* means that flags have been changed: update them!
*/
if (!del_op_requested && !del_op_entry)
if (del_op_requested != del_op_entry) {
/* DEL+ADD in the same orig interval have no effect and
* can be removed to avoid silly behaviour on the
* receiver side. The other way around (ADD+DEL) can
* happen in case of roaming of a client still in the
* NEW state. Roaming of NEW clients is now possible due
* to automatically recognition of "temporary" clients
*/
list_del(&entry->list);
kmem_cache_free(batadv_tt_change_cache, entry);
changes--;
} else {
/* this is a second add or del in the same originator
* interval. It could mean that flags have been changed
* (e.g. double add): update them
*/
entry->change.flags = flags;
}

continue;
del:
list_del(&entry->list);
kmem_cache_free(batadv_tt_change_cache, entry);
changes--;
kmem_cache_free(batadv_tt_change_cache, tt_change_node);
goto update_changes;
}

0 comments on commit fca81aa

Please sign in to comment.