* [PATCH] net/smc: common release code for non-accepted sockets
@ 2019-06-27 13:04 Karsten Graul
2019-06-27 13:16 ` Karsten Graul
2019-06-27 17:03 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Karsten Graul @ 2019-06-27 13:04 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, gor, heiko.carstens, raspl, ubraun
From: Ursula Braun <ubraun@linux.ibm.com>
There are common steps when releasing an accepted or unaccepted socket.
Move this code into a common routine.
Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
---
net/smc/af_smc.c | 73 +++++++++++++++++++++---------------------------
1 file changed, 32 insertions(+), 41 deletions(-)
diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
index 7621ec2f539c..302e355f2ebc 100644
--- a/net/smc/af_smc.c
+++ b/net/smc/af_smc.c
@@ -123,30 +123,11 @@ struct proto smc_proto6 = {
};
EXPORT_SYMBOL_GPL(smc_proto6);
-static int smc_release(struct socket *sock)
+static int __smc_release(struct smc_sock *smc)
{
- struct sock *sk = sock->sk;
- struct smc_sock *smc;
+ struct sock *sk = &smc->sk;
int rc = 0;
- if (!sk)
- goto out;
-
- smc = smc_sk(sk);
-
- /* cleanup for a dangling non-blocking connect */
- if (smc->connect_nonblock && sk->sk_state == SMC_INIT)
- tcp_abort(smc->clcsock->sk, ECONNABORTED);
- flush_work(&smc->connect_work);
-
- if (sk->sk_state == SMC_LISTEN)
- /* smc_close_non_accepted() is called and acquires
- * sock lock for child sockets again
- */
- lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
- else
- lock_sock(sk);
-
if (!smc->use_fallback) {
rc = smc_close_active(smc);
sock_set_flag(sk, SOCK_DEAD);
@@ -174,6 +155,35 @@ static int smc_release(struct socket *sock)
smc_conn_free(&smc->conn);
}
+ return rc;
+}
+
+static int smc_release(struct socket *sock)
+{
+ struct sock *sk = sock->sk;
+ struct smc_sock *smc;
+ int rc = 0;
+
+ if (!sk)
+ goto out;
+
+ smc = smc_sk(sk);
+
+ /* cleanup for a dangling non-blocking connect */
+ if (smc->connect_nonblock && sk->sk_state == SMC_INIT)
+ tcp_abort(smc->clcsock->sk, ECONNABORTED);
+ flush_work(&smc->connect_work);
+
+ if (sk->sk_state == SMC_LISTEN)
+ /* smc_close_non_accepted() is called and acquires
+ * sock lock for child sockets again
+ */
+ lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
+ else
+ lock_sock(sk);
+
+ rc = __smc_release(smc);
+
/* detach socket */
sock_orphan(sk);
sock->sk = NULL;
@@ -964,26 +974,7 @@ void smc_close_non_accepted(struct sock *sk)
if (!sk->sk_lingertime)
/* wait for peer closing */
sk->sk_lingertime = SMC_MAX_STREAM_WAIT_TIMEOUT;
- if (!smc->use_fallback) {
- smc_close_active(smc);
- sock_set_flag(sk, SOCK_DEAD);
- sk->sk_shutdown |= SHUTDOWN_MASK;
- }
- sk->sk_prot->unhash(sk);
- if (smc->clcsock) {
- struct socket *tcp;
-
- tcp = smc->clcsock;
- smc->clcsock = NULL;
- sock_release(tcp);
- }
- if (smc->use_fallback) {
- sock_put(sk); /* passive closing */
- sk->sk_state = SMC_CLOSED;
- } else {
- if (sk->sk_state == SMC_CLOSED)
- smc_conn_free(&smc->conn);
- }
+ __smc_release(smc);
release_sock(sk);
sock_put(sk); /* final sock_put */
}
--
2.21.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net/smc: common release code for non-accepted sockets
2019-06-27 13:04 [PATCH] net/smc: common release code for non-accepted sockets Karsten Graul
@ 2019-06-27 13:16 ` Karsten Graul
2019-06-27 17:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Karsten Graul @ 2019-06-27 13:16 UTC (permalink / raw)
To: davem; +Cc: netdev, linux-s390, gor, heiko.carstens, raspl, ubraun
Hi Dave,
I forgot to add that this patch is intended for the net-next tree.
On 27/06/2019 15:04, Karsten Graul wrote:
> From: Ursula Braun <ubraun@linux.ibm.com>
>
> There are common steps when releasing an accepted or unaccepted socket.
> Move this code into a common routine.
>
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
> ---
> net/smc/af_smc.c | 73 +++++++++++++++++++++---------------------------
> 1 file changed, 32 insertions(+), 41 deletions(-)
>
> diff --git a/net/smc/af_smc.c b/net/smc/af_smc.c
> index 7621ec2f539c..302e355f2ebc 100644
> --- a/net/smc/af_smc.c
> +++ b/net/smc/af_smc.c
> @@ -123,30 +123,11 @@ struct proto smc_proto6 = {
> };
> EXPORT_SYMBOL_GPL(smc_proto6);
>
> -static int smc_release(struct socket *sock)
> +static int __smc_release(struct smc_sock *smc)
> {
> - struct sock *sk = sock->sk;
> - struct smc_sock *smc;
> + struct sock *sk = &smc->sk;
> int rc = 0;
>
> - if (!sk)
> - goto out;
> -
> - smc = smc_sk(sk);
> -
> - /* cleanup for a dangling non-blocking connect */
> - if (smc->connect_nonblock && sk->sk_state == SMC_INIT)
> - tcp_abort(smc->clcsock->sk, ECONNABORTED);
> - flush_work(&smc->connect_work);
> -
> - if (sk->sk_state == SMC_LISTEN)
> - /* smc_close_non_accepted() is called and acquires
> - * sock lock for child sockets again
> - */
> - lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
> - else
> - lock_sock(sk);
> -
> if (!smc->use_fallback) {
> rc = smc_close_active(smc);
> sock_set_flag(sk, SOCK_DEAD);
> @@ -174,6 +155,35 @@ static int smc_release(struct socket *sock)
> smc_conn_free(&smc->conn);
> }
>
> + return rc;
> +}
> +
> +static int smc_release(struct socket *sock)
> +{
> + struct sock *sk = sock->sk;
> + struct smc_sock *smc;
> + int rc = 0;
> +
> + if (!sk)
> + goto out;
> +
> + smc = smc_sk(sk);
> +
> + /* cleanup for a dangling non-blocking connect */
> + if (smc->connect_nonblock && sk->sk_state == SMC_INIT)
> + tcp_abort(smc->clcsock->sk, ECONNABORTED);
> + flush_work(&smc->connect_work);
> +
> + if (sk->sk_state == SMC_LISTEN)
> + /* smc_close_non_accepted() is called and acquires
> + * sock lock for child sockets again
> + */
> + lock_sock_nested(sk, SINGLE_DEPTH_NESTING);
> + else
> + lock_sock(sk);
> +
> + rc = __smc_release(smc);
> +
> /* detach socket */
> sock_orphan(sk);
> sock->sk = NULL;
> @@ -964,26 +974,7 @@ void smc_close_non_accepted(struct sock *sk)
> if (!sk->sk_lingertime)
> /* wait for peer closing */
> sk->sk_lingertime = SMC_MAX_STREAM_WAIT_TIMEOUT;
> - if (!smc->use_fallback) {
> - smc_close_active(smc);
> - sock_set_flag(sk, SOCK_DEAD);
> - sk->sk_shutdown |= SHUTDOWN_MASK;
> - }
> - sk->sk_prot->unhash(sk);
> - if (smc->clcsock) {
> - struct socket *tcp;
> -
> - tcp = smc->clcsock;
> - smc->clcsock = NULL;
> - sock_release(tcp);
> - }
> - if (smc->use_fallback) {
> - sock_put(sk); /* passive closing */
> - sk->sk_state = SMC_CLOSED;
> - } else {
> - if (sk->sk_state == SMC_CLOSED)
> - smc_conn_free(&smc->conn);
> - }
> + __smc_release(smc);
> release_sock(sk);
> sock_put(sk); /* final sock_put */
> }
>
--
Karsten
(I'm a dude!)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net/smc: common release code for non-accepted sockets
2019-06-27 13:04 [PATCH] net/smc: common release code for non-accepted sockets Karsten Graul
2019-06-27 13:16 ` Karsten Graul
@ 2019-06-27 17:03 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-06-27 17:03 UTC (permalink / raw)
To: kgraul; +Cc: netdev, linux-s390, gor, heiko.carstens, raspl, ubraun
From: Karsten Graul <kgraul@linux.ibm.com>
Date: Thu, 27 Jun 2019 15:04:52 +0200
> From: Ursula Braun <ubraun@linux.ibm.com>
>
> There are common steps when releasing an accepted or unaccepted socket.
> Move this code into a common routine.
>
> Signed-off-by: Ursula Braun <ubraun@linux.ibm.com>
> Signed-off-by: Karsten Graul <kgraul@linux.ibm.com>
Applied.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-06-27 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-27 13:04 [PATCH] net/smc: common release code for non-accepted sockets Karsten Graul
2019-06-27 13:16 ` Karsten Graul
2019-06-27 17:03 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox