summaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-04-20 22:55:45 -0400
committerDavid S. Miller <davem@davemloft.net>2014-04-22 21:17:52 -0400
commitf8322dfce5766c8e26d9224cbcaf6fdc0b2eb04d (patch)
tree9631ad1e81d63e7199350788f997733a5eb873e9 /net/tipc/bcast.c
parentf97e455abf0d83b7d69da295163db18e3ebb4d8b (diff)
tipc: convert bearer_list to RCU list
Convert bearer_list to RCU list. It's protected by RTNL lock on update side, and RCU read lock is applied to read side. Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Tested-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r--net/tipc/bcast.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index 95ab5ef92920..223a19929024 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -659,6 +659,7 @@ void tipc_bcbearer_sort(void)
659{ 659{
660 struct tipc_bcbearer_pair *bp_temp = bcbearer->bpairs_temp; 660 struct tipc_bcbearer_pair *bp_temp = bcbearer->bpairs_temp;
661 struct tipc_bcbearer_pair *bp_curr; 661 struct tipc_bcbearer_pair *bp_curr;
662 struct tipc_bearer *b;
662 int b_index; 663 int b_index;
663 int pri; 664 int pri;
664 665
@@ -667,8 +668,9 @@ void tipc_bcbearer_sort(void)
667 /* Group bearers by priority (can assume max of two per priority) */ 668 /* Group bearers by priority (can assume max of two per priority) */
668 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp)); 669 memset(bp_temp, 0, sizeof(bcbearer->bpairs_temp));
669 670
671 rcu_read_lock();
670 for (b_index = 0; b_index < MAX_BEARERS; b_index++) { 672 for (b_index = 0; b_index < MAX_BEARERS; b_index++) {
671 struct tipc_bearer *b = bearer_list[b_index]; 673 b = rcu_dereference_rtnl(bearer_list[b_index]);
672 if (!b || !b->nodes.count) 674 if (!b || !b->nodes.count)
673 continue; 675 continue;
674 676
@@ -677,6 +679,7 @@ void tipc_bcbearer_sort(void)
677 else 679 else
678 bp_temp[b->priority].secondary = b; 680 bp_temp[b->priority].secondary = b;
679 } 681 }
682 rcu_read_unlock();
680 683
681 /* Create array of bearer pairs for broadcasting */ 684 /* Create array of bearer pairs for broadcasting */
682 bp_curr = bcbearer->bpairs; 685 bp_curr = bcbearer->bpairs;
@@ -784,7 +787,7 @@ void tipc_bclink_init(void)
784 bcl->max_pkt = MAX_PKT_DEFAULT_MCAST; 787 bcl->max_pkt = MAX_PKT_DEFAULT_MCAST;
785 tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT); 788 tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT);
786 bcl->b_ptr = &bcbearer->bearer; 789 bcl->b_ptr = &bcbearer->bearer;
787 bearer_list[BCBEARER] = &bcbearer->bearer; 790 rcu_assign_pointer(bearer_list[MAX_BEARERS], &bcbearer->bearer);
788 bcl->state = WORKING_WORKING; 791 bcl->state = WORKING_WORKING;
789 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); 792 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
790} 793}
@@ -795,7 +798,7 @@ void tipc_bclink_stop(void)
795 tipc_link_purge_queues(bcl); 798 tipc_link_purge_queues(bcl);
796 spin_unlock_bh(&bc_lock); 799 spin_unlock_bh(&bc_lock);
797 800
798 bearer_list[BCBEARER] = NULL; 801 RCU_INIT_POINTER(bearer_list[BCBEARER], NULL);
799 memset(bclink, 0, sizeof(*bclink)); 802 memset(bclink, 0, sizeof(*bclink));
800 memset(bcbearer, 0, sizeof(*bcbearer)); 803 memset(bcbearer, 0, sizeof(*bcbearer));
801} 804}