Skip to content

Commit 55612dd

Browse files
Alexander Aringteigland
authored andcommitted
dlm: use SHUT_RDWR for SCTP shutdown
Currently SCTP shutdown() call gets stuck because there is no incoming EOF indicator on its socket. On the peer side the EOF indicator as recvmsg() returns 0 will be triggered as mechanism to flush the socket queue on the receive side. In SCTP recvmsg() function sctp_recvmsg() we can see that only if sk_shutdown has the bit RCV_SHUTDOWN set SCTP will recvmsg() will return EOF. The RCV_SHUTDOWN bit will only be set when shutdown with SHUT_RD is called. We use now SHUT_RDWR to also get a EOF indicator from recvmsg() call on the shutdown() initiator. SCTP does not support half closed sockets and the semantic of SHUT_WR is different here, it seems that calling SHUT_WR on sctp sockets keeps the socket open to have the possibility to do some specific SCTP operations on it that we don't do here. There exists still a difference in the limitations of TCP vs SCTP in case if we are required to have a half closed socket functionality. This was tried to archieve with DLM protocol changes in the past and hopefully we really don't require half closed socket functionality. Signed-off-by: Alexander Aring <aahringo@redhat.com> Tested-by: Heming zhao <heming.zhao@suse.com> Reviewed-by: Heming zhao <heming.zhao@suse.com> Signed-off-by: David Teigland <teigland@redhat.com>
1 parent 8a856fd commit 55612dd

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

fs/dlm/lowcomms.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct dlm_proto_ops {
160160
bool try_new_addr;
161161
const char *name;
162162
int proto;
163+
int how;
163164

164165
void (*sockopts)(struct socket *sock);
165166
int (*bind)(struct socket *sock);
@@ -810,7 +811,7 @@ static void shutdown_connection(struct connection *con, bool and_other)
810811
return;
811812
}
812813

813-
ret = kernel_sock_shutdown(con->sock, SHUT_WR);
814+
ret = kernel_sock_shutdown(con->sock, dlm_proto_ops->how);
814815
up_read(&con->sock_lock);
815816
if (ret) {
816817
log_print("Connection %p failed to shutdown: %d will force close",
@@ -1858,6 +1859,7 @@ static int dlm_tcp_listen_bind(struct socket *sock)
18581859
static const struct dlm_proto_ops dlm_tcp_ops = {
18591860
.name = "TCP",
18601861
.proto = IPPROTO_TCP,
1862+
.how = SHUT_WR,
18611863
.sockopts = dlm_tcp_sockopts,
18621864
.bind = dlm_tcp_bind,
18631865
.listen_validate = dlm_tcp_listen_validate,
@@ -1896,6 +1898,7 @@ static void dlm_sctp_sockopts(struct socket *sock)
18961898
static const struct dlm_proto_ops dlm_sctp_ops = {
18971899
.name = "SCTP",
18981900
.proto = IPPROTO_SCTP,
1901+
.how = SHUT_RDWR,
18991902
.try_new_addr = true,
19001903
.sockopts = dlm_sctp_sockopts,
19011904
.bind = dlm_sctp_bind,

0 commit comments

Comments
 (0)