]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: learn address during connect handshake
authorSage Weil <sage@newdream.net>
Wed, 2 Sep 2009 22:57:17 +0000 (15:57 -0700)
committerSage Weil <sage@newdream.net>
Wed, 2 Sep 2009 23:10:06 +0000 (16:10 -0700)
src/kernel/messenger.c
src/kernel/messenger.h
src/kernel/mon_client.c

index 43903212bb1107d3022c185e2a8f1974e6d9980c..e1c95290b70fa1908027f12a51904dcaa7f189b8 100644 (file)
@@ -733,6 +733,10 @@ static int read_partial_connect(struct ceph_connection *con)
                           &con->actual_peer_addr);
        if (ret <= 0)
                goto out;
+       ret = read_partial(con, &to, sizeof(con->peer_addr_for_me),
+                          &con->peer_addr_for_me);
+       if (ret <= 0)
+               goto out;
        ret = read_partial(con, &to, sizeof(con->in_reply), &con->in_reply);
        if (ret <= 0)
                goto out;
@@ -786,6 +790,20 @@ static int process_connect(struct ceph_connection *con)
                return -1;
        }
 
+       /*
+        * did we learn our address?
+        */
+       if (con->msgr->inst.addr.ipaddr.sin_addr.s_addr == htons(INADDR_ANY)) {
+               int port = con->msgr->inst.addr.ipaddr.sin_port;
+
+               memcpy(&con->msgr->inst.addr.ipaddr,
+                      &con->peer_addr_for_me.ipaddr,
+                      sizeof(con->peer_addr_for_me.ipaddr));
+               con->msgr->inst.addr.ipaddr.sin_port = port;
+               dout("process_connect learned my addr is %u.%u.%u.%u:%u\n",
+                    IPQUADPORT(con->msgr->inst.addr.ipaddr));
+       }
+
        switch (con->in_reply.tag) {
        case CEPH_MSGR_TAG_RESETSESSION:
                /*
index 28e3ad17621b20aaeb891e770fd8ec36cdb61887..37da5637f3daa0c1b508d7fd023a9bee9b4f9bb9 100644 (file)
@@ -159,6 +159,7 @@ struct ceph_connection {
 
        struct ceph_entity_addr peer_addr; /* peer address */
        struct ceph_entity_name peer_name; /* peer name */
+       struct ceph_entity_addr peer_addr_for_me;
        u32 connect_seq;      /* identify the most recent connection
                                 attempt for this connection, client */
        u32 peer_global_seq;  /* peer's global seq for this connection */
index d873436fb77d555253f64bdd8fd65041205fba19..ec2574f0667a2f6803cd833dcf4703b53866bf1e 100644 (file)
@@ -306,7 +306,6 @@ static void handle_mount_ack(struct ceph_mon_client *monc, struct ceph_msg *msg)
        s32 result;
        u32 len;
        s64 cnum;
-       struct ceph_entity_addr addr;
        int err = -EINVAL;
 
        if (client->whoami >= 0) {
@@ -321,9 +320,6 @@ static void handle_mount_ack(struct ceph_mon_client *monc, struct ceph_msg *msg)
        end = p + msg->front.iov_len;
 
        ceph_decode_64_safe(&p, end, cnum, bad);
-       ceph_decode_need(&p, end, sizeof(addr), bad);
-       ceph_decode_copy(&p, &addr, sizeof(addr));
-       
        ceph_decode_32_safe(&p, end, result, bad);
        ceph_decode_32_safe(&p, end, len, bad);
        if (result) {
@@ -356,9 +352,8 @@ static void handle_mount_ack(struct ceph_mon_client *monc, struct ceph_msg *msg)
        client->whoami = cnum;
        client->msgr->inst.name.num = cpu_to_le32(cnum);
        client->msgr->inst.name.type = CEPH_ENTITY_TYPE_CLIENT;
-       memcpy(&client->msgr->inst.addr, &addr, sizeof(addr));
-       pr_info("ceph client%lld %u.%u.%u.%u:%u fsid %llx.%llx\n",
-               client->whoami, IPQUADPORT(addr.ipaddr),
+       pr_info("ceph client%lld fsid %llx.%llx\n",
+               client->whoami,
                le64_to_cpu(__ceph_fsid_major(&client->monc.monmap->fsid)),
                le64_to_cpu(__ceph_fsid_minor(&client->monc.monmap->fsid)));