Lines Matching refs:sk
105 struct sock *sk = req->data; in skcipher_async_cb() local
106 struct alg_sock *ask = alg_sk(sk); in skcipher_async_cb()
117 static inline int skcipher_sndbuf(struct sock *sk) in skcipher_sndbuf() argument
119 struct alg_sock *ask = alg_sk(sk); in skcipher_sndbuf()
122 return max_t(int, max_t(int, sk->sk_sndbuf & PAGE_MASK, PAGE_SIZE) - in skcipher_sndbuf()
126 static inline bool skcipher_writable(struct sock *sk) in skcipher_writable() argument
128 return PAGE_SIZE <= skcipher_sndbuf(sk); in skcipher_writable()
131 static int skcipher_alloc_sgl(struct sock *sk) in skcipher_alloc_sgl() argument
133 struct alg_sock *ask = alg_sk(sk); in skcipher_alloc_sgl()
143 sgl = sock_kmalloc(sk, sizeof(*sgl) + in skcipher_alloc_sgl()
161 static void skcipher_pull_sgl(struct sock *sk, int used, int put) in skcipher_pull_sgl() argument
163 struct alg_sock *ask = alg_sk(sk); in skcipher_pull_sgl()
194 sock_kfree_s(sk, sgl, in skcipher_pull_sgl()
203 static void skcipher_free_sgl(struct sock *sk) in skcipher_free_sgl() argument
205 struct alg_sock *ask = alg_sk(sk); in skcipher_free_sgl()
208 skcipher_pull_sgl(sk, ctx->used, 1); in skcipher_free_sgl()
211 static int skcipher_wait_for_wmem(struct sock *sk, unsigned flags) in skcipher_wait_for_wmem() argument
220 set_bit(SOCK_ASYNC_NOSPACE, &sk->sk_socket->flags); in skcipher_wait_for_wmem()
225 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); in skcipher_wait_for_wmem()
227 if (sk_wait_event(sk, &timeout, skcipher_writable(sk))) { in skcipher_wait_for_wmem()
232 finish_wait(sk_sleep(sk), &wait); in skcipher_wait_for_wmem()
237 static void skcipher_wmem_wakeup(struct sock *sk) in skcipher_wmem_wakeup() argument
241 if (!skcipher_writable(sk)) in skcipher_wmem_wakeup()
245 wq = rcu_dereference(sk->sk_wq); in skcipher_wmem_wakeup()
250 sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); in skcipher_wmem_wakeup()
254 static int skcipher_wait_for_data(struct sock *sk, unsigned flags) in skcipher_wait_for_data() argument
256 struct alg_sock *ask = alg_sk(sk); in skcipher_wait_for_data()
266 set_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); in skcipher_wait_for_data()
271 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); in skcipher_wait_for_data()
273 if (sk_wait_event(sk, &timeout, ctx->used)) { in skcipher_wait_for_data()
278 finish_wait(sk_sleep(sk), &wait); in skcipher_wait_for_data()
280 clear_bit(SOCK_ASYNC_WAITDATA, &sk->sk_socket->flags); in skcipher_wait_for_data()
285 static void skcipher_data_wakeup(struct sock *sk) in skcipher_data_wakeup() argument
287 struct alg_sock *ask = alg_sk(sk); in skcipher_data_wakeup()
295 wq = rcu_dereference(sk->sk_wq); in skcipher_data_wakeup()
300 sk_wake_async(sk, SOCK_WAKE_SPACE, POLL_OUT); in skcipher_data_wakeup()
307 struct sock *sk = sock->sk; in skcipher_sendmsg() local
308 struct alg_sock *ask = alg_sk(sk); in skcipher_sendmsg()
343 lock_sock(sk); in skcipher_sendmsg()
381 if (!skcipher_writable(sk)) { in skcipher_sendmsg()
382 err = skcipher_wait_for_wmem(sk, msg->msg_flags); in skcipher_sendmsg()
387 len = min_t(unsigned long, len, skcipher_sndbuf(sk)); in skcipher_sendmsg()
389 err = skcipher_alloc_sgl(sk); in skcipher_sendmsg()
433 skcipher_data_wakeup(sk); in skcipher_sendmsg()
434 release_sock(sk); in skcipher_sendmsg()
442 struct sock *sk = sock->sk; in skcipher_sendpage() local
443 struct alg_sock *ask = alg_sk(sk); in skcipher_sendpage()
451 lock_sock(sk); in skcipher_sendpage()
458 if (!skcipher_writable(sk)) { in skcipher_sendpage()
459 err = skcipher_wait_for_wmem(sk, flags); in skcipher_sendpage()
464 err = skcipher_alloc_sgl(sk); in skcipher_sendpage()
484 skcipher_data_wakeup(sk); in skcipher_sendpage()
485 release_sock(sk); in skcipher_sendpage()
510 struct sock *sk = sock->sk; in skcipher_recvmsg_async() local
511 struct alg_sock *ask = alg_sk(sk); in skcipher_recvmsg_async()
524 lock_sock(sk); in skcipher_recvmsg_async()
542 skcipher_async_cb, sk); in skcipher_recvmsg_async()
549 err = skcipher_wait_for_data(sk, flags); in skcipher_recvmsg_async()
610 skcipher_pull_sgl(sk, used, 0); in skcipher_recvmsg_async()
630 skcipher_wmem_wakeup(sk); in skcipher_recvmsg_async()
631 release_sock(sk); in skcipher_recvmsg_async()
638 struct sock *sk = sock->sk; in skcipher_recvmsg_sync() local
639 struct alg_sock *ask = alg_sk(sk); in skcipher_recvmsg_sync()
649 lock_sock(sk); in skcipher_recvmsg_sync()
659 err = skcipher_wait_for_data(sk, flags); in skcipher_recvmsg_sync()
695 skcipher_pull_sgl(sk, used, 1); in skcipher_recvmsg_sync()
702 skcipher_wmem_wakeup(sk); in skcipher_recvmsg_sync()
703 release_sock(sk); in skcipher_recvmsg_sync()
719 struct sock *sk = sock->sk; in skcipher_poll() local
720 struct alg_sock *ask = alg_sk(sk); in skcipher_poll()
724 sock_poll_wait(file, sk_sleep(sk), wait); in skcipher_poll()
730 if (skcipher_writable(sk)) in skcipher_poll()
764 struct sock *sk = sock->sk; in skcipher_check_key() local
765 struct alg_sock *ask = alg_sk(sk); in skcipher_check_key()
767 lock_sock(sk); in skcipher_check_key()
791 release_sock(sk); in skcipher_check_key()
893 static void skcipher_wait(struct sock *sk) in skcipher_wait() argument
895 struct alg_sock *ask = alg_sk(sk); in skcipher_wait()
903 static void skcipher_sock_destruct(struct sock *sk) in skcipher_sock_destruct() argument
905 struct alg_sock *ask = alg_sk(sk); in skcipher_sock_destruct()
910 skcipher_wait(sk); in skcipher_sock_destruct()
912 skcipher_free_sgl(sk); in skcipher_sock_destruct()
913 sock_kzfree_s(sk, ctx->iv, crypto_ablkcipher_ivsize(tfm)); in skcipher_sock_destruct()
914 sock_kfree_s(sk, ctx, ctx->len); in skcipher_sock_destruct()
915 af_alg_release_parent(sk); in skcipher_sock_destruct()
918 static int skcipher_accept_parent_nokey(void *private, struct sock *sk) in skcipher_accept_parent_nokey() argument
921 struct alg_sock *ask = alg_sk(sk); in skcipher_accept_parent_nokey()
926 ctx = sock_kmalloc(sk, len, GFP_KERNEL); in skcipher_accept_parent_nokey()
930 ctx->iv = sock_kmalloc(sk, crypto_ablkcipher_ivsize(skcipher), in skcipher_accept_parent_nokey()
933 sock_kfree_s(sk, ctx, len); in skcipher_accept_parent_nokey()
954 sk->sk_destruct = skcipher_sock_destruct; in skcipher_accept_parent_nokey()
959 static int skcipher_accept_parent(void *private, struct sock *sk) in skcipher_accept_parent() argument
966 return skcipher_accept_parent_nokey(private, sk); in skcipher_accept_parent()