Skip to content

Commit d007260

Browse files
author
Marek Lindner
committed
batman-adv: remove orig_hash spinlock
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
1 parent 1605d0d commit d007260

7 files changed

Lines changed: 38 additions & 148 deletions

File tree

‎net/batman-adv/icmp_socket.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -158,9 +158,7 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
158158

159159
struct orig_node *orig_node = NULL;
160160
struct neigh_node *neigh_node = NULL;
161-
struct batman_if *batman_if;
162161
size_t packet_len = sizeof(struct icmp_packet);
163-
uint8_t dstaddr[ETH_ALEN];
164162

165163
if (len < sizeof(struct icmp_packet)) {
166164
bat_dbg(DBG_BATMAN, bat_priv,
@@ -220,7 +218,6 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
220218
if (atomic_read(&bat_priv->mesh_state) != MESH_ACTIVE)
221219
goto dst_unreach;
222220

223-
spin_lock_bh(&bat_priv->orig_hash_lock);
224221
rcu_read_lock();
225222
orig_node = orig_hash_find(bat_priv, icmp_packet->dst);
226223

@@ -239,29 +236,24 @@ static ssize_t bat_socket_write(struct file *file, const char __user *buff,
239236

240237
rcu_read_unlock();
241238

242-
batman_if = orig_node->router->if_incoming;
243-
memcpy(dstaddr, orig_node->router->addr, ETH_ALEN);
244-
spin_unlock_bh(&bat_priv->orig_hash_lock);
245-
246-
if (!batman_if)
239+
if (!neigh_node->if_incoming)
247240
goto dst_unreach;
248241

249-
if (batman_if->if_status != IF_ACTIVE)
242+
if (neigh_node->if_incoming->if_status != IF_ACTIVE)
250243
goto dst_unreach;
251244

252245
memcpy(icmp_packet->orig,
253246
bat_priv->primary_if->net_dev->dev_addr, ETH_ALEN);
254247

255248
if (packet_len == sizeof(struct icmp_packet_rr))
256249
memcpy(icmp_packet->rr,
257-
batman_if->net_dev->dev_addr, ETH_ALEN);
250+
neigh_node->if_incoming->net_dev->dev_addr, ETH_ALEN);
258251

259-
send_skb_packet(skb, batman_if, dstaddr);
252+
send_skb_packet(skb, neigh_node->if_incoming, neigh_node->addr);
260253
goto out;
261254

262255
unlock:
263256
rcu_read_unlock();
264-
spin_unlock_bh(&bat_priv->orig_hash_lock);
265257
dst_unreach:
266258
icmp_packet->msg_type = DESTINATION_UNREACHABLE;
267259
bat_socket_add_packet(socket_client, icmp_packet, packet_len);

‎net/batman-adv/main.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ int mesh_init(struct net_device *soft_iface)
7979
{
8080
struct bat_priv *bat_priv = netdev_priv(soft_iface);
8181

82-
spin_lock_init(&bat_priv->orig_hash_lock);
8382
spin_lock_init(&bat_priv->forw_bat_list_lock);
8483
spin_lock_init(&bat_priv->forw_bcast_list_lock);
8584
spin_lock_init(&bat_priv->hna_lhash_lock);

‎net/batman-adv/originator.c‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,15 @@ int originator_init(struct bat_priv *bat_priv)
4444
if (bat_priv->orig_hash)
4545
return 1;
4646

47-
spin_lock_bh(&bat_priv->orig_hash_lock);
4847
bat_priv->orig_hash = hash_new(1024);
4948

5049
if (!bat_priv->orig_hash)
5150
goto err;
5251

53-
spin_unlock_bh(&bat_priv->orig_hash_lock);
5452
start_purge_timer(bat_priv);
5553
return 1;
5654

5755
err:
58-
spin_unlock_bh(&bat_priv->orig_hash_lock);
5956
return 0;
6057
}
6158

@@ -159,7 +156,6 @@ void originator_free(struct bat_priv *bat_priv)
159156

160157
cancel_delayed_work_sync(&bat_priv->orig_work);
161158

162-
spin_lock_bh(&bat_priv->orig_hash_lock);
163159
bat_priv->orig_hash = NULL;
164160

165161
for (i = 0; i < hash->size; i++) {
@@ -177,7 +173,6 @@ void originator_free(struct bat_priv *bat_priv)
177173
}
178174

179175
hash_destroy(hash);
180-
spin_unlock_bh(&bat_priv->orig_hash_lock);
181176
}
182177

183178
/* this function finds or creates an originator entry for the given
@@ -342,8 +337,6 @@ static void _purge_orig(struct bat_priv *bat_priv)
342337
if (!hash)
343338
return;
344339

345-
spin_lock_bh(&bat_priv->orig_hash_lock);
346-
347340
/* for all origins... */
348341
for (i = 0; i < hash->size; i++) {
349342
head = &hash->table[i];
@@ -367,8 +360,6 @@ static void _purge_orig(struct bat_priv *bat_priv)
367360
spin_unlock_bh(list_lock);
368361
}
369362

370-
spin_unlock_bh(&bat_priv->orig_hash_lock);
371-
372363
gw_node_purge(bat_priv);
373364
gw_election(bat_priv);
374365

@@ -425,8 +416,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
425416
"Originator", "last-seen", "#", TQ_MAX_VALUE, "Nexthop",
426417
"outgoingIF", "Potential nexthops");
427418

428-
spin_lock_bh(&bat_priv->orig_hash_lock);
429-
430419
for (i = 0; i < hash->size; i++) {
431420
head = &hash->table[i];
432421

@@ -462,8 +451,6 @@ int orig_seq_print_text(struct seq_file *seq, void *offset)
462451
rcu_read_unlock();
463452
}
464453

465-
spin_unlock_bh(&bat_priv->orig_hash_lock);
466-
467454
if ((batman_count == 0))
468455
seq_printf(seq, "No batman nodes in range ...\n");
469456

@@ -511,8 +498,6 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
511498

512499
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
513500
* if_num */
514-
spin_lock_bh(&bat_priv->orig_hash_lock);
515-
516501
for (i = 0; i < hash->size; i++) {
517502
head = &hash->table[i];
518503

@@ -528,12 +513,10 @@ int orig_hash_add_if(struct batman_if *batman_if, int max_if_num)
528513
rcu_read_unlock();
529514
}
530515

531-
spin_unlock_bh(&bat_priv->orig_hash_lock);
532516
return 0;
533517

534518
err:
535519
rcu_read_unlock();
536-
spin_unlock_bh(&bat_priv->orig_hash_lock);
537520
return -ENOMEM;
538521
}
539522

@@ -601,8 +584,6 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
601584

602585
/* resize all orig nodes because orig_node->bcast_own(_sum) depend on
603586
* if_num */
604-
spin_lock_bh(&bat_priv->orig_hash_lock);
605-
606587
for (i = 0; i < hash->size; i++) {
607588
head = &hash->table[i];
608589

@@ -637,11 +618,9 @@ int orig_hash_del_if(struct batman_if *batman_if, int max_if_num)
637618
rcu_read_unlock();
638619

639620
batman_if->if_num = -1;
640-
spin_unlock_bh(&bat_priv->orig_hash_lock);
641621
return 0;
642622

643623
err:
644624
rcu_read_unlock();
645-
spin_unlock_bh(&bat_priv->orig_hash_lock);
646625
return -ENOMEM;
647626
}

0 commit comments

Comments
 (0)