Skip to content

Commit fff8f17

Browse files
repksimonwunderlich
authored andcommitted
batman-adv: Do not let TT changes list grows indefinitely
When TT changes list is too big to fit in packet due to MTU size, an empty OGM is sent expected other node to send TT request to get the changes. The issue is that tt.last_changeset was not built thus the originator was responding with previous changes to those TT requests (see batadv_send_my_tt_response). Also the changes list was never cleaned up effectively never ending growing from this point onwards, repeatedly sending the same TT response changes over and over, and creating a new empty OGM every OGM interval expecting for the local changes to be purged. When there is more TT changes that can fit in packet, drop all changes, send empty OGM and wait for TT request so we can respond with a full table instead. Fixes: e1bf0c1 ("batman-adv: tvlv - convert tt data sent within OGMs") Signed-off-by: Remi Pommarel <repk@triplefau.lt> Acked-by: Antonio Quartulli <Antonio@mandelbit.com> Signed-off-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
1 parent 8038806 commit fff8f17

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

net/batman-adv/translation-table.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -948,17 +948,25 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)
948948
int tt_diff_len, tt_change_len = 0;
949949
int tt_diff_entries_num = 0;
950950
int tt_diff_entries_count = 0;
951+
bool drop_changes = false;
951952
size_t tt_extra_len = 0;
952953
u16 tvlv_len;
953954

954955
tt_diff_entries_num = atomic_read(&bat_priv->tt.local_changes);
955956
tt_diff_len = batadv_tt_len(tt_diff_entries_num);
956957

957958
/* if we have too many changes for one packet don't send any
958-
* and wait for the tt table request which will be fragmented
959+
* and wait for the tt table request so we can reply with the full
960+
* (fragmented) table.
961+
*
962+
* The local change history should still be cleaned up so the next
963+
* TT round can start again with a clean state.
959964
*/
960-
if (tt_diff_len > bat_priv->soft_iface->mtu)
965+
if (tt_diff_len > bat_priv->soft_iface->mtu) {
961966
tt_diff_len = 0;
967+
tt_diff_entries_num = 0;
968+
drop_changes = true;
969+
}
962970

963971
tvlv_len = batadv_tt_prepare_tvlv_local_data(bat_priv, &tt_data,
964972
&tt_change, &tt_diff_len);
@@ -967,7 +975,7 @@ static void batadv_tt_tvlv_container_update(struct batadv_priv *bat_priv)
967975

968976
tt_data->flags = BATADV_TT_OGM_DIFF;
969977

970-
if (tt_diff_len == 0)
978+
if (!drop_changes && tt_diff_len == 0)
971979
goto container_register;
972980

973981
spin_lock_bh(&bat_priv->tt.changes_list_lock);

0 commit comments

Comments
 (0)