diff options
author | Linus Lüssing <linus.luessing@web.de> | 2011-03-14 18:43:40 -0400 |
---|---|---|
committer | Sven Eckelmann <sven@narfation.org> | 2011-04-17 15:11:01 -0400 |
commit | 68003903e4eeec5288f074ff0751a381750ceb34 (patch) | |
tree | 72577cb46c0e0aaec9edb54a496002d13650f6fb /net | |
parent | e1a5382f978b67b5cc36eec65e6046730ce07714 (diff) |
batman-adv: Protect global TQ window with a spinlock
Signed-off-by: Linus Lüssing <linus.luessing@web.de>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/batman-adv/originator.c | 1 | ||||
-rw-r--r-- | net/batman-adv/routing.c | 4 | ||||
-rw-r--r-- | net/batman-adv/types.h | 1 |
3 files changed, 6 insertions, 0 deletions
diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index b4cfe3686155..5b8fe32043da 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c | |||
@@ -102,6 +102,7 @@ struct neigh_node *create_neighbor(struct orig_node *orig_node, | |||
102 | 102 | ||
103 | INIT_HLIST_NODE(&neigh_node->list); | 103 | INIT_HLIST_NODE(&neigh_node->list); |
104 | INIT_LIST_HEAD(&neigh_node->bonding_list); | 104 | INIT_LIST_HEAD(&neigh_node->bonding_list); |
105 | spin_lock_init(&neigh_node->tq_lock); | ||
105 | 106 | ||
106 | memcpy(neigh_node->addr, neigh, ETH_ALEN); | 107 | memcpy(neigh_node->addr, neigh, ETH_ALEN); |
107 | neigh_node->orig_node = orig_neigh_node; | 108 | neigh_node->orig_node = orig_neigh_node; |
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index b7d43caaa9c8..f6c642246972 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -415,10 +415,12 @@ static void update_orig(struct bat_priv *bat_priv, | |||
415 | if (is_duplicate) | 415 | if (is_duplicate) |
416 | continue; | 416 | continue; |
417 | 417 | ||
418 | spin_lock_bh(&tmp_neigh_node->tq_lock); | ||
418 | ring_buffer_set(tmp_neigh_node->tq_recv, | 419 | ring_buffer_set(tmp_neigh_node->tq_recv, |
419 | &tmp_neigh_node->tq_index, 0); | 420 | &tmp_neigh_node->tq_index, 0); |
420 | tmp_neigh_node->tq_avg = | 421 | tmp_neigh_node->tq_avg = |
421 | ring_buffer_avg(tmp_neigh_node->tq_recv); | 422 | ring_buffer_avg(tmp_neigh_node->tq_recv); |
423 | spin_unlock_bh(&tmp_neigh_node->tq_lock); | ||
422 | } | 424 | } |
423 | 425 | ||
424 | if (!neigh_node) { | 426 | if (!neigh_node) { |
@@ -443,10 +445,12 @@ static void update_orig(struct bat_priv *bat_priv, | |||
443 | orig_node->flags = batman_packet->flags; | 445 | orig_node->flags = batman_packet->flags; |
444 | neigh_node->last_valid = jiffies; | 446 | neigh_node->last_valid = jiffies; |
445 | 447 | ||
448 | spin_lock_bh(&neigh_node->tq_lock); | ||
446 | ring_buffer_set(neigh_node->tq_recv, | 449 | ring_buffer_set(neigh_node->tq_recv, |
447 | &neigh_node->tq_index, | 450 | &neigh_node->tq_index, |
448 | batman_packet->tq); | 451 | batman_packet->tq); |
449 | neigh_node->tq_avg = ring_buffer_avg(neigh_node->tq_recv); | 452 | neigh_node->tq_avg = ring_buffer_avg(neigh_node->tq_recv); |
453 | spin_unlock_bh(&neigh_node->tq_lock); | ||
450 | 454 | ||
451 | if (!is_duplicate) { | 455 | if (!is_duplicate) { |
452 | orig_node->last_ttl = batman_packet->ttl; | 456 | orig_node->last_ttl = batman_packet->ttl; |
diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h index 1854cbb4c1b6..091476df4f0e 100644 --- a/net/batman-adv/types.h +++ b/net/batman-adv/types.h | |||
@@ -125,6 +125,7 @@ struct neigh_node { | |||
125 | struct rcu_head rcu; | 125 | struct rcu_head rcu; |
126 | struct orig_node *orig_node; | 126 | struct orig_node *orig_node; |
127 | struct hard_iface *if_incoming; | 127 | struct hard_iface *if_incoming; |
128 | spinlock_t tq_lock; /* protects: tq_recv, tq_index */ | ||
128 | }; | 129 | }; |
129 | 130 | ||
130 | 131 | ||