diff options
Diffstat (limited to 'fs/ceph/messenger.c')
-rw-r--r-- | fs/ceph/messenger.c | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/fs/ceph/messenger.c b/fs/ceph/messenger.c index b48abc0b3be7..6ff44bbddf67 100644 --- a/fs/ceph/messenger.c +++ b/fs/ceph/messenger.c | |||
@@ -12,6 +12,7 @@ | |||
12 | 12 | ||
13 | #include "super.h" | 13 | #include "super.h" |
14 | #include "messenger.h" | 14 | #include "messenger.h" |
15 | #include "decode.h" | ||
15 | 16 | ||
16 | /* | 17 | /* |
17 | * Ceph uses the messenger to exchange ceph_msg messages with other | 18 | * Ceph uses the messenger to exchange ceph_msg messages with other |
@@ -97,6 +98,12 @@ const char *pr_addr(const struct sockaddr_storage *ss) | |||
97 | return s; | 98 | return s; |
98 | } | 99 | } |
99 | 100 | ||
101 | static void encode_my_addr(struct ceph_messenger *msgr) | ||
102 | { | ||
103 | memcpy(&msgr->my_enc_addr, &msgr->inst.addr, sizeof(msgr->my_enc_addr)); | ||
104 | ceph_encode_addr(&msgr->my_enc_addr); | ||
105 | } | ||
106 | |||
100 | /* | 107 | /* |
101 | * work queue for all reading and writing to/from the socket. | 108 | * work queue for all reading and writing to/from the socket. |
102 | */ | 109 | */ |
@@ -590,12 +597,12 @@ static void prepare_write_connect(struct ceph_messenger *msgr, | |||
590 | 597 | ||
591 | con->out_kvec[0].iov_base = CEPH_BANNER; | 598 | con->out_kvec[0].iov_base = CEPH_BANNER; |
592 | con->out_kvec[0].iov_len = len; | 599 | con->out_kvec[0].iov_len = len; |
593 | con->out_kvec[1].iov_base = &msgr->inst.addr; | 600 | con->out_kvec[1].iov_base = &msgr->my_enc_addr; |
594 | con->out_kvec[1].iov_len = sizeof(msgr->inst.addr); | 601 | con->out_kvec[1].iov_len = sizeof(msgr->my_enc_addr); |
595 | con->out_kvec[2].iov_base = &con->out_connect; | 602 | con->out_kvec[2].iov_base = &con->out_connect; |
596 | con->out_kvec[2].iov_len = sizeof(con->out_connect); | 603 | con->out_kvec[2].iov_len = sizeof(con->out_connect); |
597 | con->out_kvec_left = 3; | 604 | con->out_kvec_left = 3; |
598 | con->out_kvec_bytes = len + sizeof(msgr->inst.addr) + | 605 | con->out_kvec_bytes = len + sizeof(msgr->my_enc_addr) + |
599 | sizeof(con->out_connect); | 606 | sizeof(con->out_connect); |
600 | con->out_kvec_cur = con->out_kvec; | 607 | con->out_kvec_cur = con->out_kvec; |
601 | con->out_more = 0; | 608 | con->out_more = 0; |
@@ -976,6 +983,9 @@ static int process_connect(struct ceph_connection *con) | |||
976 | if (verify_hello(con) < 0) | 983 | if (verify_hello(con) < 0) |
977 | return -1; | 984 | return -1; |
978 | 985 | ||
986 | ceph_decode_addr(&con->actual_peer_addr); | ||
987 | ceph_decode_addr(&con->peer_addr_for_me); | ||
988 | |||
979 | /* | 989 | /* |
980 | * Make sure the other end is who we wanted. note that the other | 990 | * Make sure the other end is who we wanted. note that the other |
981 | * end may not yet know their ip address, so if it's 0.0.0.0, give | 991 | * end may not yet know their ip address, so if it's 0.0.0.0, give |
@@ -1005,6 +1015,7 @@ static int process_connect(struct ceph_connection *con) | |||
1005 | &con->peer_addr_for_me.in_addr, | 1015 | &con->peer_addr_for_me.in_addr, |
1006 | sizeof(con->peer_addr_for_me.in_addr)); | 1016 | sizeof(con->peer_addr_for_me.in_addr)); |
1007 | addr_set_port(&con->msgr->inst.addr.in_addr, port); | 1017 | addr_set_port(&con->msgr->inst.addr.in_addr, port); |
1018 | encode_my_addr(con->msgr); | ||
1008 | dout("process_connect learned my addr is %s\n", | 1019 | dout("process_connect learned my addr is %s\n", |
1009 | pr_addr(&con->msgr->inst.addr.in_addr)); | 1020 | pr_addr(&con->msgr->inst.addr.in_addr)); |
1010 | } | 1021 | } |
@@ -1780,6 +1791,7 @@ struct ceph_messenger *ceph_messenger_create(struct ceph_entity_addr *myaddr) | |||
1780 | /* select a random nonce */ | 1791 | /* select a random nonce */ |
1781 | get_random_bytes(&msgr->inst.addr.nonce, | 1792 | get_random_bytes(&msgr->inst.addr.nonce, |
1782 | sizeof(msgr->inst.addr.nonce)); | 1793 | sizeof(msgr->inst.addr.nonce)); |
1794 | encode_my_addr(msgr); | ||
1783 | 1795 | ||
1784 | dout("messenger_create %p\n", msgr); | 1796 | dout("messenger_create %p\n", msgr); |
1785 | return msgr; | 1797 | return msgr; |
@@ -1806,8 +1818,9 @@ void ceph_con_send(struct ceph_connection *con, struct ceph_msg *msg) | |||
1806 | } | 1818 | } |
1807 | 1819 | ||
1808 | /* set src+dst */ | 1820 | /* set src+dst */ |
1809 | msg->hdr.src = con->msgr->inst; | 1821 | msg->hdr.src.name = con->msgr->inst.name; |
1810 | msg->hdr.orig_src = con->msgr->inst; | 1822 | msg->hdr.src.addr = con->msgr->my_enc_addr; |
1823 | msg->hdr.orig_src = msg->hdr.src; | ||
1811 | msg->hdr.dst_erank = con->peer_addr.erank; | 1824 | msg->hdr.dst_erank = con->peer_addr.erank; |
1812 | 1825 | ||
1813 | /* queue */ | 1826 | /* queue */ |