tcp_connect.c (552c69b36ebd966186573b9c7a286b390935cce1) | tcp_connect.c (eee2fa6ab3225192d6d894c54a6fb02ac9efdff6) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2006 Oracle. All rights reserved. | 2 * Copyright (c) 2006, 2017 Oracle and/or its affiliates. All rights reserved. |
3 * 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 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 50 unchanged lines hidden (view full) --- 61 break; 62 case TCP_ESTABLISHED: 63 /* Force the peer to reconnect so that we have the 64 * TCP ports going from <smaller-ip>.<transient> to 65 * <larger-ip>.<RDS_TCP_PORT>. We avoid marking the 66 * RDS connection as RDS_CONN_UP until the reconnect, 67 * to avoid RDS datagram loss. 68 */ | 3 * 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 6 * General Public License (GPL) Version 2, available from the file 7 * COPYING in the main directory of this source tree, or the 8 * OpenIB.org BSD license below: 9 * 10 * Redistribution and use in source and binary forms, with or --- 50 unchanged lines hidden (view full) --- 61 break; 62 case TCP_ESTABLISHED: 63 /* Force the peer to reconnect so that we have the 64 * TCP ports going from <smaller-ip>.<transient> to 65 * <larger-ip>.<RDS_TCP_PORT>. We avoid marking the 66 * RDS connection as RDS_CONN_UP until the reconnect, 67 * to avoid RDS datagram loss. 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_ERROR)) { 72 rds_conn_path_drop(cp, false); 73 } else { 74 rds_connect_path_complete(cp, RDS_CONN_CONNECTING); 75 } 76 break; 77 case TCP_CLOSE_WAIT: --- 5 unchanged lines hidden (view full) --- 83out: 84 read_unlock_bh(&sk->sk_callback_lock); 85 state_change(sk); 86} 87 88int rds_tcp_conn_path_connect(struct rds_conn_path *cp) 89{ 90 struct socket *sock = NULL; | 71 rds_conn_path_transition(cp, RDS_CONN_CONNECTING, 72 RDS_CONN_ERROR)) { 73 rds_conn_path_drop(cp, false); 74 } else { 75 rds_connect_path_complete(cp, RDS_CONN_CONNECTING); 76 } 77 break; 78 case TCP_CLOSE_WAIT: --- 5 unchanged lines hidden (view full) --- 84out: 85 read_unlock_bh(&sk->sk_callback_lock); 86 state_change(sk); 87} 88 89int rds_tcp_conn_path_connect(struct rds_conn_path *cp) 90{ 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; 93 struct rds_connection *conn = cp->cp_conn; 94 struct rds_tcp_connection *tc = cp->cp_transport_data; 95 96 /* for multipath rds,we only trigger the connection after 97 * the handshake probe has determined the number of paths. 98 */ 99 if (cp->cp_index > 0 && cp->cp_conn->c_npaths < 2) --- 7 unchanged lines hidden (view full) --- 107 } 108 ret = sock_create_kern(rds_conn_net(conn), PF_INET, 109 SOCK_STREAM, IPPROTO_TCP, &sock); 110 if (ret < 0) 111 goto out; 112 113 rds_tcp_tune(sock); 114 | 95 int ret; 96 struct rds_connection *conn = cp->cp_conn; 97 struct rds_tcp_connection *tc = cp->cp_transport_data; 98 99 /* for multipath rds,we only trigger the connection after 100 * the handshake probe has determined the number of paths. 101 */ 102 if (cp->cp_index > 0 && cp->cp_conn->c_npaths < 2) --- 7 unchanged lines hidden (view full) --- 110 } 111 ret = sock_create_kern(rds_conn_net(conn), PF_INET, 112 SOCK_STREAM, IPPROTO_TCP, &sock); 113 if (ret < 0) 114 goto out; 115 116 rds_tcp_tune(sock); 117 |
115 src.sin_family = AF_INET; 116 src.sin_addr.s_addr = (__force u32)conn->c_laddr; 117 src.sin_port = (__force u16)htons(0); | 118 sin.sin_family = AF_INET; 119 sin.sin_addr.s_addr = conn->c_laddr.s6_addr32[3]; 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); 123 goto out; 124 } 125 | 127 ret, &conn->c_laddr); 128 goto out; 129 } 130 |
126 dest.sin_family = AF_INET; 127 dest.sin_addr.s_addr = (__force u32)conn->c_faddr; 128 dest.sin_port = (__force u16)htons(RDS_TCP_PORT); | 131 sin.sin_family = AF_INET; 132 sin.sin_addr.s_addr = conn->c_faddr.s6_addr32[3]; 133 sin.sin_port = htons(RDS_TCP_PORT); 134 addr = (struct sockaddr *)&sin; 135 addrlen = sizeof(sin); |
129 130 /* 131 * once we call connect() we can start getting callbacks and they 132 * own the socket 133 */ 134 rds_tcp_set_callbacks(sock, cp); | 136 137 /* 138 * once we call connect() we can start getting callbacks and they 139 * own the socket 140 */ 141 rds_tcp_set_callbacks(sock, cp); |
135 ret = sock->ops->connect(sock, (struct sockaddr *)&dest, sizeof(dest), 136 O_NONBLOCK); | 142 ret = sock->ops->connect(sock, addr, addrlen, 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) 140 ret = 0; 141 if (ret == 0) { 142 rds_tcp_keepalive(sock); 143 sock = NULL; 144 } else { 145 rds_tcp_restore_callbacks(sock, cp->cp_transport_data); 146 } --- 43 unchanged lines hidden --- | 145 if (ret == -EINPROGRESS) 146 ret = 0; 147 if (ret == 0) { 148 rds_tcp_keepalive(sock); 149 sock = NULL; 150 } else { 151 rds_tcp_restore_callbacks(sock, cp->cp_transport_data); 152 } --- 43 unchanged lines hidden --- |