aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/translation-table.c
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-07-30 07:10:18 -0400
committerMarek Lindner <lindner_marek@yahoo.de>2011-08-22 09:16:22 -0400
commita943cac144e035c21d4f1b31b95f15b33c33a480 (patch)
tree411276e08762d4c4a8d19daa0fecd908210758b7 /net/batman-adv/translation-table.c
parent267151cdfd17c9dd3923c8ed75ef03725cbdd539 (diff)
batman-adv: merge update_transtable() into tt related code
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/translation-table.c')
-rw-r--r--net/batman-adv/translation-table.c69
1 files changed, 64 insertions, 5 deletions
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index e8f849f6b5b7..cc53f78e448c 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -1079,8 +1079,9 @@ out:
1079 return skb; 1079 return skb;
1080} 1080}
1081 1081
1082int send_tt_request(struct bat_priv *bat_priv, struct orig_node *dst_orig_node, 1082static int send_tt_request(struct bat_priv *bat_priv,
1083 uint8_t ttvn, uint16_t tt_crc, bool full_table) 1083 struct orig_node *dst_orig_node,
1084 uint8_t ttvn, uint16_t tt_crc, bool full_table)
1084{ 1085{
1085 struct sk_buff *skb = NULL; 1086 struct sk_buff *skb = NULL;
1086 struct tt_query_packet *tt_request; 1087 struct tt_query_packet *tt_request;
@@ -1455,9 +1456,10 @@ out:
1455 orig_node_free_ref(orig_node); 1456 orig_node_free_ref(orig_node);
1456} 1457}
1457 1458
1458void tt_update_changes(struct bat_priv *bat_priv, struct orig_node *orig_node, 1459static void tt_update_changes(struct bat_priv *bat_priv,
1459 uint16_t tt_num_changes, uint8_t ttvn, 1460 struct orig_node *orig_node,
1460 struct tt_change *tt_change) 1461 uint16_t tt_num_changes, uint8_t ttvn,
1462 struct tt_change *tt_change)
1461{ 1463{
1462 _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes, 1464 _tt_update_changes(bat_priv, orig_node, tt_change, tt_num_changes,
1463 ttvn); 1465 ttvn);
@@ -1802,3 +1804,60 @@ out:
1802 tt_local_entry_free_ref(tt_local_entry); 1804 tt_local_entry_free_ref(tt_local_entry);
1803 return ret; 1805 return ret;
1804} 1806}
1807
1808void tt_update_orig(struct bat_priv *bat_priv, struct orig_node *orig_node,
1809 const unsigned char *tt_buff, uint8_t tt_num_changes,
1810 uint8_t ttvn, uint16_t tt_crc)
1811{
1812 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
1813 bool full_table = true;
1814
1815 /* the ttvn increased by one -> we can apply the attached changes */
1816 if (ttvn - orig_ttvn == 1) {
1817 /* the OGM could not contain the changes due to their size or
1818 * because they have already been sent TT_OGM_APPEND_MAX times.
1819 * In this case send a tt request */
1820 if (!tt_num_changes) {
1821 full_table = false;
1822 goto request_table;
1823 }
1824
1825 tt_update_changes(bat_priv, orig_node, tt_num_changes, ttvn,
1826 (struct tt_change *)tt_buff);
1827
1828 /* Even if we received the precomputed crc with the OGM, we
1829 * prefer to recompute it to spot any possible inconsistency
1830 * in the global table */
1831 orig_node->tt_crc = tt_global_crc(bat_priv, orig_node);
1832
1833 /* The ttvn alone is not enough to guarantee consistency
1834 * because a single value could represent different states
1835 * (due to the wrap around). Thus a node has to check whether
1836 * the resulting table (after applying the changes) is still
1837 * consistent or not. E.g. a node could disconnect while its
1838 * ttvn is X and reconnect on ttvn = X + TTVN_MAX: in this case
1839 * checking the CRC value is mandatory to detect the
1840 * inconsistency */
1841 if (orig_node->tt_crc != tt_crc)
1842 goto request_table;
1843
1844 /* Roaming phase is over: tables are in sync again. I can
1845 * unset the flag */
1846 orig_node->tt_poss_change = false;
1847 } else {
1848 /* if we missed more than one change or our tables are not
1849 * in sync anymore -> request fresh tt data */
1850 if (ttvn != orig_ttvn || orig_node->tt_crc != tt_crc) {
1851request_table:
1852 bat_dbg(DBG_TT, bat_priv, "TT inconsistency for %pM. "
1853 "Need to retrieve the correct information "
1854 "(ttvn: %u last_ttvn: %u crc: %u last_crc: "
1855 "%u num_changes: %u)\n", orig_node->orig, ttvn,
1856 orig_ttvn, tt_crc, orig_node->tt_crc,
1857 tt_num_changes);
1858 send_tt_request(bat_priv, orig_node, ttvn, tt_crc,
1859 full_table);
1860 return;
1861 }
1862 }
1863}