diff options
author | Antonio Quartulli <ordex@autistici.org> | 2011-11-07 10:36:40 -0500 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2012-02-16 13:50:18 -0500 |
commit | 17071578888c7c18709e48e74fae228c04581b9a (patch) | |
tree | a2513bb57d5685db9cfeab65a3d9c645c0df5e7c /net/batman-adv | |
parent | dcd6c92267155e70a94b3927bce681ce74b80d1f (diff) |
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: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
Tested-by: Alexey Fisher <bug-track@fisher-privat.net>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/originator.c | 1 | ||||
-rw-r--r-- | net/batman-adv/translation-table.c | 11 | ||||
-rw-r--r-- | net/batman-adv/types.h | 1 |
3 files changed, 10 insertions, 3 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 0bc2045a2f2e..847ff7e98a61 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -219,6 +219,7 @@ struct orig_node *get_orig_node(struct bat_priv *bat_priv, const uint8_t *addr) | |||
219 | /* extra reference for return */ | 219 | /* extra reference for return */ |
220 | atomic_set(&orig_node->refcount, 2); | 220 | atomic_set(&orig_node->refcount, 2); |
221 | 221 | ||
222 | orig_node->tt_initialised = false; | ||
222 | orig_node->tt_poss_change = false; | 223 | orig_node->tt_poss_change = false; |
223 | orig_node->bat_priv = bat_priv; | 224 | orig_node->bat_priv = bat_priv; |
224 | memcpy(orig_node->orig, addr, ETH_ALEN); | 225 | memcpy(orig_node->orig, addr, ETH_ALEN); |
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index ab8dea8b0b2e..c632475df375 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c | |||
@@ -733,6 +733,7 @@ void tt_global_del_orig(struct bat_priv *bat_priv, | |||
733 | spin_unlock_bh(list_lock); | 733 | spin_unlock_bh(list_lock); |
734 | } | 734 | } |
735 | atomic_set(&orig_node->tt_size, 0); | 735 | atomic_set(&orig_node->tt_size, 0); |
736 | orig_node->tt_initialised = false; | ||
736 | } | 737 | } |
737 | 738 | ||
738 | static void tt_global_roam_purge(struct bat_priv *bat_priv) | 739 | 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 | */ | 1451 | */ |
1451 | return; | 1452 | return; |
1452 | } | 1453 | } |
1454 | orig_node->tt_initialised = true; | ||
1453 | } | 1455 | } |
1454 | 1456 | ||
1455 | static void tt_fill_gtable(struct bat_priv *bat_priv, | 1457 | 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 | uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); | 1856 | uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn); |
1855 | bool full_table = true; | 1857 | bool full_table = true; |
1856 | 1858 | ||
1857 | /* the ttvn increased by one -> we can apply the attached changes */ | 1859 | /* orig table not initialised AND first diff is in the OGM OR the ttvn |
1858 | if (ttvn - orig_ttvn == 1) { | 1860 | * increased by one -> we can apply the attached changes */ |
1861 | if ((!orig_node->tt_initialised && ttvn == 1) || | ||
1862 | ttvn - orig_ttvn == 1) { | ||
1859 | /* the OGM could not contain the changes due to their size or | 1863 | /* the OGM could not contain the changes due to their size or |
1860 | * because they have already been sent TT_OGM_APPEND_MAX times. | 1864 | * because they have already been sent TT_OGM_APPEND_MAX times. |
1861 | * In this case send a tt request */ | 1865 | * 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 | } else { | 1893 | } else { |
1890 | /* if we missed more than one change or our tables are not | 1894 | /* if we missed more than one change or our tables are not |
1891 | * in sync anymore -> request fresh tt data */ | 1895 | * in sync anymore -> request fresh tt data */ |
1892 | if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) { | 1896 | if (!orig_node->tt_initialised || ttvn != orig_ttvn || |
1897 | orig_node->tt_crc != tt_crc) { | ||
1893 | request_table: | 1898 | request_table: |
1894 | bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " | 1899 | bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. " |
1895 | "Need to retrieve the correct information " | 1900 | "Need to retrieve the correct information " |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index e9eb043719ac..35085f410b96 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -81,6 +81,7 @@ struct orig_node { | |||
81 | int16_t tt_buff_len; | 81 | int16_t tt_buff_len; |
82 | spinlock_t tt_buff_lock; /* protects tt_buff */ | 82 | spinlock_t tt_buff_lock; /* protects tt_buff */ |
83 | atomic_t tt_size; | 83 | atomic_t tt_size; |
84 | bool tt_initialised; | ||
84 | /* The tt_poss_change flag is used to detect an ongoing roaming phase. | 85 | /* The tt_poss_change flag is used to detect an ongoing roaming phase. |
85 | * If true, then I sent a Roaming_adv to this orig_node and I have to | 86 | * If true, then I sent a Roaming_adv to this orig_node and I have to |
86 | * inspect every packet directed to it to check whether it is still | 87 | * inspect every packet directed to it to check whether it is still |