diff options
Diffstat (limited to 'net/tipc/core.c')
| -rw-r--r-- | net/tipc/core.c | 109 |
1 files changed, 59 insertions, 50 deletions
diff --git a/net/tipc/core.c b/net/tipc/core.c index f9e88d8b04ca..80c20647b3d2 100644 --- a/net/tipc/core.c +++ b/net/tipc/core.c | |||
| @@ -77,37 +77,13 @@ 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 | */ | ||
| 82 | static void tipc_core_stop_net(void) | ||
| 83 | { | ||
| 84 | tipc_net_stop(); | ||
| 85 | tipc_bearer_cleanup(); | ||
| 86 | } | ||
| 87 | |||
| 88 | /** | ||
| 89 | * start_net - start TIPC networking sub-systems | ||
| 90 | */ | ||
| 91 | int tipc_core_start_net(unsigned long addr) | ||
| 92 | { | ||
| 93 | int res; | ||
| 94 | |||
| 95 | tipc_net_start(addr); | ||
| 96 | res = tipc_bearer_setup(); | ||
| 97 | if (res < 0) | ||
| 98 | goto err; | ||
| 99 | return res; | ||
| 100 | |||
| 101 | err: | ||
| 102 | tipc_core_stop_net(); | ||
| 103 | return res; | ||
| 104 | } | ||
| 105 | |||
| 106 | /** | ||
| 107 | * 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 |
| 108 | */ | 81 | */ |
| 109 | static void tipc_core_stop(void) | 82 | static void tipc_core_stop(void) |
| 110 | { | 83 | { |
| 84 | tipc_handler_stop(); | ||
| 85 | tipc_net_stop(); | ||
| 86 | tipc_bearer_cleanup(); | ||
| 111 | tipc_netlink_stop(); | 87 | tipc_netlink_stop(); |
| 112 | tipc_cfg_stop(); | 88 | tipc_cfg_stop(); |
| 113 | tipc_subscr_stop(); | 89 | tipc_subscr_stop(); |
| @@ -122,30 +98,65 @@ static void tipc_core_stop(void) | |||
| 122 | */ | 98 | */ |
| 123 | static int tipc_core_start(void) | 99 | static int tipc_core_start(void) |
| 124 | { | 100 | { |
| 125 | int res; | 101 | int err; |
| 126 | 102 | ||
| 127 | get_random_bytes(&tipc_random, sizeof(tipc_random)); | 103 | get_random_bytes(&tipc_random, sizeof(tipc_random)); |
| 128 | 104 | ||
| 129 | res = tipc_handler_start(); | 105 | err = tipc_handler_start(); |
| 130 | if (!res) | 106 | if (err) |
| 131 | res = tipc_ref_table_init(tipc_max_ports, tipc_random); | 107 | goto out_handler; |
| 132 | if (!res) | 108 | |
| 133 | res = tipc_nametbl_init(); | 109 | err = tipc_ref_table_init(tipc_max_ports, tipc_random); |
| 134 | if (!res) | 110 | if (err) |
| 135 | res = tipc_netlink_start(); | 111 | goto out_reftbl; |
| 136 | if (!res) | 112 | |
| 137 | res = tipc_socket_init(); | 113 | err = tipc_nametbl_init(); |
| 138 | if (!res) | 114 | if (err) |
| 139 | res = tipc_register_sysctl(); | 115 | goto out_nametbl; |
| 140 | if (!res) | 116 | |
| 141 | res = tipc_subscr_start(); | 117 | err = tipc_netlink_start(); |
| 142 | if (!res) | 118 | if (err) |
| 143 | res = tipc_cfg_init(); | 119 | goto out_netlink; |
| 144 | if (res) { | 120 | |
| 145 | tipc_handler_stop(); | 121 | err = tipc_socket_init(); |
| 146 | tipc_core_stop(); | 122 | if (err) |
| 147 | } | 123 | goto out_socket; |
| 148 | return res; | 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; | ||
| 142 | out_bearer: | ||
| 143 | tipc_cfg_stop(); | ||
| 144 | out_cfg: | ||
| 145 | tipc_subscr_stop(); | ||
| 146 | out_subscr: | ||
| 147 | tipc_unregister_sysctl(); | ||
| 148 | out_sysctl: | ||
| 149 | tipc_socket_stop(); | ||
| 150 | out_socket: | ||
| 151 | tipc_netlink_stop(); | ||
| 152 | out_netlink: | ||
| 153 | tipc_nametbl_stop(); | ||
| 154 | out_nametbl: | ||
| 155 | tipc_ref_table_stop(); | ||
| 156 | out_reftbl: | ||
| 157 | tipc_handler_stop(); | ||
| 158 | out_handler: | ||
| 159 | return err; | ||
| 149 | } | 160 | } |
| 150 | 161 | ||
| 151 | static int __init tipc_init(void) | 162 | static int __init tipc_init(void) |
| @@ -174,8 +185,6 @@ static int __init tipc_init(void) | |||
| 174 | 185 | ||
| 175 | static void __exit tipc_exit(void) | 186 | static void __exit tipc_exit(void) |
| 176 | { | 187 | { |
| 177 | tipc_handler_stop(); | ||
| 178 | tipc_core_stop_net(); | ||
| 179 | tipc_core_stop(); | 188 | tipc_core_stop(); |
| 180 | pr_info("Deactivated\n"); | 189 | pr_info("Deactivated\n"); |
| 181 | } | 190 | } |
