Commit e17931d1a61d189845d3ca923c5baf99e729156a

Authored by Linus Lüssing
Committed by Antonio Quartulli
1 parent c5caf4ef34

batman-adv: introduce capability initialization bitfield

The new bitfield allows us to keep track whether capability subsets of
an originator have gone through their initialization phase yet.

The translation table is the only user right now, but a new one will be
added soon.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>

Showing 3 changed files with 11 additions and 9 deletions Side-by-side Diff

net/batman-adv/originator.c
... ... @@ -664,7 +664,6 @@
664 664 /* extra reference for return */
665 665 atomic_set(&orig_node->refcount, 2);
666 666  
667   - orig_node->tt_initialised = false;
668 667 orig_node->bat_priv = bat_priv;
669 668 ether_addr_copy(orig_node->orig, addr);
670 669 batadv_dat_init_orig_node_addr(orig_node);
net/batman-adv/translation-table.c
... ... @@ -1774,7 +1774,7 @@
1774 1774 }
1775 1775 spin_unlock_bh(list_lock);
1776 1776 }
1777   - orig_node->tt_initialised = false;
  1777 + orig_node->capa_initialized &= ~BATADV_ORIG_CAPA_HAS_TT;
1778 1778 }
1779 1779  
1780 1780 static bool batadv_tt_global_to_purge(struct batadv_tt_global_entry *tt_global,
... ... @@ -2734,7 +2734,7 @@
2734 2734 return;
2735 2735 }
2736 2736 }
2737   - orig_node->tt_initialised = true;
  2737 + orig_node->capa_initialized |= BATADV_ORIG_CAPA_HAS_TT;
2738 2738 }
2739 2739  
2740 2740 static void batadv_tt_fill_gtable(struct batadv_priv *bat_priv,
2741 2741  
2742 2742  
... ... @@ -3224,13 +3224,15 @@
3224 3224 uint8_t orig_ttvn = (uint8_t)atomic_read(&orig_node->last_ttvn);
3225 3225 struct batadv_tvlv_tt_vlan_data *tt_vlan;
3226 3226 bool full_table = true;
  3227 + bool has_tt_init;
3227 3228  
3228 3229 tt_vlan = (struct batadv_tvlv_tt_vlan_data *)tt_buff;
  3230 + has_tt_init = orig_node->capa_initialized & BATADV_ORIG_CAPA_HAS_TT;
  3231 +
3229 3232 /* orig table not initialised AND first diff is in the OGM OR the ttvn
3230 3233 * increased by one -> we can apply the attached changes
3231 3234 */
3232   - if ((!orig_node->tt_initialised && ttvn == 1) ||
3233   - ttvn - orig_ttvn == 1) {
  3235 + if ((!has_tt_init && ttvn == 1) || ttvn - orig_ttvn == 1) {
3234 3236 /* the OGM could not contain the changes due to their size or
3235 3237 * because they have already been sent BATADV_TT_OGM_APPEND_MAX
3236 3238 * times.
... ... @@ -3270,7 +3272,7 @@
3270 3272 /* if we missed more than one change or our tables are not
3271 3273 * in sync anymore -> request fresh tt data
3272 3274 */
3273   - if (!orig_node->tt_initialised || ttvn != orig_ttvn ||
  3275 + if (!has_tt_init || ttvn != orig_ttvn ||
3274 3276 !batadv_tt_global_check_crc(orig_node, tt_vlan,
3275 3277 tt_num_vlan)) {
3276 3278 request_table:
net/batman-adv/types.h
... ... @@ -205,13 +205,12 @@
205 205 * @last_seen: time when last packet from this node was received
206 206 * @bcast_seqno_reset: time when the broadcast seqno window was reset
207 207 * @capabilities: announced capabilities of this originator
  208 + * @capa_initialized: bitfield to remember whether a capability was initialized
208 209 * @last_ttvn: last seen translation table version number
209 210 * @tt_buff: last tt changeset this node received from the orig node
210 211 * @tt_buff_len: length of the last tt changeset this node received from the
211 212 * orig node
212 213 * @tt_buff_lock: lock that protects tt_buff and tt_buff_len
213   - * @tt_initialised: bool keeping track of whether or not this node have received
214   - * any translation table information from the orig node yet
215 214 * @tt_lock: prevents from updating the table while reading it. Table update is
216 215 * made up by two operations (data structure update and metdata -CRC/TTVN-
217 216 * recalculation) and they have to be executed atomically in order to avoid
218 217  
... ... @@ -248,11 +247,11 @@
248 247 unsigned long last_seen;
249 248 unsigned long bcast_seqno_reset;
250 249 uint8_t capabilities;
  250 + uint8_t capa_initialized;
251 251 atomic_t last_ttvn;
252 252 unsigned char *tt_buff;
253 253 int16_t tt_buff_len;
254 254 spinlock_t tt_buff_lock; /* protects tt_buff & tt_buff_len */
255   - bool tt_initialised;
256 255 /* prevents from changing the table while reading it */
257 256 spinlock_t tt_lock;
258 257 DECLARE_BITMAP(bcast_bits, BATADV_TQ_LOCAL_WINDOW_SIZE);
259 258  
... ... @@ -282,10 +281,12 @@
282 281 * enum batadv_orig_capabilities - orig node capabilities
283 282 * @BATADV_ORIG_CAPA_HAS_DAT: orig node has distributed arp table enabled
284 283 * @BATADV_ORIG_CAPA_HAS_NC: orig node has network coding enabled
  284 + * @BATADV_ORIG_CAPA_HAS_TT: orig node has tt capability
285 285 */
286 286 enum batadv_orig_capabilities {
287 287 BATADV_ORIG_CAPA_HAS_DAT = BIT(0),
288 288 BATADV_ORIG_CAPA_HAS_NC = BIT(1),
  289 + BATADV_ORIG_CAPA_HAS_TT = BIT(2),
289 290 };
290 291  
291 292 /**