tipc: remove tsk->connected for connectionless sockets
authorParthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Tue, 1 Nov 2016 13:02:39 +0000 (14:02 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Nov 2016 15:53:24 +0000 (11:53 -0400)
Until now, for connectionless sockets the peer information during
connect is stored in tsk->peer and a connection state is set in
tsk->connected. This is redundant.

In this commit, for connectionless sockets we update:
- __tipc_sendmsg(), when the destination is NULL the peer existence
  is determined by tsk->peer.family, instead of tsk->connected.
- tipc_connect(), remove set/unset of tsk->connected.
Hence tsk->connected is no longer used for connectionless sockets.

There is no functional change in this commit.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Parthasarathy Bhuvaragan <parthasarathy.bhuvaragan@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c

index 0546556d351743fcb7ff314cb9f0f29a670743da..524abe47560d7063806e43bec141beaa47d2ccce 100644 (file)
@@ -902,7 +902,7 @@ static int __tipc_sendmsg(struct socket *sock, struct msghdr *m, size_t dsz)
        if (dsz > TIPC_MAX_USER_MSG_SIZE)
                return -EMSGSIZE;
        if (unlikely(!dest)) {
-               if (tsk->connected && sock->state == SS_READY)
+               if (sock->state == SS_READY && tsk->peer.family == AF_TIPC)
                        dest = &tsk->peer;
                else
                        return -EDESTADDRREQ;
@@ -1939,12 +1939,10 @@ static int tipc_connect(struct socket *sock, struct sockaddr *dest,
        if (sock->state == SS_READY) {
                if (dst->family == AF_UNSPEC) {
                        memset(&tsk->peer, 0, sizeof(struct sockaddr_tipc));
-                       tsk->connected = 0;
                } else if (destlen != sizeof(struct sockaddr_tipc)) {
                        res = -EINVAL;
                } else {
                        memcpy(&tsk->peer, dest, destlen);
-                       tsk->connected = 1;
                }
                goto exit;
        }