]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
tipc: move broadcast link lock to struct tipc_net
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 22 Oct 2015 12:51:34 +0000 (08:51 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sat, 24 Oct 2015 13:56:25 +0000 (06:56 -0700)
The broadcast lock will need to be acquired outside bcast.c in a later
commit. For this reason, we move the lock to struct tipc_net. Consistent
with the changes in the previous commit, we also introducee two new
functions tipc_bcast_lock() and tipc_bcast_unlock(). The code that is
currently using tipc_bclink_lock()/unlock() will be phased out during
the coming commits in this series.

Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/bcast.c
net/tipc/bcast.h
net/tipc/core.h

index 2c5f5443354af5dd50e7f88d0e38e2b804058ece..ebf4fd7c3749ebba3ec0b1aa74b43d010283dffd 100644 (file)
@@ -90,7 +90,6 @@ struct tipc_bcbearer {
 
 /**
  * struct tipc_bc_base - link used for broadcast messages
- * @lock: spinlock governing access to structure
  * @link: (non-standard) broadcast link structure
  * @node: (non-standard) node structure representing b'cast link's peer node
  * @bcast_nodes: map of broadcast-capable nodes
@@ -99,7 +98,6 @@ struct tipc_bcbearer {
  * Handles sequence numbering, fragmentation, bundling, etc.
  */
 struct tipc_bc_base {
-       spinlock_t lock; /* spinlock protecting broadcast structs */
        struct tipc_link link;
        struct tipc_node node;
        struct sk_buff_head arrvq;
@@ -124,16 +122,12 @@ static void tipc_nmap_add(struct tipc_node_map *nm_ptr, u32 node);
 static void tipc_nmap_remove(struct tipc_node_map *nm_ptr, u32 node);
 static void tipc_bclink_lock(struct net *net)
 {
-       struct tipc_net *tn = net_generic(net, tipc_net_id);
-
-       spin_lock_bh(&tn->bcbase->lock);
+       tipc_bcast_lock(net);
 }
 
 static void tipc_bclink_unlock(struct net *net)
 {
-       struct tipc_net *tn = net_generic(net, tipc_net_id);
-
-       spin_unlock_bh(&tn->bcbase->lock);
+       tipc_bcast_unlock(net);
 }
 
 void tipc_bclink_input(struct net *net)
@@ -1031,7 +1025,7 @@ int tipc_bcast_init(struct net *net)
        bcbearer->media.send_msg = tipc_bcbearer_send;
        sprintf(bcbearer->media.name, "tipc-broadcast");
 
-       spin_lock_init(&bclink->lock);
+       spin_lock_init(&tipc_net(net)->bclock);
        __skb_queue_head_init(&bcl->transmq);
        __skb_queue_head_init(&bcl->backlogq);
        __skb_queue_head_init(&bcl->deferdq);
index d379b0afe8e8c3a3d1ab20c18361444ce30a03b9..eac912abacd2f9163dddefbc93002fc63ad98fed 100644 (file)
@@ -69,4 +69,14 @@ int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
 void tipc_bclink_input(struct net *net);
 void tipc_bclink_sync_state(struct tipc_node *n, struct tipc_msg *msg);
 
+static inline void tipc_bcast_lock(struct net *net)
+{
+       spin_lock_bh(&tipc_net(net)->bclock);
+}
+
+static inline void tipc_bcast_unlock(struct net *net)
+{
+       spin_unlock_bh(&tipc_net(net)->bclock);
+}
+
 #endif
index e4e9a56de64b53ec925f4e7d27bbb55ba31edbac..645dcac9575d569e3e8c20b4f634a73a8ed7956f 100644 (file)
@@ -93,6 +93,7 @@ struct tipc_net {
        struct tipc_bearer __rcu *bearer_list[MAX_BEARERS + 1];
 
        /* Broadcast link */
+       spinlock_t bclock;
        struct tipc_bcbearer *bcbearer;
        struct tipc_bc_base *bcbase;
        struct tipc_link *bcl;