RDS: TCP: Force every connection to be initiated by numerically smaller IP address
[linux-2.6-microblaze.git] / net / rds / tcp_connect.c
index 05f61c5..d6839d9 100644 (file)
@@ -60,7 +60,19 @@ void rds_tcp_state_change(struct sock *sk)
        case TCP_SYN_RECV:
                break;
        case TCP_ESTABLISHED:
-               rds_connect_path_complete(cp, RDS_CONN_CONNECTING);
+               /* Force the peer to reconnect so that we have the
+                * TCP ports going from <smaller-ip>.<transient> to
+                * <larger-ip>.<RDS_TCP_PORT>. We avoid marking the
+                * RDS connection as RDS_CONN_UP until the reconnect,
+                * to avoid RDS datagram loss.
+                */
+               if (cp->cp_conn->c_laddr > cp->cp_conn->c_faddr &&
+                   rds_conn_path_transition(cp, RDS_CONN_CONNECTING,
+                                            RDS_CONN_ERROR)) {
+                       rds_conn_path_drop(cp);
+               } else {
+                       rds_connect_path_complete(cp, RDS_CONN_CONNECTING);
+               }
                break;
        case TCP_CLOSE_WAIT:
        case TCP_CLOSE: