diff options
author | Sowmini Varadhan <sowmini.varadhan@oracle.com> | 2016-05-02 14:24:52 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-05-03 16:03:44 -0400 |
commit | bd7c5f983f3185b75cc23bdd5dbc3a676aef3d1e (patch) | |
tree | 42b348d05eaf5e948bd694bdbe390ebb6a9c354f /net/rds/tcp_connect.c | |
parent | eb192840266fab3e3da644018121eed30153355d (diff) |
RDS: TCP: Synchronize accept() and connect() paths on t_conn_lock.
An arbitration scheme for duelling SYNs is implemented as part of
commit 241b271952eb ("RDS-TCP: Reset tcp callbacks if re-using an
outgoing socket in rds_tcp_accept_one()") which ensures that both nodes
involved will arrive at the same arbitration decision. However, this
needs to be synchronized with an outgoing SYN to be generated by
rds_tcp_conn_connect(). This commit achieves the synchronization
through the t_conn_lock mutex in struct rds_tcp_connection.
The rds_conn_state is checked in rds_tcp_conn_connect() after acquiring
the t_conn_lock mutex. A SYN is sent out only if the RDS connection is
not already UP (an UP would indicate that rds_tcp_accept_one() has
completed 3WH, so no SYN needs to be generated).
Similarly, the rds_conn_state is checked in rds_tcp_accept_one() after
acquiring the t_conn_lock mutex. The only acceptable states (to
allow continuation of the arbitration logic) are UP (i.e., outgoing SYN
was SYN-ACKed by peer after it sent us the SYN) or CONNECTING (we sent
outgoing SYN before we saw incoming SYN).
Signed-off-by: Sowmini Varadhan <sowmini.varadhan@oracle.com>
Acked-by: Santosh Shilimkar <santosh.shilimkar@oracle.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/rds/tcp_connect.c')
-rw-r--r-- | net/rds/tcp_connect.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c index 5cb16875c460..49a3fcfed360 100644 --- a/net/rds/tcp_connect.c +++ b/net/rds/tcp_connect.c | |||
@@ -78,7 +78,14 @@ int rds_tcp_conn_connect(struct rds_connection *conn) | |||
78 | struct socket *sock = NULL; | 78 | struct socket *sock = NULL; |
79 | struct sockaddr_in src, dest; | 79 | struct sockaddr_in src, dest; |
80 | int ret; | 80 | int ret; |
81 | struct rds_tcp_connection *tc = conn->c_transport_data; | ||
82 | |||
83 | mutex_lock(&tc->t_conn_lock); | ||
81 | 84 | ||
85 | if (rds_conn_up(conn)) { | ||
86 | mutex_unlock(&tc->t_conn_lock); | ||
87 | return 0; | ||
88 | } | ||
82 | ret = sock_create_kern(rds_conn_net(conn), PF_INET, | 89 | ret = sock_create_kern(rds_conn_net(conn), PF_INET, |
83 | SOCK_STREAM, IPPROTO_TCP, &sock); | 90 | SOCK_STREAM, IPPROTO_TCP, &sock); |
84 | if (ret < 0) | 91 | if (ret < 0) |
@@ -120,6 +127,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn) | |||
120 | } | 127 | } |
121 | 128 | ||
122 | out: | 129 | out: |
130 | mutex_unlock(&tc->t_conn_lock); | ||
123 | if (sock) | 131 | if (sock) |
124 | sock_release(sock); | 132 | sock_release(sock); |
125 | return ret; | 133 | return ret; |