Commit 17071578 authored by Antonio Quartulli's avatar Antonio Quartulli Committed by Marek Lindner

batman-adv: add tt_initialised flag to the orig_node struct

(ttvn == 0) is currently used as initial condition. However this is not a good
idea because ttvn gets the vale zero each time after reaching the maximum value
(wrap around). For this reason a new flag is added in order to define whether a
node has an initialised table or not. Moreover, after invoking
tt_global_del_orig(), tt_initialised has to be set to false
Reported-by: default avatarAlexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
Signed-off-by: default avatarSimon Wunderlich <siwu@hrz.tu-chemnitz.de>
Tested-by: default avatarAlexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
parent dcd6c922
...@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) ...@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr)
/* extra reference for return */ /* extra reference for return */
atomic_set(&orig_node->refcount, 2); atomic_set(&orig_node->refcount, 2);
orig_node->tt_initialised = false;
orig_node->tt_poss_change = false; orig_node->tt_poss_change = false;
orig_node->bat_priv = bat_priv; orig_node->bat_priv = bat_priv;
memcpy(orig_node->orig, addr, ETH_ALEN); memcpy(orig_node->orig, addr, ETH_ALEN);
......
...@@ -733,6 +733,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, ...@@ -733,6 +733,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv,
spin_unlock_bh(list_lock); spin_unlock_bh(list_lock);
} }
atomic_set(&orig_node->tt_size, 0); atomic_set(&orig_node->tt_size, 0);
orig_node->tt_initialised = false;
} }
static void tt_global_roam_purge(struct bat_priv *bat_priv) static void tt_global_roam_purge(struct bat_priv *bat_priv)
...@@ -1450,6 +1451,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv, ...@@ -1450,6 +1451,7 @@ static void _tt_update_changes(struct bat_priv *bat_priv,
*/ */
return; return;
} }
orig_node->tt_initialised = true;
} }
static void tt_fill_gtable(struct bat_priv *bat_priv, static void tt_fill_gtable(struct bat_priv *bat_priv,
...@@ -1854,8 +1856,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -1854,8 +1856,10 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
bool full_table = true; bool full_table = true;
/* the ttvn increased by one -> we can apply the attached changes */ /* orig table not initialised AND first diff is in the OGM OR the ttvn
if (ttvn - orig_ttvn == 1) { * increased by one -> we can apply the attached changes */
if ((!orig_node->tt_initialised && ttvn == 1) ||
ttvn - orig_ttvn == 1) {
/* the OGM could not contain the changes due to their size or /* the OGM could not contain the changes due to their size or
* because they have already been sent TT_OGM_APPEND_MAX times. * because they have already been sent TT_OGM_APPEND_MAX times.
* In this case send a tt request */ * In this case send a tt request */
...@@ -1889,7 +1893,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node, ...@@ -1889,7 +1893,8 @@ void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
} else { } else {
/* if we missed more than one change or our tables are not /* if we missed more than one change or our tables are not
* in sync anymore -> request fresh tt data */ * in sync anymore -> request fresh tt data */
if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { if (!orig_node->tt_initialised || ttvn != orig_ttvn ||
orig_node->tt_crc != tt_crc) {
request_table: request_table:
bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. "
"Need to retrieve the correct information " "Need to retrieve the correct information "
......
...@@ -81,6 +81,7 @@ struct orig_node { ...@@ -81,6 +81,7 @@ struct orig_node {
int16_t tt_buff_len; int16_t tt_buff_len;
spinlock_t tt_buff_lock; /* protects tt_buff */ spinlock_t tt_buff_lock; /* protects tt_buff */
atomic_t tt_size; atomic_t tt_size;
bool tt_initialised;
/* The tt_poss_change flag is used to detect an ongoing roaming phase. /* The tt_poss_change flag is used to detect an ongoing roaming phase.
* If true, then I sent a Roaming_adv to this orig_node and I have to * If true, then I sent a Roaming_adv to this orig_node and I have to
* inspect every packet directed to it to check whether it is still * inspect every packet directed to it to check whether it is still
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment