TIPC_ESTABLISHED = TCP_ESTABLISHED,
TIPC_OPEN = TCP_CLOSE,
TIPC_DISCONNECTING = TCP_CLOSE_WAIT,
+ TIPC_CONNECTING = TCP_SYN_SENT,
};
/**
*/
static int tipc_set_sk_state(struct sock *sk, int state)
{
- int oldstate = sk->sk_socket->state;
int oldsk_state = sk->sk_state;
int res = -EINVAL;
res = 0;
break;
case TIPC_LISTEN:
+ case TIPC_CONNECTING:
if (oldsk_state == TIPC_OPEN)
res = 0;
break;
case TIPC_ESTABLISHED:
- if (oldstate == SS_CONNECTING ||
+ if (oldsk_state == TIPC_CONNECTING ||
oldsk_state == TIPC_OPEN)
res = 0;
break;
case TIPC_DISCONNECTING:
- if (oldstate == SS_CONNECTING ||
+ if (oldsk_state == TIPC_CONNECTING ||
oldsk_state == TIPC_ESTABLISHED)
res = 0;
break;
if (sk->sk_shutdown == SHUTDOWN_MASK)
mask |= POLLHUP;
- switch ((int)sock->state) {
- case SS_CONNECTED:
+ if ((int)sock->state == SS_CONNECTED) {
if (!tsk->link_cong && !tsk_conn_cong(tsk))
mask |= POLLOUT;
- /* fall thru' */
- case SS_CONNECTING:
if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= (POLLIN | POLLRDNORM);
- break;
- default:
+ } else {
switch (sk->sk_state) {
case TIPC_OPEN:
if (!tsk->link_cong)
mask = (POLLIN | POLLRDNORM | POLLHUP);
break;
case TIPC_LISTEN:
+ case TIPC_CONNECTING:
if (!skb_queue_empty(&sk->sk_receive_queue))
mask |= (POLLIN | POLLRDNORM);
break;
rc = tipc_node_xmit(net, &pktchain, dnode, tsk->portid);
if (likely(!rc)) {
if (!is_connectionless)
- sock->state = SS_CONNECTING;
+ tipc_set_sk_state(sk, TIPC_CONNECTING);
return dsz;
}
if (rc == -ELINKCONG) {
sk->sk_state_change(sk);
}
return true;
+ }
- case SS_CONNECTING:
-
+ switch (sk->sk_state) {
+ case TIPC_CONNECTING:
/* Accept only ACK or NACK message */
if (unlikely(!msg_connected(hdr)))
return false;
/* 'ACK-' message is neither accepted nor rejected: */
msg_set_dest_droppable(hdr, 1);
return false;
- }
- switch (sk->sk_state) {
case TIPC_OPEN:
case TIPC_DISCONNECTING:
break;
return sock_intr_errno(*timeo_p);
prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
- done = sk_wait_event(sk, timeo_p, sock->state != SS_CONNECTING);
+ done = sk_wait_event(sk, timeo_p,
+ sk->sk_state != TIPC_CONNECTING);
finish_wait(sk_sleep(sk), &wait);
} while (!done);
return 0;
struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest;
struct msghdr m = {NULL,};
long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout;
- socket_state previous;
+ int previous;
int res = 0;
lock_sock(sk);
goto exit;
}
- previous = sock->state;
+ previous = sk->sk_state;
switch (sk->sk_state) {
case TIPC_OPEN:
if ((res < 0) && (res != -EWOULDBLOCK))
goto exit;
- /* Just entered SS_CONNECTING state; the only
+ /* Just entered TIPC_CONNECTING state; the only
* difference is that return value in non-blocking
* case is EINPROGRESS, rather than EALREADY.
*/
res = -EINPROGRESS;
- break;
- }
-
- switch (sock->state) {
- case SS_CONNECTING:
- if (previous == SS_CONNECTING)
- res = -EALREADY;
- if (!timeout)
+ /* fall thru' */
+ case TIPC_CONNECTING:
+ if (!timeout) {
+ if (previous == TIPC_CONNECTING)
+ res = -EALREADY;
goto exit;
+ }
timeout = msecs_to_jiffies(timeout);
/* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */
res = tipc_wait_for_connect(sock, &timeout);
- break;
- case SS_CONNECTED:
+ goto exit;
+ }
+
+ if (sock->state == SS_CONNECTED)
res = -EISCONN;
- break;
- default:
+ else
res = -EINVAL;
- break;
- }
+
exit:
release_sock(sk);
return res;