]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: fail connection when s_addr==0 and port/nonce don't match
authorSage Weil <sage@newdream.net>
Mon, 11 May 2009 21:00:52 +0000 (14:00 -0700)
committerSage Weil <sage@newdream.net>
Mon, 11 May 2009 21:00:52 +0000 (14:00 -0700)
Even if s_addr is 0, the port and nonce should match.  We were
previously going ahead with the connection when we shouldn't have
been.

src/kernel/messenger.c

index 88501faf9fad91c1157ef8a05cc7fdedf5479785..af83d0599f11715abfcec3b925fa4aab7addc85e 100644 (file)
@@ -1099,7 +1099,10 @@ static int process_connect(struct ceph_connection *con)
         */
        if (!ceph_entity_addr_is_local(&con->peer_addr,
                                       &con->actual_peer_addr) &&
-           con->actual_peer_addr.ipaddr.sin_addr.s_addr != 0) {
+           !(con->actual_peer_addr.ipaddr.sin_addr.s_addr == 0 &&
+             con->actual_peer_addr.ipaddr.sin_port ==
+               con->peer_addr.ipaddr.sin_port &&
+             con->actual_peer_addr.nonce == con->peer_addr.nonce)) {
                derr(1, "process_connect wrong peer, want %u.%u.%u.%u:%u/%d, "
                     "got %u.%u.%u.%u:%u/%d, wtf\n",
                     IPQUADPORT(con->peer_addr.ipaddr),