.. | .. |
---|
34 | 34 | * POSSIBILITY OF SUCH DAMAGE. |
---|
35 | 35 | */ |
---|
36 | 36 | |
---|
37 | | -#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
---|
38 | | - |
---|
39 | 37 | #include "core.h" |
---|
40 | 38 | #include "name_table.h" |
---|
41 | 39 | #include "subscr.h" |
---|
.. | .. |
---|
43 | 41 | #include "net.h" |
---|
44 | 42 | #include "socket.h" |
---|
45 | 43 | #include "bcast.h" |
---|
| 44 | +#include "node.h" |
---|
| 45 | +#include "crypto.h" |
---|
46 | 46 | |
---|
47 | 47 | #include <linux/module.h> |
---|
48 | 48 | |
---|
.. | .. |
---|
59 | 59 | tn->node_addr = 0; |
---|
60 | 60 | tn->trial_addr = 0; |
---|
61 | 61 | tn->addr_trial_end = 0; |
---|
| 62 | + tn->capabilities = TIPC_NODE_CAPABILITIES; |
---|
| 63 | + INIT_WORK(&tn->work, tipc_net_finalize_work); |
---|
62 | 64 | memset(tn->node_id, 0, sizeof(tn->node_id)); |
---|
63 | 65 | memset(tn->node_id_string, 0, sizeof(tn->node_id_string)); |
---|
64 | 66 | tn->mon_threshold = TIPC_DEF_MON_THRESHOLD; |
---|
.. | .. |
---|
66 | 68 | INIT_LIST_HEAD(&tn->node_list); |
---|
67 | 69 | spin_lock_init(&tn->node_list_lock); |
---|
68 | 70 | |
---|
| 71 | +#ifdef CONFIG_TIPC_CRYPTO |
---|
| 72 | + err = tipc_crypto_start(&tn->crypto_tx, net, NULL); |
---|
| 73 | + if (err) |
---|
| 74 | + goto out_crypto; |
---|
| 75 | +#endif |
---|
69 | 76 | err = tipc_sk_rht_init(net); |
---|
70 | 77 | if (err) |
---|
71 | 78 | goto out_sk_rht; |
---|
.. | .. |
---|
80 | 87 | if (err) |
---|
81 | 88 | goto out_bclink; |
---|
82 | 89 | |
---|
| 90 | + err = tipc_attach_loopback(net); |
---|
| 91 | + if (err) |
---|
| 92 | + goto out_bclink; |
---|
| 93 | + |
---|
83 | 94 | return 0; |
---|
84 | 95 | |
---|
85 | 96 | out_bclink: |
---|
.. | .. |
---|
87 | 98 | out_nametbl: |
---|
88 | 99 | tipc_sk_rht_destroy(net); |
---|
89 | 100 | out_sk_rht: |
---|
| 101 | + |
---|
| 102 | +#ifdef CONFIG_TIPC_CRYPTO |
---|
| 103 | + tipc_crypto_stop(&tn->crypto_tx); |
---|
| 104 | +out_crypto: |
---|
| 105 | +#endif |
---|
90 | 106 | return err; |
---|
91 | 107 | } |
---|
92 | 108 | |
---|
93 | 109 | static void __net_exit tipc_exit_net(struct net *net) |
---|
94 | 110 | { |
---|
95 | | - tipc_net_stop(net); |
---|
| 111 | + struct tipc_net *tn = tipc_net(net); |
---|
96 | 112 | |
---|
97 | | - /* Make sure the tipc_net_finalize_work stopped |
---|
98 | | - * before releasing the resources. |
---|
99 | | - */ |
---|
100 | | - flush_scheduled_work(); |
---|
| 113 | + tipc_detach_loopback(net); |
---|
| 114 | + tipc_net_stop(net); |
---|
| 115 | + /* Make sure the tipc_net_finalize_work() finished */ |
---|
| 116 | + cancel_work_sync(&tn->work); |
---|
101 | 117 | tipc_bcast_stop(net); |
---|
102 | 118 | tipc_nametbl_stop(net); |
---|
103 | 119 | tipc_sk_rht_destroy(net); |
---|
| 120 | +#ifdef CONFIG_TIPC_CRYPTO |
---|
| 121 | + tipc_crypto_stop(&tipc_net(net)->crypto_tx); |
---|
| 122 | +#endif |
---|
| 123 | + while (atomic_read(&tn->wq_count)) |
---|
| 124 | + cond_resched(); |
---|
104 | 125 | } |
---|
| 126 | + |
---|
| 127 | +static void __net_exit tipc_pernet_pre_exit(struct net *net) |
---|
| 128 | +{ |
---|
| 129 | + tipc_node_pre_cleanup_net(net); |
---|
| 130 | +} |
---|
| 131 | + |
---|
| 132 | +static struct pernet_operations tipc_pernet_pre_exit_ops = { |
---|
| 133 | + .pre_exit = tipc_pernet_pre_exit, |
---|
| 134 | +}; |
---|
105 | 135 | |
---|
106 | 136 | static struct pernet_operations tipc_net_ops = { |
---|
107 | 137 | .init = tipc_init_net, |
---|
.. | .. |
---|
141 | 171 | if (err) |
---|
142 | 172 | goto out_pernet_topsrv; |
---|
143 | 173 | |
---|
| 174 | + err = register_pernet_subsys(&tipc_pernet_pre_exit_ops); |
---|
| 175 | + if (err) |
---|
| 176 | + goto out_register_pernet_subsys; |
---|
| 177 | + |
---|
144 | 178 | err = tipc_bearer_setup(); |
---|
145 | 179 | if (err) |
---|
146 | 180 | goto out_bearer; |
---|
.. | .. |
---|
161 | 195 | out_netlink: |
---|
162 | 196 | tipc_bearer_cleanup(); |
---|
163 | 197 | out_bearer: |
---|
| 198 | + unregister_pernet_subsys(&tipc_pernet_pre_exit_ops); |
---|
| 199 | +out_register_pernet_subsys: |
---|
164 | 200 | unregister_pernet_device(&tipc_topsrv_net_ops); |
---|
165 | 201 | out_pernet_topsrv: |
---|
166 | 202 | tipc_socket_stop(); |
---|
.. | .. |
---|
178 | 214 | tipc_netlink_compat_stop(); |
---|
179 | 215 | tipc_netlink_stop(); |
---|
180 | 216 | tipc_bearer_cleanup(); |
---|
| 217 | + unregister_pernet_subsys(&tipc_pernet_pre_exit_ops); |
---|
181 | 218 | unregister_pernet_device(&tipc_topsrv_net_ops); |
---|
182 | 219 | tipc_socket_stop(); |
---|
183 | 220 | unregister_pernet_device(&tipc_net_ops); |
---|