19 #include <linux/kernel.h>
20 #include <linux/list.h>
21 #include <linux/module.h>
22 #include <linux/net.h>
32 static struct proto alg_proto = {
35 .memory_allocated = &alg_memory_allocated,
52 if (try_module_get(node->
type->owner))
79 list_add(&node->
list, &alg_types);
110 static void alg_do_release(
const struct af_alg_type *type,
void *
private)
116 module_put(type->
owner);
129 struct sock *
sk = sock->
sk;
138 if (addr_len !=
sizeof(*sa))
145 if (IS_ERR(type) && PTR_ERR(type) == -
ENOENT) {
146 request_module(
"algif-%s", sa->
salg_type);
151 return PTR_ERR(type);
154 if (IS_ERR(
private)) {
155 module_put(type->
owner);
156 return PTR_ERR(
private);
166 alg_do_release(type,
private);
171 static int alg_setkey(
struct sock *sk,
char __user *ukey,
195 static int alg_setsockopt(
struct socket *sock,
int level,
int optname,
196 char __user *optval,
unsigned int optlen)
198 struct sock *sk = sock->
sk;
216 err = alg_setkey(sk, optval, optlen);
245 sock_graft(sk2, newsock);
256 alg_sk(sk2)->parent =
sk;
257 alg_sk(sk2)->type =
type;
276 static const struct proto_ops alg_proto_ops = {
295 .setsockopt = alg_setsockopt,
296 .accept = alg_accept,
299 static void alg_sock_destruct(
struct sock *sk)
322 sock->
ops = &alg_proto_ops;
335 .create = alg_create,
342 unsigned long from = (
unsigned long)addr;
343 unsigned long npages;
370 for (i = 0; i < npages; i++) {
373 sg_set_page(sgl->
sg + i, sgl->
pages[i], plen, off);
438 err = completion->
err;
455 static int __init af_alg_init(
void)
464 goto out_unregister_proto;
469 out_unregister_proto:
474 static void __exit af_alg_exit(
void)