@@ -55,12 +55,14 @@ void slide_own_bcast_window(struct batman_if *batman_if)
5555 rcu_read_lock ();
5656 hlist_for_each_entry_rcu (bucket , walk , head , hlist ) {
5757 orig_node = bucket -> data ;
58+ spin_lock_bh (& orig_node -> ogm_cnt_lock );
5859 word_index = batman_if -> if_num * NUM_WORDS ;
5960 word = & (orig_node -> bcast_own [word_index ]);
6061
6162 bit_get_packet (bat_priv , word , 1 , 0 );
6263 orig_node -> bcast_own_sum [batman_if -> if_num ] =
6364 bit_packet_count (word );
65+ spin_unlock_bh (& orig_node -> ogm_cnt_lock );
6466 }
6567 rcu_read_unlock ();
6668 }
@@ -278,8 +280,10 @@ static void update_orig(struct bat_priv *bat_priv,
278280 char is_duplicate )
279281{
280282 struct neigh_node * neigh_node = NULL , * tmp_neigh_node = NULL ;
283+ struct orig_node * orig_node_tmp ;
281284 struct hlist_node * node ;
282285 int tmp_hna_buff_len ;
286+ uint8_t bcast_own_sum_orig , bcast_own_sum_neigh ;
283287
284288 bat_dbg (DBG_BATMAN , bat_priv , "update_originator(): "
285289 "Searching and updating originator entry of received packet\n" );
@@ -351,10 +355,22 @@ static void update_orig(struct bat_priv *bat_priv,
351355 /* if the TQ is the same and the link not more symetric we
352356 * won't consider it either */
353357 if ((orig_node -> router ) &&
354- ((neigh_node -> tq_avg == orig_node -> router -> tq_avg ) &&
355- (orig_node -> router -> orig_node -> bcast_own_sum [if_incoming -> if_num ]
356- >= neigh_node -> orig_node -> bcast_own_sum [if_incoming -> if_num ])))
357- goto update_hna ;
358+ (neigh_node -> tq_avg == orig_node -> router -> tq_avg )) {
359+ orig_node_tmp = orig_node -> router -> orig_node ;
360+ spin_lock_bh (& orig_node_tmp -> ogm_cnt_lock );
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+ }
358374
359375 update_routes (bat_priv , orig_node , neigh_node ,
360376 hna_buff , tmp_hna_buff_len );
@@ -705,10 +721,13 @@ void receive_bat_packet(struct ethhdr *ethhdr,
705721 batman_packet -> orig ) &&
706722 (batman_packet -> seqno - if_incoming_seqno + 2 == 0 )) {
707723 offset = if_incoming -> if_num * NUM_WORDS ;
724+
725+ spin_lock_bh (& orig_neigh_node -> ogm_cnt_lock );
708726 word = & (orig_neigh_node -> bcast_own [offset ]);
709727 bit_mark (word , 0 );
710728 orig_neigh_node -> bcast_own_sum [if_incoming -> if_num ] =
711729 bit_packet_count (word );
730+ spin_unlock_bh (& orig_neigh_node -> ogm_cnt_lock );
712731 }
713732
714733 bat_dbg (DBG_BATMAN , bat_priv , "Drop packet: "
0 commit comments