Commit 3abe4adbfb293e37d2d6f4fe22366534dc2675d9

Authored by Antonio Quartulli
Committed by Antonio Quartulli
1 parent d989661732

batman-adv: refactor batadv_tt_local_event()

Instead of passing a generic combination of flags as
argument, it is easier to pass the entire tt_common
structure (containing the flags already set) plus a
bitfield of event flags that will be unified with
the already existing ones before inserting the client
in the event queue.
In this way invocations of the modified function can be
simplified.

Signed-off-by: Antonio Quartulli <antonio@open-mesh.com>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>

Showing 1 changed file with 15 additions and 8 deletions Side-by-side Diff

net/batman-adv/translation-table.c
... ... @@ -163,10 +163,19 @@
163 163 call_rcu(&orig_entry->rcu, batadv_tt_orig_list_entry_free_rcu);
164 164 }
165 165  
  166 +/**
  167 + * batadv_tt_local_event - store a local TT event (ADD/DEL)
  168 + * @bat_priv: the bat priv with all the soft interface information
  169 + * @tt_local_entry: the TT entry involved in the event
  170 + * @event_flags: flags to store in the event structure
  171 + */
166 172 static void batadv_tt_local_event(struct batadv_priv *bat_priv,
167   - const uint8_t *addr, uint8_t flags)
  173 + struct batadv_tt_local_entry *tt_local_entry,
  174 + uint8_t event_flags)
168 175 {
169 176 struct batadv_tt_change_node *tt_change_node, *entry, *safe;
  177 + struct batadv_tt_common_entry *common = &tt_local_entry->common;
  178 + uint8_t flags = common->flags | event_flags;
170 179 bool event_removed = false;
171 180 bool del_op_requested, del_op_entry;
172 181  
... ... @@ -176,7 +185,7 @@
176 185 return;
177 186  
178 187 tt_change_node->change.flags = flags;
179   - memcpy(tt_change_node->change.addr, addr, ETH_ALEN);
  188 + memcpy(tt_change_node->change.addr, common->addr, ETH_ALEN);
180 189  
181 190 del_op_requested = flags & BATADV_TT_CLIENT_DEL;
182 191  
... ... @@ -184,7 +193,7 @@
184 193 spin_lock_bh(&bat_priv->tt.changes_list_lock);
185 194 list_for_each_entry_safe(entry, safe, &bat_priv->tt.changes_list,
186 195 list) {
187   - if (!batadv_compare_eth(entry->change.addr, addr))
  196 + if (!batadv_compare_eth(entry->change.addr, common->addr))
188 197 continue;
189 198  
190 199 /* DEL+ADD in the same orig interval have no effect and can be
... ... @@ -332,7 +341,7 @@
332 341 }
333 342  
334 343 add_event:
335   - batadv_tt_local_event(bat_priv, addr, tt_local->common.flags);
  344 + batadv_tt_local_event(bat_priv, tt_local, BATADV_NO_FLAGS);
336 345  
337 346 check_roaming:
338 347 /* Check whether it is a roaming, but don't do anything if the roaming
... ... @@ -529,8 +538,7 @@
529 538 struct batadv_tt_local_entry *tt_local_entry,
530 539 uint16_t flags, const char *message)
531 540 {
532   - batadv_tt_local_event(bat_priv, tt_local_entry->common.addr,
533   - tt_local_entry->common.flags | flags);
  541 + batadv_tt_local_event(bat_priv, tt_local_entry, flags);
534 542  
535 543 /* The local client has to be marked as "pending to be removed" but has
536 544 * to be kept in the table in order to send it in a full table
... ... @@ -584,8 +592,7 @@
584 592 /* if this client has been added right now, it is possible to
585 593 * immediately purge it
586 594 */
587   - batadv_tt_local_event(bat_priv, tt_local_entry->common.addr,
588   - curr_flags | BATADV_TT_CLIENT_DEL);
  595 + batadv_tt_local_event(bat_priv, tt_local_entry, BATADV_TT_CLIENT_DEL);
589 596 hlist_del_rcu(&tt_local_entry->common.hash_entry);
590 597 batadv_tt_local_entry_free_ref(tt_local_entry);
591 598