• Home
  • Raw
  • Download

Lines Matching refs:sk

60 static inline int skcipher_sndbuf(struct sock *sk)  in skcipher_sndbuf()  argument
62 struct alg_sock *ask = alg_sk(sk); in skcipher_sndbuf()
65 return max_t(int, max_t(int, sk->sk_sndbuf & PAGE_MASK, PAGE_SIZE) - in skcipher_sndbuf()
69 static inline bool skcipher_writable(struct sock *sk) in skcipher_writable() argument
71 return PAGE_SIZE <= skcipher_sndbuf(sk); in skcipher_writable()
74 static int skcipher_alloc_sgl(struct sock *sk) in skcipher_alloc_sgl() argument
76 struct alg_sock *ask = alg_sk(sk); in skcipher_alloc_sgl()
86 sgl = sock_kmalloc(sk, sizeof(*sgl) + in skcipher_alloc_sgl()
106 static void skcipher_pull_sgl(struct sock *sk, int used) in skcipher_pull_sgl() argument
108 struct alg_sock *ask = alg_sk(sk); in skcipher_pull_sgl()
139 sock_kfree_s(sk, sgl, in skcipher_pull_sgl()
148 static void skcipher_free_sgl(struct sock *sk) in skcipher_free_sgl() argument
150 struct alg_sock *ask = alg_sk(sk); in skcipher_free_sgl()
153 skcipher_pull_sgl(sk, ctx->used); in skcipher_free_sgl()
156 static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags) in skcipher_wait_for_wmem() argument
165 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); in skcipher_wait_for_wmem()
170 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); in skcipher_wait_for_wmem()
172 if (sk_wait_event(sk, &timeout, skcipher_writable(sk))) { in skcipher_wait_for_wmem()
177 finish_wait(sk_sleep(sk), &wait); in skcipher_wait_for_wmem()
182 static void skcipher_wmem_wakeup(struct sock *sk) in skcipher_wmem_wakeup() argument
186 if (!skcipher_writable(sk)) in skcipher_wmem_wakeup()
190 wq = rcu_dereference(sk->sk_wq); in skcipher_wmem_wakeup()
195 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); in skcipher_wmem_wakeup()
199 static int skcipher_wait_for_data(struct sock *sk, unsigned flags) in skcipher_wait_for_data() argument
201 struct alg_sock *ask = alg_sk(sk); in skcipher_wait_for_data()
211 set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); in skcipher_wait_for_data()
216 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); in skcipher_wait_for_data()
218 if (sk_wait_event(sk, &timeout, ctx->used)) { in skcipher_wait_for_data()
223 finish_wait(sk_sleep(sk), &wait); in skcipher_wait_for_data()
225 clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); in skcipher_wait_for_data()
230 static void skcipher_data_wakeup(struct sock *sk) in skcipher_data_wakeup() argument
232 struct alg_sock *ask = alg_sk(sk); in skcipher_data_wakeup()
240 wq = rcu_dereference(sk->sk_wq); in skcipher_data_wakeup()
245 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); in skcipher_data_wakeup()
252 struct sock *sk = sock->sk; in skcipher_sendmsg() local
253 struct alg_sock *ask = alg_sk(sk); in skcipher_sendmsg()
286 lock_sock(sk); in skcipher_sendmsg()
324 if (!skcipher_writable(sk)) { in skcipher_sendmsg()
325 err = skcipher_wait_for_wmem(sk, msg->msg_flags); in skcipher_sendmsg()
330 len = min_t(unsigned long, len, skcipher_sndbuf(sk)); in skcipher_sendmsg()
332 err = skcipher_alloc_sgl(sk); in skcipher_sendmsg()
373 skcipher_data_wakeup(sk); in skcipher_sendmsg()
374 release_sock(sk); in skcipher_sendmsg()
382 struct sock *sk = sock->sk; in skcipher_sendpage() local
383 struct alg_sock *ask = alg_sk(sk); in skcipher_sendpage()
391 lock_sock(sk); in skcipher_sendpage()
398 if (!skcipher_writable(sk)) { in skcipher_sendpage()
399 err = skcipher_wait_for_wmem(sk, flags); in skcipher_sendpage()
404 err = skcipher_alloc_sgl(sk); in skcipher_sendpage()
422 skcipher_data_wakeup(sk); in skcipher_sendpage()
423 release_sock(sk); in skcipher_sendpage()
431 struct sock *sk = sock->sk; in skcipher_recvmsg() local
432 struct alg_sock *ask = alg_sk(sk); in skcipher_recvmsg()
444 lock_sock(sk); in skcipher_recvmsg()
453 err = skcipher_wait_for_data(sk, flags); in skcipher_recvmsg()
498 skcipher_pull_sgl(sk, used); in skcipher_recvmsg()
505 skcipher_wmem_wakeup(sk); in skcipher_recvmsg()
506 release_sock(sk); in skcipher_recvmsg()
515 struct sock *sk = sock->sk; in skcipher_poll() local
516 struct alg_sock *ask = alg_sk(sk); in skcipher_poll()
520 sock_poll_wait(file, sk_sleep(sk), wait); in skcipher_poll()
526 if (skcipher_writable(sk)) in skcipher_poll()
560 struct sock *sk = sock->sk; in skcipher_check_key() local
561 struct alg_sock *ask = alg_sk(sk); in skcipher_check_key()
563 lock_sock(sk); in skcipher_check_key()
587 release_sock(sk); in skcipher_check_key()
689 static void skcipher_sock_destruct(struct sock *sk) in skcipher_sock_destruct() argument
691 struct alg_sock *ask = alg_sk(sk); in skcipher_sock_destruct()
695 skcipher_free_sgl(sk); in skcipher_sock_destruct()
696 sock_kfree_s(sk, ctx->iv, crypto_ablkcipher_ivsize(tfm)); in skcipher_sock_destruct()
697 sock_kfree_s(sk, ctx, ctx->len); in skcipher_sock_destruct()
698 af_alg_release_parent(sk); in skcipher_sock_destruct()
701 static int skcipher_accept_parent_nokey(void *private, struct sock *sk) in skcipher_accept_parent_nokey() argument
704 struct alg_sock *ask = alg_sk(sk); in skcipher_accept_parent_nokey()
709 ctx = sock_kmalloc(sk, len, GFP_KERNEL); in skcipher_accept_parent_nokey()
713 ctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(skcipher), in skcipher_accept_parent_nokey()
716 sock_kfree_s(sk, ctx, len); in skcipher_accept_parent_nokey()
737 sk->sk_destruct = skcipher_sock_destruct; in skcipher_accept_parent_nokey()
742 static int skcipher_accept_parent(void *private, struct sock *sk) in skcipher_accept_parent() argument
749 return skcipher_accept_parent_nokey(private, sk); in skcipher_accept_parent()