@@ -501,6 +501,31 @@ int mesh_gate_num(struct ieee80211_sub_if_data *sdata)
501
501
return sdata -> u .mesh .num_gates ;
502
502
}
503
503
504
+ static
505
+ struct mesh_path * mesh_path_new (struct ieee80211_sub_if_data * sdata ,
506
+ const u8 * dst , gfp_t gfp_flags )
507
+ {
508
+ struct mesh_path * new_mpath ;
509
+
510
+ new_mpath = kzalloc (sizeof (struct mesh_path ), gfp_flags );
511
+ if (!new_mpath )
512
+ return NULL ;
513
+
514
+ memcpy (new_mpath -> dst , dst , ETH_ALEN );
515
+ eth_broadcast_addr (new_mpath -> rann_snd_addr );
516
+ new_mpath -> is_root = false;
517
+ new_mpath -> sdata = sdata ;
518
+ new_mpath -> flags = 0 ;
519
+ skb_queue_head_init (& new_mpath -> frame_queue );
520
+ new_mpath -> timer .data = (unsigned long ) new_mpath ;
521
+ new_mpath -> timer .function = mesh_path_timer ;
522
+ new_mpath -> exp_time = jiffies ;
523
+ spin_lock_init (& new_mpath -> state_lock );
524
+ init_timer (& new_mpath -> timer );
525
+
526
+ return new_mpath ;
527
+ }
528
+
504
529
/**
505
530
* mesh_path_add - allocate and add a new path to the mesh path table
506
531
* @dst: destination address of the path (ETH_ALEN length)
@@ -548,27 +573,15 @@ struct mesh_path *mesh_path_add(struct ieee80211_sub_if_data *sdata,
548
573
}
549
574
550
575
err = - ENOMEM ;
551
- new_mpath = kzalloc ( sizeof ( struct mesh_path ) , GFP_ATOMIC );
576
+ new_mpath = mesh_path_new ( sdata , dst , GFP_ATOMIC );
552
577
if (!new_mpath )
553
578
goto err_path_alloc ;
554
579
555
580
new_node = kmalloc (sizeof (struct mpath_node ), GFP_ATOMIC );
556
581
if (!new_node )
557
582
goto err_node_alloc ;
558
583
559
- memcpy (new_mpath -> dst , dst , ETH_ALEN );
560
- eth_broadcast_addr (new_mpath -> rann_snd_addr );
561
- new_mpath -> is_root = false;
562
- new_mpath -> sdata = sdata ;
563
- new_mpath -> flags = 0 ;
564
- skb_queue_head_init (& new_mpath -> frame_queue );
565
584
new_node -> mpath = new_mpath ;
566
- new_mpath -> timer .data = (unsigned long ) new_mpath ;
567
- new_mpath -> timer .function = mesh_path_timer ;
568
- new_mpath -> exp_time = jiffies ;
569
- spin_lock_init (& new_mpath -> state_lock );
570
- init_timer (& new_mpath -> timer );
571
-
572
585
hlist_add_head_rcu (& new_node -> list , bucket );
573
586
if (atomic_inc_return (& tbl -> entries ) >=
574
587
MEAN_CHAIN_LEN * (tbl -> hash_mask + 1 ))
@@ -664,25 +677,17 @@ int mpp_path_add(struct ieee80211_sub_if_data *sdata,
664
677
return - ENOTSUPP ;
665
678
666
679
err = - ENOMEM ;
667
- new_mpath = kzalloc ( sizeof ( struct mesh_path ) , GFP_ATOMIC );
680
+ new_mpath = mesh_path_new ( sdata , dst , GFP_ATOMIC );
668
681
if (!new_mpath )
669
682
goto err_path_alloc ;
670
683
671
684
new_node = kmalloc (sizeof (struct mpath_node ), GFP_ATOMIC );
672
685
if (!new_node )
673
686
goto err_node_alloc ;
674
687
675
- read_lock_bh (& sdata -> u .mesh .pathtbl_resize_lock );
676
- memcpy (new_mpath -> dst , dst , ETH_ALEN );
677
688
memcpy (new_mpath -> mpp , mpp , ETH_ALEN );
678
- new_mpath -> sdata = sdata ;
679
- new_mpath -> flags = 0 ;
680
- skb_queue_head_init (& new_mpath -> frame_queue );
681
689
new_node -> mpath = new_mpath ;
682
- init_timer (& new_mpath -> timer );
683
- new_mpath -> exp_time = jiffies ;
684
- spin_lock_init (& new_mpath -> state_lock );
685
-
690
+ read_lock_bh (& sdata -> u .mesh .pathtbl_resize_lock );
686
691
tbl = resize_dereference_mpp_paths (sdata );
687
692
688
693
hash_idx = mesh_table_hash (dst , tbl );
0 commit comments