| 731 | } |
| 732 | |
| 733 | bool DaemonServer::handle_report(const ref_t<MMgrReport>& m) |
| 734 | { |
| 735 | DaemonKey key; |
| 736 | if (!m->service_name.empty()) { |
| 737 | key.type = m->service_name; |
| 738 | } else { |
| 739 | key.type = ceph_entity_type_name(m->get_connection()->get_peer_type()); |
| 740 | } |
| 741 | key.name = m->daemon_name; |
| 742 | |
| 743 | dout(10) << "from " << m->get_connection() << " " << key << dendl; |
| 744 | |
| 745 | if (m->get_connection()->get_peer_type() == entity_name_t::TYPE_CLIENT && |
| 746 | m->service_name.empty()) { |
| 747 | // Clients should not be sending us stats unless they are declaring |
| 748 | // themselves to be a daemon for some service. |
| 749 | dout(10) << "rejecting report from non-daemon client " << m->daemon_name |
| 750 | << dendl; |
| 751 | clog->warn() << "rejecting report from non-daemon client " << m->daemon_name |
| 752 | << " at " << m->get_connection()->get_peer_addrs(); |
| 753 | m->get_connection()->mark_down(); |
| 754 | return true; |
| 755 | } |
| 756 | |
| 757 | |
| 758 | { |
| 759 | std::unique_lock locker(lock); |
| 760 | |
| 761 | DaemonStatePtr daemon; |
| 762 | // Look up the DaemonState |
| 763 | if (daemon = daemon_state.get(key); daemon != nullptr) { |
| 764 | dout(20) << "updating existing DaemonState for " << key << dendl; |
| 765 | } else { |
| 766 | locker.unlock(); |
| 767 | |
| 768 | // we don't know the hostname at this stage, reject MMgrReport here. |
| 769 | dout(5) << "rejecting report from " << key << ", since we do not have its metadata now." |
| 770 | << dendl; |
| 771 | // issue metadata request in background |
| 772 | fetch_missing_metadata(key, m->get_source_addr()); |
| 773 | |
| 774 | locker.lock(); |
| 775 | |
| 776 | // kill session |
| 777 | auto priv = m->get_connection()->get_priv(); |
| 778 | auto session = static_cast<MgrSession*>(priv.get()); |
| 779 | if (!session) { |
| 780 | return false; |
| 781 | } |
| 782 | m->get_connection()->mark_down(); |
| 783 | |
| 784 | dout(10) << "unregistering osd." << session->osd_id |
| 785 | << " session " << session << " con " << m->get_connection() << dendl; |
| 786 | |
| 787 | if (osd_cons.find(session->osd_id) != osd_cons.end()) { |
| 788 | osd_cons[session->osd_id].erase(m->get_connection()); |
| 789 | } |
| 790 |
nothing calls this directly
no test coverage detected