When initiating a connection message under link congestion,
function __tipc_sendmsg() is used to send the connection message to
a listening socket. Function tipc_wait_for_cond() is called to wait
until the link is not congested. However, it calls tipc_sk_sock_err()
for sanity check and this function returns -ENOTCONN immediately
because the socket state is not ESTABLISHED.
This commit fixes this issue by moving the sanity check for
connection-oriented socket from tipc_sk_sock_err() to
__tipc_sendstream().
Fixes: 8c44e1af16b2 ("tipc: unify tipc_wait_for_sndpkt() and
tipc_wait_for_sndmsg() functions)
Signed-off-by: Tung Nguyen <[email protected]>
---
net/tipc/socket.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index 9fd9a5727786..0ce441fd126c 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -363,12 +363,9 @@ static int tipc_sk_sock_err(struct socket *sock, long
*timeout)
if (err)
return err;
- if (typ == SOCK_STREAM || typ == SOCK_SEQPACKET) {
- if (sk->sk_state == TIPC_DISCONNECTING)
- return -EPIPE;
- else if (!tipc_sk_connected(sk))
- return -ENOTCONN;
- }
+ if ((typ == SOCK_STREAM || typ == SOCK_SEQPACKET) &&
+ (sk->sk_state == TIPC_DISCONNECTING))
+ return -EPIPE;
if (!*timeout)
return -EAGAIN;
if (signal_pending(current))
@@ -1462,6 +1459,13 @@ static int __tipc_sendstream(struct socket *sock, struct
msghdr *m, size_t dlen)
return rc;
}
+ if (!tipc_sk_connected(sk)) {
+ if (sk->sk_state == TIPC_DISCONNECTING)
+ return -EPIPE;
+ else
+ return -ENOTCONN;
+ }
+
do {
rc = tipc_wait_for_cond(sock, &timeout,
(!tsk->cong_link_cnt &&
--
2.17.1
_______________________________________________
tipc-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tipc-discussion