aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/routing.c
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-02-18 07:28:09 -0500
committerMarek Lindner <lindner_marek@yahoo.de>2011-03-05 06:52:00 -0500
commit7aadf889e897155c45cda230d2a6701ad1fbff61 (patch)
tree4a31df411c29844afe25ccde17d2ff9e618241c1 /net/batman-adv/routing.c
parent39901e716275da4e831b40f9e45a1b61d6a776dc (diff)
batman-adv: remove extra layer between hash and hash element - hash bucket
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r--net/batman-adv/routing.c40
1 files changed, 13 insertions, 27 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index b54bf6ec637e..fc4c12a049da 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -39,9 +39,8 @@ void slide_own_bcast_window(struct batman_if *batman_if)
39{ 39{
40 struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface); 40 struct bat_priv *bat_priv = netdev_priv(batman_if->soft_iface);
41 struct hashtable_t *hash = bat_priv->orig_hash; 41 struct hashtable_t *hash = bat_priv->orig_hash;
42 struct hlist_node *walk; 42 struct hlist_node *node;
43 struct hlist_head *head; 43 struct hlist_head *head;
44 struct element_t *bucket;
45 struct orig_node *orig_node; 44 struct orig_node *orig_node;
46 unsigned long *word; 45 unsigned long *word;
47 int i; 46 int i;
@@ -53,8 +52,7 @@ void slide_own_bcast_window(struct batman_if *batman_if)
53 head = &hash->table[i]; 52 head = &hash->table[i];
54 53
55 rcu_read_lock(); 54 rcu_read_lock();
56 hlist_for_each_entry_rcu(bucket, walk, head, hlist) { 55 hlist_for_each_entry_rcu(orig_node, node, head, hash_entry) {
57 orig_node = bucket->data;
58 spin_lock_bh(&orig_node->ogm_cnt_lock); 56 spin_lock_bh(&orig_node->ogm_cnt_lock);
59 word_index = batman_if->if_num * NUM_WORDS; 57 word_index = batman_if->if_num * NUM_WORDS;
60 word = &(orig_node->bcast_own[word_index]); 58 word = &(orig_node->bcast_own[word_index]);
@@ -908,14 +906,11 @@ static int recv_my_icmp_packet(struct bat_priv *bat_priv,
908 /* get routing information */ 906 /* get routing information */
909 spin_lock_bh(&bat_priv->orig_hash_lock); 907 spin_lock_bh(&bat_priv->orig_hash_lock);
910 rcu_read_lock(); 908 rcu_read_lock();
911 orig_node = ((struct orig_node *)hash_find(bat_priv->orig_hash, 909 orig_node = orig_hash_find(bat_priv, icmp_packet->orig);
912 compare_orig, choose_orig,
913 icmp_packet->orig));
914 910
915 if (!orig_node) 911 if (!orig_node)
916 goto unlock; 912 goto unlock;
917 913
918 kref_get(&orig_node->refcount);
919 neigh_node = orig_node->router; 914 neigh_node = orig_node->router;
920 915
921 if (!neigh_node) 916 if (!neigh_node)
@@ -987,14 +982,11 @@ static int recv_icmp_ttl_exceeded(struct bat_priv *bat_priv,
987 /* get routing information */ 982 /* get routing information */
988 spin_lock_bh(&bat_priv->orig_hash_lock); 983 spin_lock_bh(&bat_priv->orig_hash_lock);
989 rcu_read_lock(); 984 rcu_read_lock();
990 orig_node = ((struct orig_node *) 985 orig_node = orig_hash_find(bat_priv, icmp_packet->orig);
991 hash_find(bat_priv->orig_hash, compare_orig, choose_orig,
992 icmp_packet->orig));
993 986
994 if (!orig_node) 987 if (!orig_node)
995 goto unlock; 988 goto unlock;
996 989
997 kref_get(&orig_node->refcount);
998 neigh_node = orig_node->router; 990 neigh_node = orig_node->router;
999 991
1000 if (!neigh_node) 992 if (!neigh_node)
@@ -1098,13 +1090,11 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)
1098 /* get routing information */ 1090 /* get routing information */
1099 spin_lock_bh(&bat_priv->orig_hash_lock); 1091 spin_lock_bh(&bat_priv->orig_hash_lock);
1100 rcu_read_lock(); 1092 rcu_read_lock();
1101 orig_node = ((struct orig_node *) 1093 orig_node = orig_hash_find(bat_priv, icmp_packet->dst);
1102 hash_find(bat_priv->orig_hash, compare_orig, choose_orig, 1094
1103 icmp_packet->dst));
1104 if (!orig_node) 1095 if (!orig_node)
1105 goto unlock; 1096 goto unlock;
1106 1097
1107 kref_get(&orig_node->refcount);
1108 neigh_node = orig_node->router; 1098 neigh_node = orig_node->router;
1109 1099
1110 if (!neigh_node) 1100 if (!neigh_node)
@@ -1194,11 +1184,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
1194 if (compare_eth(router_orig->primary_addr, router_orig->orig)) { 1184 if (compare_eth(router_orig->primary_addr, router_orig->orig)) {
1195 primary_orig_node = router_orig; 1185 primary_orig_node = router_orig;
1196 } else { 1186 } else {
1197 primary_orig_node = hash_find(bat_priv->orig_hash, compare_orig, 1187 primary_orig_node = orig_hash_find(bat_priv,
1198 choose_orig, 1188 router_orig->primary_addr);
1199 router_orig->primary_addr);
1200 if (!primary_orig_node) 1189 if (!primary_orig_node)
1201 goto return_router; 1190 goto return_router;
1191
1192 kref_put(&primary_orig_node->refcount, orig_node_free_ref);
1202 } 1193 }
1203 1194
1204 /* with less than 2 candidates, we can't do any 1195 /* with less than 2 candidates, we can't do any
@@ -1344,13 +1335,11 @@ int route_unicast_packet(struct sk_buff *skb, struct batman_if *recv_if,
1344 /* get routing information */ 1335 /* get routing information */
1345 spin_lock_bh(&bat_priv->orig_hash_lock); 1336 spin_lock_bh(&bat_priv->orig_hash_lock);
1346 rcu_read_lock(); 1337 rcu_read_lock();
1347 orig_node = ((struct orig_node *) 1338 orig_node = orig_hash_find(bat_priv, unicast_packet->dest);
1348 hash_find(bat_priv->orig_hash, compare_orig, choose_orig, 1339
1349 unicast_packet->dest));
1350 if (!orig_node) 1340 if (!orig_node)
1351 goto unlock; 1341 goto unlock;
1352 1342
1353 kref_get(&orig_node->refcount);
1354 rcu_read_unlock(); 1343 rcu_read_unlock();
1355 1344
1356 /* find_router() increases neigh_nodes refcount if found. */ 1345 /* find_router() increases neigh_nodes refcount if found. */
@@ -1508,14 +1497,11 @@ int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if)
1508 1497
1509 spin_lock_bh(&bat_priv->orig_hash_lock); 1498 spin_lock_bh(&bat_priv->orig_hash_lock);
1510 rcu_read_lock(); 1499 rcu_read_lock();
1511 orig_node = ((struct orig_node *) 1500 orig_node = orig_hash_find(bat_priv, bcast_packet->orig);
1512 hash_find(bat_priv->orig_hash, compare_orig, choose_orig,
1513 bcast_packet->orig));
1514 1501
1515 if (!orig_node) 1502 if (!orig_node)
1516 goto rcu_unlock; 1503 goto rcu_unlock;
1517 1504
1518 kref_get(&orig_node->refcount);
1519 rcu_read_unlock(); 1505 rcu_read_unlock();
1520 1506
1521 spin_lock_bh(&orig_node->bcast_seqno_lock); 1507 spin_lock_bh(&orig_node->bcast_seqno_lock);