Skip to content

Commit fca81aa

Browse files
repksimonwunderlich
authored andcommitted
batman-adv: Don't keep redundant TT change events
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 <[email protected]> Co-developed-by: Sven Eckelmann <[email protected]> Signed-off-by: Sven Eckelmann <[email protected]> Signed-off-by: Simon Wunderlich <[email protected]>
1 parent 8587e0e commit fca81aa

File tree

1 file changed

+18
-22
lines changed

1 file changed

+18
-22
lines changed

net/batman-adv/translation-table.c

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -438,38 +438,34 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
438438

439439
del_op_requested = flags & BATADV_TT_CLIENT_DEL;
440440

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

449-
/* DEL+ADD in the same orig interval have no effect and can be
450-
* removed to avoid silly behaviour on the receiver side. The
451-
* other way around (ADD+DEL) can happen in case of roaming of
452-
* a client still in the NEW state. Roaming of NEW clients is
453-
* now possible due to automatically recognition of "temporary"
454-
* clients
455-
*/
456449
del_op_entry = entry->change.flags & BATADV_TT_CLIENT_DEL;
457-
if (!del_op_requested && del_op_entry)
458-
goto del;
459-
if (del_op_requested && !del_op_entry)
460-
goto del;
461-
462-
/* this is a second add in the same originator interval. It
463-
* means that flags have been changed: update them!
464-
*/
465-
if (!del_op_requested && !del_op_entry)
450+
if (del_op_requested != del_op_entry) {
451+
/* DEL+ADD in the same orig interval have no effect and
452+
* can be removed to avoid silly behaviour on the
453+
* receiver side. The other way around (ADD+DEL) can
454+
* happen in case of roaming of a client still in the
455+
* NEW state. Roaming of NEW clients is now possible due
456+
* to automatically recognition of "temporary" clients
457+
*/
458+
list_del(&entry->list);
459+
kmem_cache_free(batadv_tt_change_cache, entry);
460+
changes--;
461+
} else {
462+
/* this is a second add or del in the same originator
463+
* interval. It could mean that flags have been changed
464+
* (e.g. double add): update them
465+
*/
466466
entry->change.flags = flags;
467+
}
467468

468-
continue;
469-
del:
470-
list_del(&entry->list);
471-
kmem_cache_free(batadv_tt_change_cache, entry);
472-
changes--;
473469
kmem_cache_free(batadv_tt_change_cache, tt_change_node);
474470
goto update_changes;
475471
}

0 commit comments

Comments
 (0)