From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: "Jere Leppänen" <jere.leppanen@nokia.com>
Cc: linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
Vlad Yasevich <vyasevich@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
"David S . Miller" <davem@davemloft.net>,
David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket
Date: Wed, 20 May 2020 19:46:29 +0000 [thread overview]
Message-ID: <20200520194629.GS2491@localhost.localdomain> (raw)
In-Reply-To: <20200520151531.787414-1-jere.leppanen@nokia.com>
On Wed, May 20, 2020 at 06:15:31PM +0300, Jere Leppänen wrote:
> Commit bdf6fa52f01b ("sctp: handle association restarts when the
> socket is closed.") starts shutdown when an association is restarted,
> if in SHUTDOWN-PENDING state and the socket is closed. However, the
> rationale stated in that commit applies also when in SHUTDOWN-SENT
> state - we don't want to move an association to ESTABLISHED state when
> the socket has been closed, because that results in an association
> that is unreachable from user space.
>
> The problem scenario:
>
> 1. Client crashes and/or restarts.
>
> 2. Server (using one-to-one socket) calls close(). SHUTDOWN is lost.
>
> 3. Client reconnects using the same addresses and ports.
>
> 4. Server's association is restarted. The association and the socket
> move to ESTABLISHED state, even though the server process has
> closed its descriptor.
>
> Also, after step 4 when the server process exits, some resources are
> leaked in an attempt to release the underlying inet sock structure in
> ESTABLISHED state:
>
> IPv4: Attempt to release TCP socket in state 1 00000000377288c7
>
> Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
> an association is restarted in SHUTDOWN-SENT state and the socket is
> closed, then start shutdown and don't move the association or the
> socket to ESTABLISHED state.
>
> Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is closed.")
> Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
> ---
> net/sctp/sm_statefuns.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 26788f4a3b9e..e86620fbd90f 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1856,12 +1856,13 @@ static enum sctp_disposition sctp_sf_do_dupcook_a(
> /* Update the content of current association. */
> sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
> sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
> - if (sctp_state(asoc, SHUTDOWN_PENDING) &&
> + if ((sctp_state(asoc, SHUTDOWN_PENDING) ||
> + sctp_state(asoc, SHUTDOWN_SENT)) &&
> (sctp_sstate(asoc->base.sk, CLOSING) ||
> sock_flag(asoc->base.sk, SOCK_DEAD))) {
> - /* if were currently in SHUTDOWN_PENDING, but the socket
> - * has been closed by user, don't transition to ESTABLISHED.
> - * Instead trigger SHUTDOWN bundled with COOKIE_ACK.
> + /* If the socket has been closed by user, don't
> + * transition to ESTABLISHED. Instead trigger SHUTDOWN
> + * bundled with COOKIE_ACK.
> */
> sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
> return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,
>
> base-commit: 20a785aa52c82246055a089e55df9dac47d67da1
This last line is not standard, but git didn't complain about it here.
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
WARNING: multiple messages have this Message-ID (diff)
From: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
To: "Jere Leppänen" <jere.leppanen@nokia.com>
Cc: linux-sctp@vger.kernel.org, netdev@vger.kernel.org,
Vlad Yasevich <vyasevich@gmail.com>,
Neil Horman <nhorman@tuxdriver.com>,
"David S . Miller" <davem@davemloft.net>,
David Laight <David.Laight@aculab.com>
Subject: Re: [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed
Date: Wed, 20 May 2020 16:46:29 -0300 [thread overview]
Message-ID: <20200520194629.GS2491@localhost.localdomain> (raw)
In-Reply-To: <20200520151531.787414-1-jere.leppanen@nokia.com>
On Wed, May 20, 2020 at 06:15:31PM +0300, Jere Leppänen wrote:
> Commit bdf6fa52f01b ("sctp: handle association restarts when the
> socket is closed.") starts shutdown when an association is restarted,
> if in SHUTDOWN-PENDING state and the socket is closed. However, the
> rationale stated in that commit applies also when in SHUTDOWN-SENT
> state - we don't want to move an association to ESTABLISHED state when
> the socket has been closed, because that results in an association
> that is unreachable from user space.
>
> The problem scenario:
>
> 1. Client crashes and/or restarts.
>
> 2. Server (using one-to-one socket) calls close(). SHUTDOWN is lost.
>
> 3. Client reconnects using the same addresses and ports.
>
> 4. Server's association is restarted. The association and the socket
> move to ESTABLISHED state, even though the server process has
> closed its descriptor.
>
> Also, after step 4 when the server process exits, some resources are
> leaked in an attempt to release the underlying inet sock structure in
> ESTABLISHED state:
>
> IPv4: Attempt to release TCP socket in state 1 00000000377288c7
>
> Fix by acting the same way as in SHUTDOWN-PENDING state. That is, if
> an association is restarted in SHUTDOWN-SENT state and the socket is
> closed, then start shutdown and don't move the association or the
> socket to ESTABLISHED state.
>
> Fixes: bdf6fa52f01b ("sctp: handle association restarts when the socket is closed.")
> Signed-off-by: Jere Leppänen <jere.leppanen@nokia.com>
> ---
> net/sctp/sm_statefuns.c | 9 +++++----
> 1 file changed, 5 insertions(+), 4 deletions(-)
>
> diff --git a/net/sctp/sm_statefuns.c b/net/sctp/sm_statefuns.c
> index 26788f4a3b9e..e86620fbd90f 100644
> --- a/net/sctp/sm_statefuns.c
> +++ b/net/sctp/sm_statefuns.c
> @@ -1856,12 +1856,13 @@ static enum sctp_disposition sctp_sf_do_dupcook_a(
> /* Update the content of current association. */
> sctp_add_cmd_sf(commands, SCTP_CMD_UPDATE_ASSOC, SCTP_ASOC(new_asoc));
> sctp_add_cmd_sf(commands, SCTP_CMD_EVENT_ULP, SCTP_ULPEVENT(ev));
> - if (sctp_state(asoc, SHUTDOWN_PENDING) &&
> + if ((sctp_state(asoc, SHUTDOWN_PENDING) ||
> + sctp_state(asoc, SHUTDOWN_SENT)) &&
> (sctp_sstate(asoc->base.sk, CLOSING) ||
> sock_flag(asoc->base.sk, SOCK_DEAD))) {
> - /* if were currently in SHUTDOWN_PENDING, but the socket
> - * has been closed by user, don't transition to ESTABLISHED.
> - * Instead trigger SHUTDOWN bundled with COOKIE_ACK.
> + /* If the socket has been closed by user, don't
> + * transition to ESTABLISHED. Instead trigger SHUTDOWN
> + * bundled with COOKIE_ACK.
> */
> sctp_add_cmd_sf(commands, SCTP_CMD_REPLY, SCTP_CHUNK(repl));
> return sctp_sf_do_9_2_start_shutdown(net, ep, asoc,
>
> base-commit: 20a785aa52c82246055a089e55df9dac47d67da1
This last line is not standard, but git didn't complain about it here.
Acked-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
next prev parent reply other threads:[~2020-05-20 19:46 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-05-20 15:15 [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is Jere Leppänen
2020-05-20 15:15 ` [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed Jere Leppänen
2020-05-20 19:46 ` Marcelo Ricardo Leitner [this message]
2020-05-20 19:46 ` Marcelo Ricardo Leitner
2020-05-20 21:50 ` [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket Jere Leppänen
2020-05-20 21:50 ` [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed Jere Leppänen
2020-05-22 22:48 ` [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket David Miller
2020-05-22 22:48 ` [PATCH net 1/1] sctp: Start shutdown on association restart if in SHUTDOWN-SENT state and socket is closed David Miller
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=20200520194629.GS2491@localhost.localdomain \
--to=marcelo.leitner@gmail.com \
--cc=David.Laight@aculab.com \
--cc=davem@davemloft.net \
--cc=jere.leppanen@nokia.com \
--cc=linux-sctp@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=nhorman@tuxdriver.com \
--cc=vyasevich@gmail.com \
/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.