mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-04 20:19:47 +08:00
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>
This commit is contained in:
parent
8a856fdede
commit
55612ddb62
@ -160,6 +160,7 @@ struct dlm_proto_ops {
|
|||||||
bool try_new_addr;
|
bool try_new_addr;
|
||||||
const char *name;
|
const char *name;
|
||||||
int proto;
|
int proto;
|
||||||
|
int how;
|
||||||
|
|
||||||
void (*sockopts)(struct socket *sock);
|
void (*sockopts)(struct socket *sock);
|
||||||
int (*bind)(struct socket *sock);
|
int (*bind)(struct socket *sock);
|
||||||
@ -810,7 +811,7 @@ static void shutdown_connection(struct connection *con, bool and_other)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = kernel_sock_shutdown(con->sock, SHUT_WR);
|
ret = kernel_sock_shutdown(con->sock, dlm_proto_ops->how);
|
||||||
up_read(&con->sock_lock);
|
up_read(&con->sock_lock);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
log_print("Connection %p failed to shutdown: %d will force close",
|
log_print("Connection %p failed to shutdown: %d will force close",
|
||||||
@ -1858,6 +1859,7 @@ static int dlm_tcp_listen_bind(struct socket *sock)
|
|||||||
static const struct dlm_proto_ops dlm_tcp_ops = {
|
static const struct dlm_proto_ops dlm_tcp_ops = {
|
||||||
.name = "TCP",
|
.name = "TCP",
|
||||||
.proto = IPPROTO_TCP,
|
.proto = IPPROTO_TCP,
|
||||||
|
.how = SHUT_WR,
|
||||||
.sockopts = dlm_tcp_sockopts,
|
.sockopts = dlm_tcp_sockopts,
|
||||||
.bind = dlm_tcp_bind,
|
.bind = dlm_tcp_bind,
|
||||||
.listen_validate = dlm_tcp_listen_validate,
|
.listen_validate = dlm_tcp_listen_validate,
|
||||||
@ -1896,6 +1898,7 @@ static void dlm_sctp_sockopts(struct socket *sock)
|
|||||||
static const struct dlm_proto_ops dlm_sctp_ops = {
|
static const struct dlm_proto_ops dlm_sctp_ops = {
|
||||||
.name = "SCTP",
|
.name = "SCTP",
|
||||||
.proto = IPPROTO_SCTP,
|
.proto = IPPROTO_SCTP,
|
||||||
|
.how = SHUT_RDWR,
|
||||||
.try_new_addr = true,
|
.try_new_addr = true,
|
||||||
.sockopts = dlm_sctp_sockopts,
|
.sockopts = dlm_sctp_sockopts,
|
||||||
.bind = dlm_sctp_bind,
|
.bind = dlm_sctp_bind,
|
||||||
|
Loading…
Reference in New Issue
Block a user