Thread (3 messages) flat view 3 messages, 3 authors, 2016-06-09

Re: [PATCHv3 net-next] sctp: sctp should change socket state when shutdown is received

From: Sergei Shtylyov <hidden>
Date: 2016-06-09 13:42:50
Also in: linux-sctp

Hello.

On 6/9/2016 2:22 PM, Xin Long wrote:
Now sctp doesn't change socket state upon shutdown reception. It changes
just the assoc state, even though it's a TCP-style socket.

For some cases, if we really need to check sk->sk_state, it's necessary to
fix this issue, at least when we use ss or netstat to dump, we can get a
more exact information.

As an improvement, we will change sk->sk_state when we change asoc->state
to SHUTDOWN_RECEIVED, and also do it in sctp_shutdown to keep consistent with
sctp_close.

Signed-off-by: Xin Long <lucien.xin@gmail.com>
[...]
quoted hunk ↗ jump to hunk
diff --git a/net/sctp/socket.c b/net/sctp/socket.c
index 67154b8..80d860a 100644
--- a/net/sctp/socket.c
+++ b/net/sctp/socket.c
[...]
quoted hunk ↗ jump to hunk
@@ -7564,10 +7565,12 @@ static void sctp_sock_migrate(struct sock *oldsk, struct sock *newsk,
 	/* If the association on the newsk is already closed before accept()
 	 * is called, set RCV_SHUTDOWN flag.
 	 */
-	if (sctp_state(assoc, CLOSED) && sctp_style(newsk, TCP))
+	if (sctp_state(assoc, CLOSED) && sctp_style(newsk, TCP)) {
+		newsk->sk_state = SCTP_SS_CLOSING;
 		newsk->sk_shutdown |= RCV_SHUTDOWN;
+	} else
+		newsk->sk_state = SCTP_SS_ESTABLISHED;
    CodingStyle: all arms of the *if* statment should use {} if at least one 
arm uses {}.

MBR, Sergei
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help