Commit 92f90f56caa30dfcb6c5755776d73df23ef2ae1a
Committed by
Marek Lindner
1 parent
032b7969f8
batman-adv: refactor tt_global_del() to avoid misalignment
Signed-off-by: Sven Eckelmann <sven@narfation.org> Acked-by: Antonio Quartulli <ordex@autistici.org> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Showing 1 changed file with 22 additions and 20 deletions Side-by-side Diff
net/batman-adv/translation-table.c
... | ... | @@ -657,29 +657,31 @@ |
657 | 657 | struct tt_local_entry *tt_local_entry = NULL; |
658 | 658 | |
659 | 659 | tt_global_entry = tt_global_hash_find(bat_priv, addr); |
660 | - if (!tt_global_entry) | |
660 | + if (!tt_global_entry || tt_global_entry->orig_node != orig_node) | |
661 | 661 | goto out; |
662 | 662 | |
663 | - if (tt_global_entry->orig_node == orig_node) { | |
664 | - if (roaming) { | |
665 | - /* if we are deleting a global entry due to a roam | |
666 | - * event, there are two possibilities: | |
667 | - * 1) the client roamed from node A to node B => we mark | |
668 | - * it with TT_CLIENT_ROAM, we start a timer and we | |
669 | - * wait for node B to claim it. In case of timeout | |
670 | - * the entry is purged. | |
671 | - * 2) the client roamed to us => we can directly delete | |
672 | - * the global entry, since it is useless now. */ | |
673 | - tt_local_entry = tt_local_hash_find(bat_priv, | |
674 | - tt_global_entry->common.addr); | |
675 | - if (!tt_local_entry) { | |
676 | - tt_global_entry->common.flags |= TT_CLIENT_ROAM; | |
677 | - tt_global_entry->roam_at = jiffies; | |
678 | - goto out; | |
679 | - } | |
680 | - } | |
681 | - _tt_global_del(bat_priv, tt_global_entry, message); | |
663 | + if (!roaming) | |
664 | + goto out_del; | |
665 | + | |
666 | + /* if we are deleting a global entry due to a roam | |
667 | + * event, there are two possibilities: | |
668 | + * 1) the client roamed from node A to node B => we mark | |
669 | + * it with TT_CLIENT_ROAM, we start a timer and we | |
670 | + * wait for node B to claim it. In case of timeout | |
671 | + * the entry is purged. | |
672 | + * 2) the client roamed to us => we can directly delete | |
673 | + * the global entry, since it is useless now. */ | |
674 | + tt_local_entry = tt_local_hash_find(bat_priv, | |
675 | + tt_global_entry->common.addr); | |
676 | + if (!tt_local_entry) { | |
677 | + tt_global_entry->common.flags |= TT_CLIENT_ROAM; | |
678 | + tt_global_entry->roam_at = jiffies; | |
679 | + goto out; | |
682 | 680 | } |
681 | + | |
682 | +out_del: | |
683 | + _tt_global_del(bat_priv, tt_global_entry, message); | |
684 | + | |
683 | 685 | out: |
684 | 686 | if (tt_global_entry) |
685 | 687 | tt_global_entry_free_ref(tt_global_entry); |