]> Pileus Git - ~andy/linux/commitdiff
tipc: allow implicit connect for stream sockets
authorErik Hugne <erik.hugne@ericsson.com>
Mon, 17 Jun 2013 14:54:38 +0000 (10:54 -0400)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Jun 2013 22:53:00 +0000 (15:53 -0700)
TIPC's implied connect feature, aka piggyback connect, allows
applications to save one syscall and all SYN/SYN-ACK signalling
overhead when setting up a connection.  Until now, this has only
been supported for SEQPACKET sockets.  Here, we make it possible
to use this feature even with stream sockets.

At the connecting side, the connection is completed when the
first data message arrives from the accepting peer.  This means
that we must allow the connecting user to call blocking recv()
before the socket has reached state SS_CONNECTED.  So we must must
relax the state machine check at recv_stream(), and allow the
recv() call even if socket is in state SS_CONNECTING.

Signed-off-by: Erik Hugne <erik.hugne@ericsson.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c

index aba4255f297becbf1f3ef73043d507eb4d1c7861..d5fa708f037d239111dbbc329b6e6f5f94ef3092 100644 (file)
@@ -518,8 +518,7 @@ static int send_msg(struct kiocb *iocb, struct socket *sock,
                        res = -EISCONN;
                        goto exit;
                }
-               if ((tport->published) ||
-                   ((sock->type == SOCK_STREAM) && (total_len != 0))) {
+               if (tport->published) {
                        res = -EOPNOTSUPP;
                        goto exit;
                }
@@ -1010,8 +1009,7 @@ static int recv_stream(struct kiocb *iocb, struct socket *sock,
 
        lock_sock(sk);
 
-       if (unlikely((sock->state == SS_UNCONNECTED) ||
-                    (sock->state == SS_CONNECTING))) {
+       if (unlikely((sock->state == SS_UNCONNECTED))) {
                res = -ENOTCONN;
                goto exit;
        }