diff options
author | Linus Lüssing <linus.luessing@c0d3.blue> | 2014-10-30 01:23:40 -0400 |
---|---|---|
committer | Antonio Quartulli <antonio@meshcoding.com> | 2015-01-06 05:05:09 -0500 |
commit | 2c667a339c7a6f23e1b7e23eed06f2564cff0c91 (patch) | |
tree | b8875d1a9cc60c576cc39a1c7f9b6983d3e30f1a /net/batman-adv | |
parent | 329887ad13a3f3d26837ea9fce5a8305a7c983e2 (diff) |
batman-adv: fix delayed foreign originator recognition
Currently it can happen that the reception of an OGM from a new
originator is not being accepted. More precisely it can happen that
an originator struct gets allocated and initialized
(batadv_orig_node_new()), even the TQ gets calculated and set correctly
(batadv_iv_ogm_calc_tq()) but still the periodic orig_node purging
thread will decide to delete it if it has a chance to jump between
these two function calls.
This is because batadv_orig_node_new() initializes the last_seen value
to zero and its caller (batadv_iv_ogm_orig_get()) makes it visible to
other threads by adding it to the hash table already.
batadv_iv_ogm_calc_tq() will set the last_seen variable to the correct,
current time a few lines later but if the purging thread jumps in between
that it will think that the orig_node timed out and will wrongly
schedule it for deletion already.
If the purging interval is the same as the originator interval (which is
the default: 1 second), then this game can continue for several rounds
until the random OGM jitter added enough difference between these
two (in tests, two to about four rounds seemed common).
Fixing this by initializing the last_seen variable of an orig_node
to the current time before adding it to the hash table.
Signed-off-by: Linus Lüssing <linus.luessing@c0d3.blue>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
Diffstat (limited to 'net/batman-adv')
-rw-r--r-- | net/batman-adv/originator.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index 6a484514cd3e..648bdbacee08 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -678,6 +678,7 @@ struct batadv_orig_node *batadv_orig_node_new(struct batadv_priv *bat_priv, | |||
678 | atomic_set(&orig_node->last_ttvn, 0); | 678 | atomic_set(&orig_node->last_ttvn, 0); |
679 | orig_node->tt_buff = NULL; | 679 | orig_node->tt_buff = NULL; |
680 | orig_node->tt_buff_len = 0; | 680 | orig_node->tt_buff_len = 0; |
681 | orig_node->last_seen = jiffies; | ||
681 | reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); | 682 | reset_time = jiffies - 1 - msecs_to_jiffies(BATADV_RESET_PROTECTION_MS); |
682 | orig_node->bcast_seqno_reset = reset_time; | 683 | orig_node->bcast_seqno_reset = reset_time; |
683 | #ifdef CONFIG_BATMAN_ADV_MCAST | 684 | #ifdef CONFIG_BATMAN_ADV_MCAST |