aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/core.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/core.c')
-rw-r--r--net/tipc/core.c110
1 files changed, 58 insertions, 52 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c
index fd4eeeaa972a..80c20647b3d2 100644
--- a/net/tipc/core.c
+++ b/net/tipc/core.c
@@ -77,43 +77,14 @@ struct sk_buff *tipc_buf_acquire(u32 size)
77} 77}
78 78
79/** 79/**
80 * tipc_core_stop_net - shut down TIPC networking sub-systems
81 */
82static void tipc_core_stop_net(void)
83{
84 tipc_net_stop();
85 tipc_eth_media_stop();
86 tipc_ib_media_stop();
87}
88
89/**
90 * start_net - start TIPC networking sub-systems
91 */
92int tipc_core_start_net(unsigned long addr)
93{
94 int res;
95
96 tipc_net_start(addr);
97 res = tipc_eth_media_start();
98 if (res < 0)
99 goto err;
100 res = tipc_ib_media_start();
101 if (res < 0)
102 goto err;
103 return res;
104
105err:
106 tipc_core_stop_net();
107 return res;
108}
109
110/**
111 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode 80 * tipc_core_stop - switch TIPC from SINGLE NODE to NOT RUNNING mode
112 */ 81 */
113static void tipc_core_stop(void) 82static void tipc_core_stop(void)
114{ 83{
115 tipc_netlink_stop();
116 tipc_handler_stop(); 84 tipc_handler_stop();
85 tipc_net_stop();
86 tipc_bearer_cleanup();
87 tipc_netlink_stop();
117 tipc_cfg_stop(); 88 tipc_cfg_stop();
118 tipc_subscr_stop(); 89 tipc_subscr_stop();
119 tipc_nametbl_stop(); 90 tipc_nametbl_stop();
@@ -127,29 +98,65 @@ static void tipc_core_stop(void)
127 */ 98 */
128static int tipc_core_start(void) 99static int tipc_core_start(void)
129{ 100{
130 int res; 101 int err;
131 102
132 get_random_bytes(&tipc_random, sizeof(tipc_random)); 103 get_random_bytes(&tipc_random, sizeof(tipc_random));
133 104
134 res = tipc_handler_start(); 105 err = tipc_handler_start();
135 if (!res) 106 if (err)
136 res = tipc_ref_table_init(tipc_max_ports, tipc_random); 107 goto out_handler;
137 if (!res)
138 res = tipc_nametbl_init();
139 if (!res)
140 res = tipc_netlink_start();
141 if (!res)
142 res = tipc_socket_init();
143 if (!res)
144 res = tipc_register_sysctl();
145 if (!res)
146 res = tipc_subscr_start();
147 if (!res)
148 res = tipc_cfg_init();
149 if (res)
150 tipc_core_stop();
151 108
152 return res; 109 err = tipc_ref_table_init(tipc_max_ports, tipc_random);
110 if (err)
111 goto out_reftbl;
112
113 err = tipc_nametbl_init();
114 if (err)
115 goto out_nametbl;
116
117 err = tipc_netlink_start();
118 if (err)
119 goto out_netlink;
120
121 err = tipc_socket_init();
122 if (err)
123 goto out_socket;
124
125 err = tipc_register_sysctl();
126 if (err)
127 goto out_sysctl;
128
129 err = tipc_subscr_start();
130 if (err)
131 goto out_subscr;
132
133 err = tipc_cfg_init();
134 if (err)
135 goto out_cfg;
136
137 err = tipc_bearer_setup();
138 if (err)
139 goto out_bearer;
140
141 return 0;
142out_bearer:
143 tipc_cfg_stop();
144out_cfg:
145 tipc_subscr_stop();
146out_subscr:
147 tipc_unregister_sysctl();
148out_sysctl:
149 tipc_socket_stop();
150out_socket:
151 tipc_netlink_stop();
152out_netlink:
153 tipc_nametbl_stop();
154out_nametbl:
155 tipc_ref_table_stop();
156out_reftbl:
157 tipc_handler_stop();
158out_handler:
159 return err;
153} 160}
154 161
155static int __init tipc_init(void) 162static int __init tipc_init(void)
@@ -178,7 +185,6 @@ static int __init tipc_init(void)
178 185
179static void __exit tipc_exit(void) 186static void __exit tipc_exit(void)
180{ 187{
181 tipc_core_stop_net();
182 tipc_core_stop(); 188 tipc_core_stop();
183 pr_info("Deactivated\n"); 189 pr_info("Deactivated\n");
184} 190}