diff options
author | Marek Lindner <lindner_marek@yahoo.de> | 2011-01-19 15:01:40 -0500 |
---|---|---|
committer | Marek Lindner <lindner_marek@yahoo.de> | 2011-03-05 06:49:58 -0500 |
commit | fb778ea173fcd58b8fc3d75c674f07fab187b55f (patch) | |
tree | b14cfc99b7ca61ddcb49cc56c9a8e2822675debc /net/batman-adv/routing.c | |
parent | a775eb847ae66211577d4fd2c46749b77c9993c9 (diff) |
batman-adv: protect each hash row with rcu locks
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r-- | net/batman-adv/routing.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index c15e6c1c20b5..32ae04e26a05 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -52,7 +52,8 @@ void slide_own_bcast_window(struct batman_if *batman_if) | |||
52 | for (i = 0; i < hash->size; i++) { | 52 | for (i = 0; i < hash->size; i++) { |
53 | head = &hash->table[i]; | 53 | head = &hash->table[i]; |
54 | 54 | ||
55 | hlist_for_each_entry(bucket, walk, head, hlist) { | 55 | rcu_read_lock(); |
56 | hlist_for_each_entry_rcu(bucket, walk, head, hlist) { | ||
56 | orig_node = bucket->data; | 57 | orig_node = bucket->data; |
57 | word_index = batman_if->if_num * NUM_WORDS; | 58 | word_index = batman_if->if_num * NUM_WORDS; |
58 | word = &(orig_node->bcast_own[word_index]); | 59 | word = &(orig_node->bcast_own[word_index]); |
@@ -61,6 +62,7 @@ void slide_own_bcast_window(struct batman_if *batman_if) | |||
61 | orig_node->bcast_own_sum[batman_if->if_num] = | 62 | orig_node->bcast_own_sum[batman_if->if_num] = |
62 | bit_packet_count(word); | 63 | bit_packet_count(word); |
63 | } | 64 | } |
65 | rcu_read_unlock(); | ||
64 | } | 66 | } |
65 | 67 | ||
66 | spin_unlock_bh(&bat_priv->orig_hash_lock); | 68 | spin_unlock_bh(&bat_priv->orig_hash_lock); |
@@ -873,9 +875,11 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv, | |||
873 | /* answer echo request (ping) */ | 875 | /* answer echo request (ping) */ |
874 | /* get routing information */ | 876 | /* get routing information */ |
875 | spin_lock_bh(&bat_priv->orig_hash_lock); | 877 | spin_lock_bh(&bat_priv->orig_hash_lock); |
878 | rcu_read_lock(); | ||
876 | orig_node = ((struct orig_node *)hash_find(bat_priv->orig_hash, | 879 | orig_node = ((struct orig_node *)hash_find(bat_priv->orig_hash, |
877 | compare_orig, choose_orig, | 880 | compare_orig, choose_orig, |
878 | icmp_packet->orig)); | 881 | icmp_packet->orig)); |
882 | rcu_read_unlock(); | ||
879 | ret = NET_RX_DROP; | 883 | ret = NET_RX_DROP; |
880 | 884 | ||
881 | if ((orig_node) && (orig_node->router)) { | 885 | if ((orig_node) && (orig_node->router)) { |
@@ -931,9 +935,11 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv, | |||
931 | 935 | ||
932 | /* get routing information */ | 936 | /* get routing information */ |
933 | spin_lock_bh(&bat_priv->orig_hash_lock); | 937 | spin_lock_bh(&bat_priv->orig_hash_lock); |
938 | rcu_read_lock(); | ||
934 | orig_node = ((struct orig_node *) | 939 | orig_node = ((struct orig_node *) |
935 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, | 940 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, |
936 | icmp_packet->orig)); | 941 | icmp_packet->orig)); |
942 | rcu_read_unlock(); | ||
937 | ret = NET_RX_DROP; | 943 | ret = NET_RX_DROP; |
938 | 944 | ||
939 | if ((orig_node) && (orig_node->router)) { | 945 | if ((orig_node) && (orig_node->router)) { |
@@ -1023,9 +1029,11 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if) | |||
1023 | 1029 | ||
1024 | /* get routing information */ | 1030 | /* get routing information */ |
1025 | spin_lock_bh(&bat_priv->orig_hash_lock); | 1031 | spin_lock_bh(&bat_priv->orig_hash_lock); |
1032 | rcu_read_lock(); | ||
1026 | orig_node = ((struct orig_node *) | 1033 | orig_node = ((struct orig_node *) |
1027 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, | 1034 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, |
1028 | icmp_packet->dst)); | 1035 | icmp_packet->dst)); |
1036 | rcu_read_unlock(); | ||
1029 | 1037 | ||
1030 | if ((orig_node) && (orig_node->router)) { | 1038 | if ((orig_node) && (orig_node->router)) { |
1031 | 1039 | ||
@@ -1094,9 +1102,11 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, | |||
1094 | router_orig->orig, ETH_ALEN) == 0) { | 1102 | router_orig->orig, ETH_ALEN) == 0) { |
1095 | primary_orig_node = router_orig; | 1103 | primary_orig_node = router_orig; |
1096 | } else { | 1104 | } else { |
1105 | rcu_read_lock(); | ||
1097 | primary_orig_node = hash_find(bat_priv->orig_hash, compare_orig, | 1106 | primary_orig_node = hash_find(bat_priv->orig_hash, compare_orig, |
1098 | choose_orig, | 1107 | choose_orig, |
1099 | router_orig->primary_addr); | 1108 | router_orig->primary_addr); |
1109 | rcu_read_unlock(); | ||
1100 | 1110 | ||
1101 | if (!primary_orig_node) | 1111 | if (!primary_orig_node) |
1102 | return orig_node->router; | 1112 | return orig_node->router; |
@@ -1199,9 +1209,11 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if, | |||
1199 | 1209 | ||
1200 | /* get routing information */ | 1210 | /* get routing information */ |
1201 | spin_lock_bh(&bat_priv->orig_hash_lock); | 1211 | spin_lock_bh(&bat_priv->orig_hash_lock); |
1212 | rcu_read_lock(); | ||
1202 | orig_node = ((struct orig_node *) | 1213 | orig_node = ((struct orig_node *) |
1203 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, | 1214 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, |
1204 | unicast_packet->dest)); | 1215 | unicast_packet->dest)); |
1216 | rcu_read_unlock(); | ||
1205 | 1217 | ||
1206 | router = find_router(bat_priv, orig_node, recv_if); | 1218 | router = find_router(bat_priv, orig_node, recv_if); |
1207 | 1219 | ||
@@ -1345,9 +1357,11 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if) | |||
1345 | return NET_RX_DROP; | 1357 | return NET_RX_DROP; |
1346 | 1358 | ||
1347 | spin_lock_bh(&bat_priv->orig_hash_lock); | 1359 | spin_lock_bh(&bat_priv->orig_hash_lock); |
1360 | rcu_read_lock(); | ||
1348 | orig_node = ((struct orig_node *) | 1361 | orig_node = ((struct orig_node *) |
1349 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, | 1362 | hash_find(bat_priv->orig_hash, compare_orig, choose_orig, |
1350 | bcast_packet->orig)); | 1363 | bcast_packet->orig)); |
1364 | rcu_read_unlock(); | ||
1351 | 1365 | ||
1352 | if (!orig_node) { | 1366 | if (!orig_node) { |
1353 | spin_unlock_bh(&bat_priv->orig_hash_lock); | 1367 | spin_unlock_bh(&bat_priv->orig_hash_lock); |