All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Stephan Müller" <smueller@chronox.de>
To: herbert@gondor.apana.org.au
Cc: linux-crypto@vger.kernel.org
Subject: [PATCH 16/16] crypto: AF_ALG - consolidate poll syscall handler
Date: Mon, 31 Jul 2017 14:11:13 +0200	[thread overview]
Message-ID: <4962248.kL35ls7QWF@positron.chronox.de> (raw)
In-Reply-To: <4570630.RBIQc1aA22@positron.chronox.de>

Consoliate aead_poll, skcipher_poll ==> af_alg_poll

The POLLIN / POLLRDNORM is now set when either not more data is given or
the kernel is supplied with data. This is consistent to the wakeup from
sleep when the kernel waits for data.

Signed-off-by: Stephan Mueller <smueller@chronox.de>
---
 crypto/af_alg.c         | 24 ++++++++++++++++++++++++
 crypto/algif_aead.c     | 24 ++----------------------
 crypto/algif_skcipher.c | 23 ++---------------------
 include/crypto/if_alg.h |  2 ++
 4 files changed, 30 insertions(+), 43 deletions(-)

diff --git a/crypto/af_alg.c b/crypto/af_alg.c
index ef37fc3a9015..ae0e93103c76 100644
--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1080,6 +1080,30 @@ void af_alg_async_cb(struct crypto_async_request *_req, int err)
 }
 EXPORT_SYMBOL_GPL(af_alg_async_cb);
 
+/**
+ * af_alg_poll - poll system call handler
+ */
+unsigned int af_alg_poll(struct file *file, struct socket *sock,
+			 poll_table *wait)
+{
+	struct sock *sk = sock->sk;
+	struct alg_sock *ask = alg_sk(sk);
+	struct af_alg_ctx *ctx = ask->private;
+	unsigned int mask;
+
+	sock_poll_wait(file, sk_sleep(sk), wait);
+	mask = 0;
+
+	if (!ctx->more || ctx->used)
+		mask |= POLLIN | POLLRDNORM;
+
+	if (af_alg_writable(sk))
+		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
+
+	return mask;
+}
+EXPORT_SYMBOL_GPL(af_alg_poll);
+
 static int __init af_alg_init(void)
 {
 	int err = proto_register(&alg_proto, 0);
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c
index 8add641cc667..478bacf30079 100644
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -385,26 +385,6 @@ static int aead_recvmsg(struct socket *sock, struct msghdr *msg,
 	return ret;
 }
 
-static unsigned int aead_poll(struct file *file, struct socket *sock,
-			      poll_table *wait)
-{
-	struct sock *sk = sock->sk;
-	struct alg_sock *ask = alg_sk(sk);
-	struct af_alg_ctx *ctx = ask->private;
-	unsigned int mask;
-
-	sock_poll_wait(file, sk_sleep(sk), wait);
-	mask = 0;
-
-	if (!ctx->more)
-		mask |= POLLIN | POLLRDNORM;
-
-	if (af_alg_writable(sk))
-		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
-
-	return mask;
-}
-
 static struct proto_ops algif_aead_ops = {
 	.family		=	PF_ALG,
 
@@ -424,7 +404,7 @@ static struct proto_ops algif_aead_ops = {
 	.sendmsg	=	aead_sendmsg,
 	.sendpage	=	af_alg_sendpage,
 	.recvmsg	=	aead_recvmsg,
-	.poll		=	aead_poll,
+	.poll		=	af_alg_poll,
 };
 
 static int aead_check_key(struct socket *sock)
@@ -520,7 +500,7 @@ static struct proto_ops algif_aead_ops_nokey = {
 	.sendmsg	=	aead_sendmsg_nokey,
 	.sendpage	=	aead_sendpage_nokey,
 	.recvmsg	=	aead_recvmsg_nokey,
-	.poll		=	aead_poll,
+	.poll		=	af_alg_poll,
 };
 
 static void *aead_bind(const char *name, u32 type, u32 mask)
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c
index 5134df529833..5bd85c1dd188 100644
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -236,25 +236,6 @@ static int skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
 	return ret;
 }
 
-static unsigned int skcipher_poll(struct file *file, struct socket *sock,
-				  poll_table *wait)
-{
-	struct sock *sk = sock->sk;
-	struct alg_sock *ask = alg_sk(sk);
-	struct af_alg_ctx *ctx = ask->private;
-	unsigned int mask;
-
-	sock_poll_wait(file, sk_sleep(sk), wait);
-	mask = 0;
-
-	if (ctx->used)
-		mask |= POLLIN | POLLRDNORM;
-
-	if (af_alg_writable(sk))
-		mask |= POLLOUT | POLLWRNORM | POLLWRBAND;
-
-	return mask;
-}
 
 static struct proto_ops algif_skcipher_ops = {
 	.family		=	PF_ALG,
@@ -275,7 +256,7 @@ static struct proto_ops algif_skcipher_ops = {
 	.sendmsg	=	skcipher_sendmsg,
 	.sendpage	=	af_alg_sendpage,
 	.recvmsg	=	skcipher_recvmsg,
-	.poll		=	skcipher_poll,
+	.poll		=	af_alg_poll,
 };
 
 static int skcipher_check_key(struct socket *sock)
@@ -371,7 +352,7 @@ static struct proto_ops algif_skcipher_ops_nokey = {
 	.sendmsg	=	skcipher_sendmsg_nokey,
 	.sendpage	=	skcipher_sendpage_nokey,
 	.recvmsg	=	skcipher_recvmsg_nokey,
-	.poll		=	skcipher_poll,
+	.poll		=	af_alg_poll,
 };
 
 static void *skcipher_bind(const char *name, u32 type, u32 mask)
diff --git a/include/crypto/if_alg.h b/include/crypto/if_alg.h
index ef08fb4a599e..7bac3fee6061 100644
--- a/include/crypto/if_alg.h
+++ b/include/crypto/if_alg.h
@@ -254,5 +254,7 @@ int af_alg_sendmsg(struct socket *sock, struct msghdr *msg, size_t size,
 ssize_t af_alg_sendpage(struct socket *sock, struct page *page,
 			int offset, size_t size, int flags);
 void af_alg_async_cb(struct crypto_async_request *_req, int err);
+unsigned int af_alg_poll(struct file *file, struct socket *sock,
+			 poll_table *wait);
 
 #endif	/* _CRYPTO_IF_ALG_H */
-- 
2.13.3

  parent reply	other threads:[~2017-07-31 12:11 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-31 12:04 [PATCH 00/16] crypto: AF_ALG - consolidation Stephan Müller
2017-07-31 12:05 ` [PATCH 01/16] crypto: AF_ALG - consolidation of common data structures Stephan Müller
2017-07-31 12:06 ` [PATCH 02/16] crypto: AF_ALG - consolidation of context data structure Stephan Müller
2017-07-31 12:06 ` [PATCH 03/16] crypto: AF_ALG - consolidate send buffer service functions Stephan Müller
2017-07-31 12:06 ` [PATCH 04/16] crypto: AF_ALG - consolidate RX " Stephan Müller
2017-07-31 12:07 ` [PATCH 05/16] crypto: AF_ALG - consolidate TX SGL allocation Stephan Müller
2017-07-31 12:07 ` [PATCH 06/16] crypto: AF_ALG - consolidate counting TX SG entries Stephan Müller
2017-07-31 12:07 ` [PATCH 07/16] " Stephan Müller
2017-07-31 12:08 ` [PATCH 08/16] crypto: AF_ALG - consolidate freeing TX/RX SGLs Stephan Müller
2017-07-31 12:08 ` [PATCH 09/16] crypto: AF_ALG - consolidate waiting for wmem Stephan Müller
2017-07-31 12:08 ` [PATCH 10/16] crypto: AF_ALG - consolidate waking up on writable memory Stephan Müller
2017-07-31 12:09 ` [PATCH 11/16] crypto: AF_ALG - consolidate waiting for TX data Stephan Müller
2017-07-31 12:09 ` [PATCH 12/16] crypto: AF_ALG - consolidate waking up caller " Stephan Müller
2017-07-31 12:09 ` [PATCH 13/16] crypto: AF_ALG - consolidate sendmsg implementation Stephan Müller
2017-07-31 12:10 ` [PATCH 14/16] crypto: AF_ALG - consolidate sendpage implementation Stephan Müller
2017-07-31 12:10 ` [PATCH 15/16] crypto: AF_ALG - consolidate AIO callback handler Stephan Müller
2017-07-31 12:11 ` Stephan Müller [this message]
2017-08-01  8:58 ` [PATCH 00/16] crypto: AF_ALG - consolidation Herbert Xu
2017-08-01  9:01   ` Stephan Müller
2017-08-01  9:08     ` Herbert Xu
2017-08-01  9:15       ` Stephan Müller
2017-08-01  9:18         ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4962248.kL35ls7QWF@positron.chronox.de \
    --to=smueller@chronox.de \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.