1 From: Linus Lüssing <linus.luessing@c0d3.blue>
2 Date: Thu, 10 May 2018 19:44:28 +0200
3 Subject: [PATCH] batman-adv: Fix TT sync flags for intermediate TT responses
5 The previous TT sync fix so far only fixed TT responses issued by the
6 target node directly. So far, TT responses issued by intermediate nodes
7 still lead to the wrong flags being added, leading to CRC mismatches.
9 This behaviour was observed at Freifunk Hannover in a 800 nodes setup
10 where a considerable amount of nodes were still infected with 'WI'
11 TT flags even with (most) nodes having the previous TT sync fix applied.
13 I was able to reproduce the issue with intermediate TT responses in a
14 four node test setup and this patch fixes this issue by ensuring to
15 use the per originator instead of the summarized, OR'd ones.
17 Fixes: fa614fd04692 ("batman-adv: fix tt_global_entries flags update")
18 Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
19 Signed-off-by: Sven Eckelmann <sven@narfation.org>
21 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/d65daee8617b29c1ddcc949ce3a5ec24f7a1e1af
23 net/batman-adv/translation-table.c | 61 +++++++++++++++++++++++++-----
24 1 file changed, 51 insertions(+), 10 deletions(-)
26 diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
27 index 7fa3a0a0524a1da63e92d081b443c302900bf0c3..23f9c212ab1e27be429645a85f7b5d6a02585de9 100644
28 --- a/net/batman-adv/translation-table.c
29 +++ b/net/batman-adv/translation-table.c
30 @@ -1538,6 +1538,8 @@ batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry,
31 * handled by a given originator
32 * @entry: the TT global entry to check
33 * @orig_node: the originator to search in the list
34 + * @flags: a pointer to store TT flags for the given @entry received
37 * find out if an orig_node is already in the list of a tt_global_entry.
39 @@ -1545,7 +1547,8 @@ batadv_tt_global_orig_entry_find(const struct batadv_tt_global_entry *entry,
42 batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry,
43 - const struct batadv_orig_node *orig_node)
44 + const struct batadv_orig_node *orig_node,
47 struct batadv_tt_orig_list_entry *orig_entry;
49 @@ -1553,6 +1556,10 @@ batadv_tt_global_entry_has_orig(const struct batadv_tt_global_entry *entry,
50 orig_entry = batadv_tt_global_orig_entry_find(entry, orig_node);
55 + *flags = orig_entry->flags;
57 batadv_tt_orig_list_entry_put(orig_entry);
60 @@ -1731,7 +1738,7 @@ static bool batadv_tt_global_add(struct batadv_priv *bat_priv,
61 if (!(common->flags & BATADV_TT_CLIENT_TEMP))
63 if (batadv_tt_global_entry_has_orig(tt_global_entry,
67 batadv_tt_global_del_orig_list(tt_global_entry);
69 @@ -2880,23 +2887,46 @@ batadv_tt_req_node_new(struct batadv_priv *bat_priv,
73 - * batadv_tt_local_valid() - verify that given tt entry is a valid one
74 + * batadv_tt_local_valid() - verify local tt entry and get flags
75 * @entry_ptr: to be checked local tt entry
76 * @data_ptr: not used but definition required to satisfy the callback prototype
77 + * @flags: a pointer to store TT flags for this client to
79 + * Checks the validity of the given local TT entry. If it is, then the provided
80 + * flags pointer is updated.
82 * Return: true if the entry is a valid, false otherwise.
84 -static bool batadv_tt_local_valid(const void *entry_ptr, const void *data_ptr)
85 +static bool batadv_tt_local_valid(const void *entry_ptr,
86 + const void *data_ptr,
89 const struct batadv_tt_common_entry *tt_common_entry = entry_ptr;
91 if (tt_common_entry->flags & BATADV_TT_CLIENT_NEW)
95 + *flags = tt_common_entry->flags;
101 + * batadv_tt_global_valid() - verify global tt entry and get flags
102 + * @entry_ptr: to be checked global tt entry
103 + * @data_ptr: an orig_node object (may be NULL)
104 + * @flags: a pointer to store TT flags for this client to
106 + * Checks the validity of the given global TT entry. If it is, then the provided
107 + * flags pointer is updated either with the common (summed) TT flags if data_ptr
108 + * is NULL or the specific, per originator TT flags otherwise.
110 + * Return: true if the entry is a valid, false otherwise.
112 static bool batadv_tt_global_valid(const void *entry_ptr,
113 - const void *data_ptr)
114 + const void *data_ptr,
117 const struct batadv_tt_common_entry *tt_common_entry = entry_ptr;
118 const struct batadv_tt_global_entry *tt_global_entry;
119 @@ -2910,7 +2940,8 @@ static bool batadv_tt_global_valid(const void *entry_ptr,
120 struct batadv_tt_global_entry,
123 - return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node);
124 + return batadv_tt_global_entry_has_orig(tt_global_entry, orig_node,
129 @@ -2920,25 +2951,34 @@ static bool batadv_tt_global_valid(const void *entry_ptr,
130 * @hash: hash table containing the tt entries
131 * @tt_len: expected tvlv tt data buffer length in number of bytes
132 * @tvlv_buff: pointer to the buffer to fill with the TT data
133 - * @valid_cb: function to filter tt change entries
134 + * @valid_cb: function to filter tt change entries and to return TT flags
135 * @cb_data: data passed to the filter function as argument
137 + * Fills the tvlv buff with the tt entries from the specified hash. If valid_cb
138 + * is not provided then this becomes a no-op.
140 static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
141 struct batadv_hashtable *hash,
142 void *tvlv_buff, u16 tt_len,
143 bool (*valid_cb)(const void *,
149 struct batadv_tt_common_entry *tt_common_entry;
150 struct batadv_tvlv_tt_change *tt_change;
151 struct hlist_head *head;
152 u16 tt_tot, tt_num_entries = 0;
157 tt_tot = batadv_tt_entries(tt_len);
158 tt_change = (struct batadv_tvlv_tt_change *)tvlv_buff;
164 for (i = 0; i < hash->size; i++) {
165 head = &hash->table[i];
166 @@ -2948,11 +2988,12 @@ static void batadv_tt_tvlv_generate(struct batadv_priv *bat_priv,
167 if (tt_tot == tt_num_entries)
170 - if ((valid_cb) && (!valid_cb(tt_common_entry, cb_data)))
171 + ret = valid_cb(tt_common_entry, cb_data, &flags);
175 ether_addr_copy(tt_change->addr, tt_common_entry->addr);
176 - tt_change->flags = tt_common_entry->flags;
177 + tt_change->flags = flags;
178 tt_change->vid = htons(tt_common_entry->vid);
179 memset(tt_change->reserved, 0,
180 sizeof(tt_change->reserved));