diff options
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r-- | net/batman-adv/routing.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c index 1c31a0e9f90a..7627ebe50c4b 100644 --- a/net/batman-adv/routing.c +++ b/net/batman-adv/routing.c | |||
@@ -55,12 +55,14 @@ void slide_own_bcast_window(struct batman_if *batman_if) | |||
55 | rcu_read_lock(); | 55 | rcu_read_lock(); |
56 | hlist_for_each_entry_rcu(bucket, walk, head, hlist) { | 56 | hlist_for_each_entry_rcu(bucket, walk, head, hlist) { |
57 | orig_node = bucket->data; | 57 | orig_node = bucket->data; |
58 | spin_lock_bh(&orig_node->ogm_cnt_lock); | ||
58 | word_index = batman_if->if_num * NUM_WORDS; | 59 | word_index = batman_if->if_num * NUM_WORDS; |
59 | word = &(orig_node->bcast_own[word_index]); | 60 | word = &(orig_node->bcast_own[word_index]); |
60 | 61 | ||
61 | bit_get_packet(bat_priv, word, 1, 0); | 62 | bit_get_packet(bat_priv, word, 1, 0); |
62 | orig_node->bcast_own_sum[batman_if->if_num] = | 63 | orig_node->bcast_own_sum[batman_if->if_num] = |
63 | bit_packet_count(word); | 64 | bit_packet_count(word); |
65 | spin_unlock_bh(&orig_node->ogm_cnt_lock); | ||
64 | } | 66 | } |
65 | rcu_read_unlock(); | 67 | rcu_read_unlock(); |
66 | } | 68 | } |
@@ -278,8 +280,10 @@ static void update_orig(struct bat_priv *bat_priv, | |||
278 | char is_duplicate) | 280 | char is_duplicate) |
279 | { | 281 | { |
280 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; | 282 | struct neigh_node *neigh_node = NULL, *tmp_neigh_node = NULL; |
283 | struct orig_node *orig_node_tmp; | ||
281 | struct hlist_node *node; | 284 | struct hlist_node *node; |
282 | int tmp_hna_buff_len; | 285 | int tmp_hna_buff_len; |
286 | uint8_t bcast_own_sum_orig, bcast_own_sum_neigh; | ||
283 | 287 | ||
284 | bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " | 288 | bat_dbg(DBG_BATMAN, bat_priv, "update_originator(): " |
285 | "Searching and updating originator entry of received packet\n"); | 289 | "Searching and updating originator entry of received packet\n"); |
@@ -351,10 +355,22 @@ static void update_orig(struct bat_priv *bat_priv, | |||
351 | /* if the TQ is the same and the link not more symetric we | 355 | /* if the TQ is the same and the link not more symetric we |
352 | * won't consider it either */ | 356 | * won't consider it either */ |
353 | if ((orig_node->router) && | 357 | if ((orig_node->router) && |
354 | ((neigh_node->tq_avg == orig_node->router->tq_avg) && | 358 | (neigh_node->tq_avg == orig_node->router->tq_avg)) { |
355 | (orig_node->router->orig_node->bcast_own_sum[if_incoming->if_num] | 359 | orig_node_tmp = orig_node->router->orig_node; |
356 | >= neigh_node->orig_node->bcast_own_sum[if_incoming->if_num]))) | 360 | spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); |
357 | goto update_hna; | 361 | bcast_own_sum_orig = |
362 | orig_node_tmp->bcast_own_sum[if_incoming->if_num]; | ||
363 | spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); | ||
364 | |||
365 | orig_node_tmp = neigh_node->orig_node; | ||
366 | spin_lock_bh(&orig_node_tmp->ogm_cnt_lock); | ||
367 | bcast_own_sum_neigh = | ||
368 | orig_node_tmp->bcast_own_sum[if_incoming->if_num]; | ||
369 | spin_unlock_bh(&orig_node_tmp->ogm_cnt_lock); | ||
370 | |||
371 | if (bcast_own_sum_orig >= bcast_own_sum_neigh) | ||
372 | goto update_hna; | ||
373 | } | ||
358 | 374 | ||
359 | update_routes(bat_priv, orig_node, neigh_node, | 375 | update_routes(bat_priv, orig_node, neigh_node, |
360 | hna_buff, tmp_hna_buff_len); | 376 | hna_buff, tmp_hna_buff_len); |
@@ -705,10 +721,13 @@ void receive_bat_packet(struct ethhdr *ethhdr, | |||
705 | batman_packet->orig) && | 721 | batman_packet->orig) && |
706 | (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { | 722 | (batman_packet->seqno - if_incoming_seqno + 2 == 0)) { |
707 | offset = if_incoming->if_num * NUM_WORDS; | 723 | offset = if_incoming->if_num * NUM_WORDS; |
724 | |||
725 | spin_lock_bh(&orig_neigh_node->ogm_cnt_lock); | ||
708 | word = &(orig_neigh_node->bcast_own[offset]); | 726 | word = &(orig_neigh_node->bcast_own[offset]); |
709 | bit_mark(word, 0); | 727 | bit_mark(word, 0); |
710 | orig_neigh_node->bcast_own_sum[if_incoming->if_num] = | 728 | orig_neigh_node->bcast_own_sum[if_incoming->if_num] = |
711 | bit_packet_count(word); | 729 | bit_packet_count(word); |
730 | spin_unlock_bh(&orig_neigh_node->ogm_cnt_lock); | ||
712 | } | 731 | } |
713 | 732 | ||
714 | bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: " | 733 | bat_dbg(DBG_BATMAN, bat_priv, "Drop packet: " |