aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/bcast.c
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-10-22 08:51:37 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-24 09:56:30 -0400
commit323019069e8d96d87e9dba51f897060f94999821 (patch)
tree02d0426143d9a89548a1e6f5a0d0e2ef8448db49 /net/tipc/bcast.c
parent0e05498e9eae16a6d8c86543e77930ec152e655e (diff)
tipc: use explicit allocation of broadcast send link
The broadcast link instance (struct tipc_link) used for sending is currently aggregated into struct tipc_bclink. This means that we cannot use the regular tipc_link_create() function for initiating the link, but do instead have to initiate numerous fields directly from the bcast_init() function. We want to reduce dependencies between the broadcast functionality and the inner workings of tipc_link. In this commit, we introduce a new function tipc_bclink_create() to link.c, and allocate the instance of the link separately using this function. 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>
Diffstat (limited to 'net/tipc/bcast.c')
-rw-r--r--net/tipc/bcast.c89
1 files changed, 46 insertions, 43 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index c6f0d1dbfc3c..3b7bd2174330 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -98,10 +98,11 @@ struct tipc_bcbearer {
98 * Handles sequence numbering, fragmentation, bundling, etc. 98 * Handles sequence numbering, fragmentation, bundling, etc.
99 */ 99 */
100struct tipc_bc_base { 100struct tipc_bc_base {
101 struct tipc_link link; 101 struct tipc_link *link;
102 struct tipc_node node; 102 struct tipc_node node;
103 struct sk_buff_head arrvq; 103 struct sk_buff_head arrvq;
104 struct sk_buff_head inputq; 104 struct sk_buff_head inputq;
105 struct sk_buff_head namedq;
105 struct tipc_node_map bcast_nodes; 106 struct tipc_node_map bcast_nodes;
106 struct tipc_node *retransmit_to; 107 struct tipc_node *retransmit_to;
107}; 108};
@@ -180,7 +181,7 @@ void tipc_bclink_remove_node(struct net *net, u32 addr)
180 181
181 /* Last node? => reset backlog queue */ 182 /* Last node? => reset backlog queue */
182 if (!tn->bcbase->bcast_nodes.count) 183 if (!tn->bcbase->bcast_nodes.count)
183 tipc_link_purge_backlog(&tn->bcbase->link); 184 tipc_link_purge_backlog(tn->bcbase->link);
184 185
185 tipc_bclink_unlock(net); 186 tipc_bclink_unlock(net);
186} 187}
@@ -1010,55 +1011,56 @@ int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[])
1010 1011
1011int tipc_bcast_init(struct net *net) 1012int tipc_bcast_init(struct net *net)
1012{ 1013{
1013 struct tipc_net *tn = net_generic(net, tipc_net_id); 1014 struct tipc_net *tn = tipc_net(net);
1014 struct tipc_bcbearer *bcbearer; 1015 struct tipc_bcbearer *bcb = NULL;
1015 struct tipc_bc_base *bclink; 1016 struct tipc_bc_base *bb = NULL;
1016 struct tipc_link *bcl; 1017 struct tipc_link *l = NULL;
1017 1018
1018 bcbearer = kzalloc(sizeof(*bcbearer), GFP_ATOMIC); 1019 bcb = kzalloc(sizeof(*bcb), GFP_ATOMIC);
1019 if (!bcbearer) 1020 if (!bcb)
1020 return -ENOMEM; 1021 goto enomem;
1021 1022 tn->bcbearer = bcb;
1022 bclink = kzalloc(sizeof(*bclink), GFP_ATOMIC); 1023
1023 if (!bclink) { 1024 bcb->bearer.window = BCLINK_WIN_DEFAULT;
1024 kfree(bcbearer); 1025 bcb->bearer.mtu = MAX_PKT_DEFAULT_MCAST;
1025 return -ENOMEM; 1026 bcb->bearer.identity = MAX_BEARERS;
1026 } 1027
1027 1028 bcb->bearer.media = &bcb->media;
1028 bcl = &bclink->link; 1029 bcb->media.send_msg = tipc_bcbearer_send;
1029 bcbearer->bearer.media = &bcbearer->media; 1030 sprintf(bcb->media.name, "tipc-broadcast");
1030 bcbearer->media.send_msg = tipc_bcbearer_send; 1031 strcpy(bcb->bearer.name, bcb->media.name);
1031 sprintf(bcbearer->media.name, "tipc-broadcast"); 1032
1032 1033 bb = kzalloc(sizeof(*bb), GFP_ATOMIC);
1034 if (!bb)
1035 goto enomem;
1036 tn->bcbase = bb;
1037 __skb_queue_head_init(&bb->arrvq);
1033 spin_lock_init(&tipc_net(net)->bclock); 1038 spin_lock_init(&tipc_net(net)->bclock);
1034 __skb_queue_head_init(&bcl->transmq); 1039 bb->node.net = net;
1035 __skb_queue_head_init(&bcl->backlogq); 1040
1036 __skb_queue_head_init(&bcl->deferdq); 1041 if (!tipc_link_bc_create(&bb->node,
1037 skb_queue_head_init(&bcl->wakeupq); 1042 MAX_PKT_DEFAULT_MCAST,
1038 bcl->snd_nxt = 1; 1043 BCLINK_WIN_DEFAULT,
1039 spin_lock_init(&bclink->node.lock); 1044 &bb->inputq,
1040 __skb_queue_head_init(&bclink->arrvq); 1045 &bb->namedq,
1041 skb_queue_head_init(&bclink->inputq); 1046 &l))
1042 bcl->owner = &bclink->node; 1047 goto enomem;
1043 bcl->owner->net = net; 1048 bb->link = l;
1044 bcl->mtu = MAX_PKT_DEFAULT_MCAST; 1049 tn->bcl = l;
1045 tipc_link_set_queue_limits(bcl, BCLINK_WIN_DEFAULT); 1050 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcb->bearer);
1046 bcl->bearer_id = MAX_BEARERS;
1047 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);
1048 bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg;
1049
1050 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
1051 tn->bcbearer = bcbearer;
1052 tn->bcbase = bclink;
1053 tn->bcl = bcl;
1054 return 0; 1051 return 0;
1052enomem:
1053 kfree(bcb);
1054 kfree(bb);
1055 kfree(l);
1056 return -ENOMEM;
1055} 1057}
1056 1058
1057void tipc_bcast_reinit(struct net *net) 1059void tipc_bcast_reinit(struct net *net)
1058{ 1060{
1059 struct tipc_bc_base *b = tipc_bc_base(net); 1061 struct tipc_bc_base *b = tipc_bc_base(net);
1060 1062
1061 msg_set_prevnode(b->link.pmsg, tipc_own_addr(net)); 1063 msg_set_prevnode(b->link->pmsg, tipc_own_addr(net));
1062} 1064}
1063 1065
1064void tipc_bcast_stop(struct net *net) 1066void tipc_bcast_stop(struct net *net)
@@ -1072,6 +1074,7 @@ void tipc_bcast_stop(struct net *net)
1072 synchronize_net(); 1074 synchronize_net();
1073 kfree(tn->bcbearer); 1075 kfree(tn->bcbearer);
1074 kfree(tn->bcbase); 1076 kfree(tn->bcbase);
1077 kfree(tn->bcl);
1075} 1078}
1076 1079
1077/** 1080/**