aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc
diff options
context:
space:
mode:
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>2016-11-01 09:02:48 -0400
committerDavid S. Miller <davem@davemloft.net>2016-11-01 11:53:26 -0400
commit99a20889816a653e192db23701b0fda00399b91f (patch)
tree5a00a77bc0ac71427e8271987acb496261e7e1d8 /net/tipc
parent6f00089c7372ba9732c046fe242301dfb0a13233 (diff)
tipc: create TIPC_CONNECTING as a new sk_state
In this commit, we create a new tipc socket state TIPC_CONNECTING by primarily replacing the SS_CONNECTING with TIPC_CONNECTING. There is no functional change in this commit. Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc')
-rw-r--r--net/tipc/socket.c60
1 files changed, 28 insertions, 32 deletions
diff --git a/net/tipc/socket.c b/net/tipc/socket.c
index e732b1fe7eab..074f4d546828 100644
--- a/net/tipc/socket.c
+++ b/net/tipc/socket.c
@@ -55,6 +55,7 @@ enum {
55 TIPC_ESTABLISHED = TCP_ESTABLISHED, 55 TIPC_ESTABLISHED = TCP_ESTABLISHED,
56 TIPC_OPEN = TCP_CLOSE, 56 TIPC_OPEN = TCP_CLOSE,
57 TIPC_DISCONNECTING = TCP_CLOSE_WAIT, 57 TIPC_DISCONNECTING = TCP_CLOSE_WAIT,
58 TIPC_CONNECTING = TCP_SYN_SENT,
58}; 59};
59 60
60/** 61/**
@@ -349,7 +350,6 @@ static bool tsk_peer_msg(struct tipc_sock *tsk, struct tipc_msg *msg)
349 */ 350 */
350static int tipc_set_sk_state(struct sock *sk, int state) 351static int tipc_set_sk_state(struct sock *sk, int state)
351{ 352{
352 int oldstate = sk->sk_socket->state;
353 int oldsk_state = sk->sk_state; 353 int oldsk_state = sk->sk_state;
354 int res = -EINVAL; 354 int res = -EINVAL;
355 355
@@ -358,16 +358,17 @@ static int tipc_set_sk_state(struct sock *sk, int state)
358 res = 0; 358 res = 0;
359 break; 359 break;
360 case TIPC_LISTEN: 360 case TIPC_LISTEN:
361 case TIPC_CONNECTING:
361 if (oldsk_state == TIPC_OPEN) 362 if (oldsk_state == TIPC_OPEN)
362 res = 0; 363 res = 0;
363 break; 364 break;
364 case TIPC_ESTABLISHED: 365 case TIPC_ESTABLISHED:
365 if (oldstate == SS_CONNECTING || 366 if (oldsk_state == TIPC_CONNECTING ||
366 oldsk_state == TIPC_OPEN) 367 oldsk_state == TIPC_OPEN)
367 res = 0; 368 res = 0;
368 break; 369 break;
369 case TIPC_DISCONNECTING: 370 case TIPC_DISCONNECTING:
370 if (oldstate == SS_CONNECTING || 371 if (oldsk_state == TIPC_CONNECTING ||
371 oldsk_state == TIPC_ESTABLISHED) 372 oldsk_state == TIPC_ESTABLISHED)
372 res = 0; 373 res = 0;
373 break; 374 break;
@@ -689,16 +690,12 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
689 if (sk->sk_shutdown == SHUTDOWN_MASK) 690 if (sk->sk_shutdown == SHUTDOWN_MASK)
690 mask |= POLLHUP; 691 mask |= POLLHUP;
691 692
692 switch ((int)sock->state) { 693 if ((int)sock->state == SS_CONNECTED) {
693 case SS_CONNECTED:
694 if (!tsk->link_cong && !tsk_conn_cong(tsk)) 694 if (!tsk->link_cong && !tsk_conn_cong(tsk))
695 mask |= POLLOUT; 695 mask |= POLLOUT;
696 /* fall thru' */
697 case SS_CONNECTING:
698 if (!skb_queue_empty(&sk->sk_receive_queue)) 696 if (!skb_queue_empty(&sk->sk_receive_queue))
699 mask |= (POLLIN | POLLRDNORM); 697 mask |= (POLLIN | POLLRDNORM);
700 break; 698 } else {
701 default:
702 switch (sk->sk_state) { 699 switch (sk->sk_state) {
703 case TIPC_OPEN: 700 case TIPC_OPEN:
704 if (!tsk->link_cong) 701 if (!tsk->link_cong)
@@ -711,6 +708,7 @@ static unsigned int tipc_poll(struct file *file, struct socket *sock,
711 mask = (POLLIN | POLLRDNORM | POLLHUP); 708 mask = (POLLIN | POLLRDNORM | POLLHUP);
712 break; 709 break;
713 case TIPC_LISTEN: 710 case TIPC_LISTEN:
711 case TIPC_CONNECTING:
714 if (!skb_queue_empty(&sk->sk_receive_queue)) 712 if (!skb_queue_empty(&sk->sk_receive_queue))
715 mask |= (POLLIN | POLLRDNORM); 713 mask |= (POLLIN | POLLRDNORM);
716 break; 714 break;
@@ -1014,7 +1012,7 @@ new_mtu:
1014 rc = tipc_node_xmit(net, &pktchain, dnode, tsk->portid); 1012 rc = tipc_node_xmit(net, &pktchain, dnode, tsk->portid);
1015 if (likely(!rc)) { 1013 if (likely(!rc)) {
1016 if (!is_connectionless) 1014 if (!is_connectionless)
1017 sock->state = SS_CONNECTING; 1015 tipc_set_sk_state(sk, TIPC_CONNECTING);
1018 return dsz; 1016 return dsz;
1019 } 1017 }
1020 if (rc == -ELINKCONG) { 1018 if (rc == -ELINKCONG) {
@@ -1650,9 +1648,10 @@ static bool filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
1650 sk->sk_state_change(sk); 1648 sk->sk_state_change(sk);
1651 } 1649 }
1652 return true; 1650 return true;
1651 }
1653 1652
1654 case SS_CONNECTING: 1653 switch (sk->sk_state) {
1655 1654 case TIPC_CONNECTING:
1656 /* Accept only ACK or NACK message */ 1655 /* Accept only ACK or NACK message */
1657 if (unlikely(!msg_connected(hdr))) 1656 if (unlikely(!msg_connected(hdr)))
1658 return false; 1657 return false;
@@ -1684,9 +1683,7 @@ static bool filter_connect(struct tipc_sock *tsk, struct sk_buff *skb)
1684 /* 'ACK-' message is neither accepted nor rejected: */ 1683 /* 'ACK-' message is neither accepted nor rejected: */
1685 msg_set_dest_droppable(hdr, 1); 1684 msg_set_dest_droppable(hdr, 1);
1686 return false; 1685 return false;
1687 }
1688 1686
1689 switch (sk->sk_state) {
1690 case TIPC_OPEN: 1687 case TIPC_OPEN:
1691 case TIPC_DISCONNECTING: 1688 case TIPC_DISCONNECTING:
1692 break; 1689 break;
@@ -1955,7 +1952,8 @@ static int tipc_wait_for_connect(struct socket *sock, long *timeo_p)
1955 return sock_intr_errno(*timeo_p); 1952 return sock_intr_errno(*timeo_p);
1956 1953
1957 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE); 1954 prepare_to_wait(sk_sleep(sk), &wait, TASK_INTERRUPTIBLE);
1958 done = sk_wait_event(sk, timeo_p, sock->state != SS_CONNECTING); 1955 done = sk_wait_event(sk, timeo_p,
1956 sk->sk_state != TIPC_CONNECTING);
1959 finish_wait(sk_sleep(sk), &wait); 1957 finish_wait(sk_sleep(sk), &wait);
1960 } while (!done); 1958 } while (!done);
1961 return 0; 1959 return 0;
@@ -1978,7 +1976,7 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
1978 struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest; 1976 struct sockaddr_tipc *dst = (struct sockaddr_tipc *)dest;
1979 struct msghdr m = {NULL,}; 1977 struct msghdr m = {NULL,};
1980 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout; 1978 long timeout = (flags & O_NONBLOCK) ? 0 : tsk->conn_timeout;
1981 socket_state previous; 1979 int previous;
1982 int res = 0; 1980 int res = 0;
1983 1981
1984 lock_sock(sk); 1982 lock_sock(sk);
@@ -2006,7 +2004,7 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
2006 goto exit; 2004 goto exit;
2007 } 2005 }
2008 2006
2009 previous = sock->state; 2007 previous = sk->sk_state;
2010 2008
2011 switch (sk->sk_state) { 2009 switch (sk->sk_state) {
2012 case TIPC_OPEN: 2010 case TIPC_OPEN:
@@ -2024,31 +2022,29 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
2024 if ((res < 0) && (res != -EWOULDBLOCK)) 2022 if ((res < 0) && (res != -EWOULDBLOCK))
2025 goto exit; 2023 goto exit;
2026 2024
2027 /* Just entered SS_CONNECTING state; the only 2025 /* Just entered TIPC_CONNECTING state; the only
2028 * difference is that return value in non-blocking 2026 * difference is that return value in non-blocking
2029 * case is EINPROGRESS, rather than EALREADY. 2027 * case is EINPROGRESS, rather than EALREADY.
2030 */ 2028 */
2031 res = -EINPROGRESS; 2029 res = -EINPROGRESS;
2032 break; 2030 /* fall thru' */
2033 } 2031 case TIPC_CONNECTING:
2034 2032 if (!timeout) {
2035 switch (sock->state) { 2033 if (previous == TIPC_CONNECTING)
2036 case SS_CONNECTING: 2034 res = -EALREADY;
2037 if (previous == SS_CONNECTING)
2038 res = -EALREADY;
2039 if (!timeout)
2040 goto exit; 2035 goto exit;
2036 }
2041 timeout = msecs_to_jiffies(timeout); 2037 timeout = msecs_to_jiffies(timeout);
2042 /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */ 2038 /* Wait until an 'ACK' or 'RST' arrives, or a timeout occurs */
2043 res = tipc_wait_for_connect(sock, &timeout); 2039 res = tipc_wait_for_connect(sock, &timeout);
2044 break; 2040 goto exit;
2045 case SS_CONNECTED: 2041 }
2042
2043 if (sock->state == SS_CONNECTED)
2046 res = -EISCONN; 2044 res = -EISCONN;
2047 break; 2045 else
2048 default:
2049 res = -EINVAL; 2046 res = -EINVAL;
2050 break; 2047
2051 }
2052exit: 2048exit:
2053 release_sock(sk); 2049 release_sock(sk);
2054 return res; 2050 return res;