| 1025 | } |
| 1026 | |
| 1027 | CtPtr ProtocolV2::handle_hello(ceph::bufferlist &payload) |
| 1028 | { |
| 1029 | ldout(cct, 20) << __func__ |
| 1030 | << " payload.length()=" << payload.length() << dendl; |
| 1031 | |
| 1032 | if (state != HELLO_CONNECTING && state != HELLO_ACCEPTING) { |
| 1033 | lderr(cct) << __func__ << " not in hello exchange state!" << dendl; |
| 1034 | return _fault(); |
| 1035 | } |
| 1036 | |
| 1037 | auto hello = HelloFrame::Decode(payload); |
| 1038 | |
| 1039 | ldout(cct, 5) << __func__ << " received hello:" |
| 1040 | << " peer_type=" << (int)hello.entity_type() |
| 1041 | << " peer_addr_for_me=" << hello.peer_addr() << dendl; |
| 1042 | |
| 1043 | sockaddr_storage ss; |
| 1044 | socklen_t len = sizeof(ss); |
| 1045 | getsockname(connection->cs.fd(), (sockaddr *)&ss, &len); |
| 1046 | ldout(cct, 5) << __func__ << " getsockname says I am " << (sockaddr *)&ss |
| 1047 | << " when talking to " << connection->target_addr << dendl; |
| 1048 | |
| 1049 | if (connection->get_peer_type() == -1) { |
| 1050 | connection->set_peer_type(hello.entity_type()); |
| 1051 | |
| 1052 | ceph_assert(state == HELLO_ACCEPTING); |
| 1053 | connection->policy = messenger->get_policy(hello.entity_type()); |
| 1054 | ldout(cct, 10) << __func__ << " accept of host_type " |
| 1055 | << (int)hello.entity_type() |
| 1056 | << ", policy.lossy=" << connection->policy.lossy |
| 1057 | << " policy.server=" << connection->policy.server |
| 1058 | << " policy.standby=" << connection->policy.standby |
| 1059 | << " policy.resetcheck=" << connection->policy.resetcheck |
| 1060 | << dendl; |
| 1061 | } else { |
| 1062 | ceph_assert(state == HELLO_CONNECTING); |
| 1063 | if (connection->get_peer_type() != hello.entity_type()) { |
| 1064 | ldout(cct, 1) << __func__ << " connection peer type does not match what" |
| 1065 | << " peer advertises " << connection->get_peer_type() |
| 1066 | << " != " << (int)hello.entity_type() << dendl; |
| 1067 | stop(); |
| 1068 | connection->dispatch_queue->queue_reset(connection); |
| 1069 | return nullptr; |
| 1070 | } |
| 1071 | } |
| 1072 | |
| 1073 | if (messenger->get_myaddrs().empty() || |
| 1074 | messenger->get_myaddrs().front().is_blank_ip()) { |
| 1075 | entity_addr_t a; |
| 1076 | if (cct->_conf->ms_learn_addr_from_peer) { |
| 1077 | ldout(cct, 1) << __func__ << " peer " << connection->target_addr |
| 1078 | << " says I am " << hello.peer_addr() << " (socket says " |
| 1079 | << (sockaddr*)&ss << ")" << dendl; |
| 1080 | a = hello.peer_addr(); |
| 1081 | } else { |
| 1082 | ldout(cct, 1) << __func__ << " socket to " << connection->target_addr |
| 1083 | << " says I am " << (sockaddr*)&ss |
| 1084 | << " (peer says " << hello.peer_addr() << ")" << dendl; |
nothing calls this directly
no test coverage detected