tipc: fix implicit-connect for SYN+
authorXin Long <lucien.xin@gmail.com>
Thu, 22 Jul 2021 16:05:41 +0000 (12:05 -0400)
committerDavid S. Miller <davem@davemloft.net>
Fri, 23 Jul 2021 15:33:54 +0000 (16:33 +0100)
commitf8dd60de194817c86bf812700980762bb5a8d9a4
tree35fec37c686069290b6abcb65d8815d46fa86483
parentd72e91efcae12f2f24ced984d00d60517c677857
tipc: fix implicit-connect for SYN+

For implicit-connect, when it's either SYN- or SYN+, an ACK should
be sent back to the client immediately. It's not appropriate for
the client to enter established state only after receiving data
from the server.

On client side, after the SYN is sent out, tipc_wait_for_connect()
should be called to wait for the ACK if timeout is set.

This patch also restricts __tipc_sendstream() to call __sendmsg()
only when it's in TIPC_OPEN state, so that the client can program
in a single loop doing both connecting and data sending like:

  for (...)
      sendmsg(dest, buf);

This makes the implicit-connect more implicit.

Fixes: b97bf3fd8f6a ("[TIPC] Initial merge")
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Acked-by: Jon Maloy <jmaloy@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c