Lines Matching refs:ops
122 static int ops_init(const struct pernet_operations *ops, struct net *net) in ops_init() argument
128 if (ops->id && ops->size) { in ops_init()
129 data = kzalloc(ops->size, GFP_KERNEL); in ops_init()
133 err = net_assign_generic(net, *ops->id, data); in ops_init()
138 if (ops->init) in ops_init()
139 err = ops->init(net); in ops_init()
143 if (ops->id && ops->size) { in ops_init()
146 ng->ptr[*ops->id] = NULL; in ops_init()
156 static void ops_pre_exit_list(const struct pernet_operations *ops, in ops_pre_exit_list() argument
161 if (ops->pre_exit) { in ops_pre_exit_list()
163 ops->pre_exit(net); in ops_pre_exit_list()
167 static void ops_exit_list(const struct pernet_operations *ops, in ops_exit_list() argument
171 if (ops->exit) { in ops_exit_list()
173 ops->exit(net); in ops_exit_list()
177 if (ops->exit_batch) in ops_exit_list()
178 ops->exit_batch(net_exit_list); in ops_exit_list()
181 static void ops_free_list(const struct pernet_operations *ops, in ops_free_list() argument
185 if (ops->size && ops->id) { in ops_free_list()
187 kfree(net_generic(net, *ops->id)); in ops_free_list()
323 const struct pernet_operations *ops, *saved_ops; in setup_net() local
341 list_for_each_entry(ops, &pernet_list, list) { in setup_net()
342 error = ops_init(ops, net); in setup_net()
357 saved_ops = ops; in setup_net()
358 list_for_each_entry_continue_reverse(ops, &pernet_list, list) in setup_net()
359 ops_pre_exit_list(ops, &net_exit_list); in setup_net()
363 ops = saved_ops; in setup_net()
364 list_for_each_entry_continue_reverse(ops, &pernet_list, list) in setup_net()
365 ops_exit_list(ops, &net_exit_list); in setup_net()
367 ops = saved_ops; in setup_net()
368 list_for_each_entry_continue_reverse(ops, &pernet_list, list) in setup_net()
369 ops_free_list(ops, &net_exit_list); in setup_net()
571 const struct pernet_operations *ops; in cleanup_net() local
604 list_for_each_entry_reverse(ops, &pernet_list, list) in cleanup_net()
605 ops_pre_exit_list(ops, &net_exit_list); in cleanup_net()
616 list_for_each_entry_reverse(ops, &pernet_list, list) in cleanup_net()
617 ops_exit_list(ops, &net_exit_list); in cleanup_net()
620 list_for_each_entry_reverse(ops, &pernet_list, list) in cleanup_net()
621 ops_free_list(ops, &net_exit_list); in cleanup_net()
696 if (ns->ops == &netns_operations) in get_net_ns_by_fd()
731 net->ns.ops = &netns_operations; in net_ns_net_init()
1151 static void free_exit_list(struct pernet_operations *ops, struct list_head *net_exit_list) in free_exit_list() argument
1153 ops_pre_exit_list(ops, net_exit_list); in free_exit_list()
1155 ops_exit_list(ops, net_exit_list); in free_exit_list()
1156 ops_free_list(ops, net_exit_list); in free_exit_list()
1161 struct pernet_operations *ops) in __register_pernet_operations() argument
1167 list_add_tail(&ops->list, list); in __register_pernet_operations()
1168 if (ops->init || (ops->id && ops->size)) { in __register_pernet_operations()
1173 error = ops_init(ops, net); in __register_pernet_operations()
1183 list_del(&ops->list); in __register_pernet_operations()
1184 free_exit_list(ops, &net_exit_list); in __register_pernet_operations()
1188 static void __unregister_pernet_operations(struct pernet_operations *ops) in __unregister_pernet_operations() argument
1193 list_del(&ops->list); in __unregister_pernet_operations()
1198 free_exit_list(ops, &net_exit_list); in __unregister_pernet_operations()
1204 struct pernet_operations *ops) in __register_pernet_operations() argument
1207 list_add_tail(&ops->list, list); in __register_pernet_operations()
1211 return ops_init(ops, &init_net); in __register_pernet_operations()
1214 static void __unregister_pernet_operations(struct pernet_operations *ops) in __unregister_pernet_operations() argument
1217 list_del(&ops->list); in __unregister_pernet_operations()
1221 free_exit_list(ops, &net_exit_list); in __unregister_pernet_operations()
1230 struct pernet_operations *ops) in register_pernet_operations() argument
1234 if (ops->id) { in register_pernet_operations()
1239 *ops->id = error; in register_pernet_operations()
1244 WRITE_ONCE(max_gen_ptrs, max(max_gen_ptrs, *ops->id + 1)); in register_pernet_operations()
1246 error = __register_pernet_operations(list, ops); in register_pernet_operations()
1249 if (ops->id) in register_pernet_operations()
1250 ida_free(&net_generic_ids, *ops->id); in register_pernet_operations()
1256 static void unregister_pernet_operations(struct pernet_operations *ops) in unregister_pernet_operations() argument
1258 __unregister_pernet_operations(ops); in unregister_pernet_operations()
1260 if (ops->id) in unregister_pernet_operations()
1261 ida_free(&net_generic_ids, *ops->id); in unregister_pernet_operations()
1283 int register_pernet_subsys(struct pernet_operations *ops) in register_pernet_subsys() argument
1287 error = register_pernet_operations(first_device, ops); in register_pernet_subsys()
1302 void unregister_pernet_subsys(struct pernet_operations *ops) in unregister_pernet_subsys() argument
1305 unregister_pernet_operations(ops); in unregister_pernet_subsys()
1329 int register_pernet_device(struct pernet_operations *ops) in register_pernet_device() argument
1333 error = register_pernet_operations(&pernet_list, ops); in register_pernet_device()
1335 first_device = &ops->list; in register_pernet_device()
1350 void unregister_pernet_device(struct pernet_operations *ops) in unregister_pernet_device() argument
1353 if (&ops->list == first_device) in unregister_pernet_device()
1355 unregister_pernet_operations(ops); in unregister_pernet_device()