summaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorJon Paul Maloy <jon.maloy@ericsson.com>2015-10-22 08:51:35 -0400
committerDavid S. Miller <davem@davemloft.net>2015-10-24 09:56:27 -0400
commit5fd9fd635104f4816da158cdac6917e99e192eac (patch)
tree18b6a2fd254fa3997278470b12288111d5294f5e /net/tipc
parent0043550b0a88b72216161d6f25eb0a2e0e78babf (diff)
tipc: create broadcast transmission link at namespace init
The broadcast transmission link is currently instantiated when the network subsystem is started, i.e., on order from user space via netlink. This forces the broadcast transmission code to do unnecessary tests for the existence of the transmission link, as well in single mode node as in network mode. In this commit, we do instead create the link during initialization of the name space, and remove it when it is stopped. The fact that the transmission link now has a guaranteed longer life cycle than any of its potential clients paves the way for further code simplifcations and optimizations. 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')
-rw-r--r--net/tipc/bcast.c15
-rw-r--r--net/tipc/bcast.h1
-rw-r--r--net/tipc/core.c9
-rw-r--r--net/tipc/net.c6
4 files changed, 24 insertions, 7 deletions
diff --git a/net/tipc/bcast.c b/net/tipc/bcast.c
index ebf4fd7c3749..c6f0d1dbfc3c 100644
--- a/net/tipc/bcast.c
+++ b/net/tipc/bcast.c
@@ -106,6 +106,11 @@ struct tipc_bc_base {
106 struct tipc_node *retransmit_to; 106 struct tipc_node *retransmit_to;
107}; 107};
108 108
109static struct tipc_bc_base *tipc_bc_base(struct net *net)
110{
111 return tipc_net(net)->bcbase;
112}
113
109/** 114/**
110 * tipc_nmap_equal - test for equality of node maps 115 * tipc_nmap_equal - test for equality of node maps
111 */ 116 */
@@ -1041,7 +1046,7 @@ int tipc_bcast_init(struct net *net)
1041 bcl->bearer_id = MAX_BEARERS; 1046 bcl->bearer_id = MAX_BEARERS;
1042 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer); 1047 rcu_assign_pointer(tn->bearer_list[MAX_BEARERS], &bcbearer->bearer);
1043 bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg; 1048 bcl->pmsg = (struct tipc_msg *)&bcl->proto_msg;
1044 msg_set_prevnode(bcl->pmsg, tn->own_addr); 1049
1045 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME); 1050 strlcpy(bcl->name, tipc_bclink_name, TIPC_MAX_LINK_NAME);
1046 tn->bcbearer = bcbearer; 1051 tn->bcbearer = bcbearer;
1047 tn->bcbase = bclink; 1052 tn->bcbase = bclink;
@@ -1049,6 +1054,13 @@ int tipc_bcast_init(struct net *net)
1049 return 0; 1054 return 0;
1050} 1055}
1051 1056
1057void tipc_bcast_reinit(struct net *net)
1058{
1059 struct tipc_bc_base *b = tipc_bc_base(net);
1060
1061 msg_set_prevnode(b->link.pmsg, tipc_own_addr(net));
1062}
1063
1052void tipc_bcast_stop(struct net *net) 1064void tipc_bcast_stop(struct net *net)
1053{ 1065{
1054 struct tipc_net *tn = net_generic(net, tipc_net_id); 1066 struct tipc_net *tn = net_generic(net, tipc_net_id);
@@ -1056,7 +1068,6 @@ void tipc_bcast_stop(struct net *net)
1056 tipc_bclink_lock(net); 1068 tipc_bclink_lock(net);
1057 tipc_link_purge_queues(tn->bcl); 1069 tipc_link_purge_queues(tn->bcl);
1058 tipc_bclink_unlock(net); 1070 tipc_bclink_unlock(net);
1059
1060 RCU_INIT_POINTER(tn->bearer_list[BCBEARER], NULL); 1071 RCU_INIT_POINTER(tn->bearer_list[BCBEARER], NULL);
1061 synchronize_net(); 1072 synchronize_net();
1062 kfree(tn->bcbearer); 1073 kfree(tn->bcbearer);
diff --git a/net/tipc/bcast.h b/net/tipc/bcast.h
index eac912abacd2..041935d4ad6d 100644
--- a/net/tipc/bcast.h
+++ b/net/tipc/bcast.h
@@ -47,6 +47,7 @@ struct tipc_node_map;
47extern const char tipc_bclink_name[]; 47extern const char tipc_bclink_name[];
48 48
49int tipc_bcast_init(struct net *net); 49int tipc_bcast_init(struct net *net);
50void tipc_bcast_reinit(struct net *net);
50void tipc_bcast_stop(struct net *net); 51void tipc_bcast_stop(struct net *net);
51void tipc_bclink_add_node(struct net *net, u32 addr); 52void tipc_bclink_add_node(struct net *net, u32 addr);
52void tipc_bclink_remove_node(struct net *net, u32 addr); 53void tipc_bclink_remove_node(struct net *net, u32 addr);
diff --git a/net/tipc/core.c b/net/tipc/core.c
index 005ba5eb0ea4..03a842870c52 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -42,6 +42,7 @@
42#include "bearer.h" 42#include "bearer.h"
43#include "net.h" 43#include "net.h"
44#include "socket.h" 44#include "socket.h"
45#include "bcast.h"
45 46
46#include <linux/module.h> 47#include <linux/module.h>
47 48
@@ -71,8 +72,15 @@ static int __net_init tipc_init_net(struct net *net)
71 err = tipc_topsrv_start(net); 72 err = tipc_topsrv_start(net);
72 if (err) 73 if (err)
73 goto out_subscr; 74 goto out_subscr;
75
76 err = tipc_bcast_init(net);
77 if (err)
78 goto out_bclink;
79
74 return 0; 80 return 0;
75 81
82out_bclink:
83 tipc_bcast_stop(net);
76out_subscr: 84out_subscr:
77 tipc_nametbl_stop(net); 85 tipc_nametbl_stop(net);
78out_nametbl: 86out_nametbl:
@@ -85,6 +93,7 @@ static void __net_exit tipc_exit_net(struct net *net)
85{ 93{
86 tipc_topsrv_stop(net); 94 tipc_topsrv_stop(net);
87 tipc_net_stop(net); 95 tipc_net_stop(net);
96 tipc_bcast_stop(net);
88 tipc_nametbl_stop(net); 97 tipc_nametbl_stop(net);
89 tipc_sk_rht_destroy(net); 98 tipc_sk_rht_destroy(net);
90} 99}
diff --git a/net/tipc/net.c b/net/tipc/net.c
index dc623d5358aa..77bf9113c7a7 100644
--- a/net/tipc/net.c
+++ b/net/tipc/net.c
@@ -112,14 +112,11 @@ int tipc_net_start(struct net *net, u32 addr)
112{ 112{
113 struct tipc_net *tn = net_generic(net, tipc_net_id); 113 struct tipc_net *tn = net_generic(net, tipc_net_id);
114 char addr_string[16]; 114 char addr_string[16];
115 int res;
116 115
117 tn->own_addr = addr; 116 tn->own_addr = addr;
118 tipc_named_reinit(net); 117 tipc_named_reinit(net);
119 tipc_sk_reinit(net); 118 tipc_sk_reinit(net);
120 res = tipc_bcast_init(net); 119 tipc_bcast_reinit(net);
121 if (res)
122 return res;
123 120
124 tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr, 121 tipc_nametbl_publish(net, TIPC_CFG_SRV, tn->own_addr, tn->own_addr,
125 TIPC_ZONE_SCOPE, 0, tn->own_addr); 122 TIPC_ZONE_SCOPE, 0, tn->own_addr);
@@ -142,7 +139,6 @@ void tipc_net_stop(struct net *net)
142 tn->own_addr); 139 tn->own_addr);
143 rtnl_lock(); 140 rtnl_lock();
144 tipc_bearer_stop(net); 141 tipc_bearer_stop(net);
145 tipc_bcast_stop(net);
146 tipc_node_stop(net); 142 tipc_node_stop(net);
147 rtnl_unlock(); 143 rtnl_unlock();
148 144