aboutsummaryrefslogtreecommitdiffstats
path: root/net/rds/tcp_connect.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/rds/tcp_connect.c')
-rw-r--r--net/rds/tcp_connect.c34
1 files changed, 20 insertions, 14 deletions
diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c
index d999e7075645..231ae927858e 100644
--- a/net/rds/tcp_connect.c
+++ b/net/rds/tcp_connect.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) 2006 Oracle. All rights reserved. 2 * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved.
3 * 3 *
4 * This software is available to you under a choice of one of two 4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU 5 * licenses. You may choose to be licensed under the terms of the GNU
@@ -66,7 +66,8 @@ void rds_tcp_state_change(struct sock *sk)
66 * RDS connection as RDS_CONN_UP until the reconnect, 66 * RDS connection as RDS_CONN_UP until the reconnect,
67 * to avoid RDS datagram loss. 67 * to avoid RDS datagram loss.
68 */ 68 */
69 if (!IS_CANONICAL(cp->cp_conn->c_laddr, cp->cp_conn->c_faddr) && 69 if (rds_addr_cmp(&cp->cp_conn->c_laddr,
70 &cp->cp_conn->c_faddr) >= 0 &&
70 rds_conn_path_transition(cp, RDS_CONN_CONNECTING, 71 rds_conn_path_transition(cp, RDS_CONN_CONNECTING,
71 RDS_CONN_ERROR)) { 72 RDS_CONN_ERROR)) {
72 rds_conn_path_drop(cp, false); 73 rds_conn_path_drop(cp, false);
@@ -88,7 +89,9 @@ out:
88int rds_tcp_conn_path_connect(struct rds_conn_path *cp) 89int rds_tcp_conn_path_connect(struct rds_conn_path *cp)
89{ 90{
90 struct socket *sock = NULL; 91 struct socket *sock = NULL;
91 struct sockaddr_in src, dest; 92 struct sockaddr_in sin;
93 struct sockaddr *addr;
94 int addrlen;
92 int ret; 95 int ret;
93 struct rds_connection *conn = cp->cp_conn; 96 struct rds_connection *conn = cp->cp_conn;
94 struct rds_tcp_connection *tc = cp->cp_transport_data; 97 struct rds_tcp_connection *tc = cp->cp_transport_data;
@@ -112,30 +115,33 @@ int rds_tcp_conn_path_connect(struct rds_conn_path *cp)
112 115
113 rds_tcp_tune(sock); 116 rds_tcp_tune(sock);
114 117
115 src.sin_family = AF_INET; 118 sin.sin_family = AF_INET;
116 src.sin_addr.s_addr = (__force u32)conn->c_laddr; 119 sin.sin_addr.s_addr = conn->c_laddr.s6_addr32[3];
117 src.sin_port = (__force u16)htons(0); 120 sin.sin_port = 0;
121 addr = (struct sockaddr *)&sin;
122 addrlen = sizeof(sin);
118 123
119 ret = sock->ops->bind(sock, (struct sockaddr *)&src, sizeof(src)); 124 ret = sock->ops->bind(sock, addr, addrlen);
120 if (ret) { 125 if (ret) {
121 rdsdebug("bind failed with %d at address %pI4\n", 126 rdsdebug("bind failed with %d at address %pI6c\n",
122 ret, &conn->c_laddr); 127 ret, &conn->c_laddr);
123 goto out; 128 goto out;
124 } 129 }
125 130
126 dest.sin_family = AF_INET; 131 sin.sin_family = AF_INET;
127 dest.sin_addr.s_addr = (__force u32)conn->c_faddr; 132 sin.sin_addr.s_addr = conn->c_faddr.s6_addr32[3];
128 dest.sin_port = (__force u16)htons(RDS_TCP_PORT); 133 sin.sin_port = htons(RDS_TCP_PORT);
134 addr = (struct sockaddr *)&sin;
135 addrlen = sizeof(sin);
129 136
130 /* 137 /*
131 * once we call connect() we can start getting callbacks and they 138 * once we call connect() we can start getting callbacks and they
132 * own the socket 139 * own the socket
133 */ 140 */
134 rds_tcp_set_callbacks(sock, cp); 141 rds_tcp_set_callbacks(sock, cp);
135 ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest), 142 ret = sock->ops->connect(sock, addr, addrlen, O_NONBLOCK);
136 O_NONBLOCK);
137 143
138 rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret); 144 rdsdebug("connect to address %pI6c returned %d\n", &conn->c_faddr, ret);
139 if (ret == -EINPROGRESS) 145 if (ret == -EINPROGRESS)
140 ret = 0; 146 ret = 0;
141 if (ret == 0) { 147 if (ret == 0) {