| 1121 | } |
| 1122 | |
| 1123 | ssize_t ProtocolV1::write_message(Message *m, ceph::buffer::list &bl, bool more) { |
| 1124 | FUNCTRACE(cct); |
| 1125 | ceph_assert(connection->center->in_thread()); |
| 1126 | m->set_seq(++out_seq); |
| 1127 | |
| 1128 | if (messenger->crcflags & MSG_CRC_HEADER) { |
| 1129 | m->calc_header_crc(); |
| 1130 | } |
| 1131 | |
| 1132 | ceph_msg_header &header = m->get_header(); |
| 1133 | ceph_msg_footer &footer = m->get_footer(); |
| 1134 | |
| 1135 | // TODO: let sign_message could be reentry? |
| 1136 | // Now that we have all the crcs calculated, handle the |
| 1137 | // digital signature for the message, if the AsyncConnection has session |
| 1138 | // security set up. Some session security options do not |
| 1139 | // actually calculate and check the signature, but they should |
| 1140 | // handle the calls to sign_message and check_signature. PLR |
| 1141 | if (session_security.get() == NULL) { |
| 1142 | ldout(cct, 20) << __func__ << " no session security" << dendl; |
| 1143 | } else { |
| 1144 | if (session_security->sign_message(m)) { |
| 1145 | ldout(cct, 20) << __func__ << " failed to sign m=" << m |
| 1146 | << "): sig = " << footer.sig << dendl; |
| 1147 | } else { |
| 1148 | ldout(cct, 20) << __func__ << " signed m=" << m |
| 1149 | << "): sig = " << footer.sig << dendl; |
| 1150 | } |
| 1151 | } |
| 1152 | |
| 1153 | connection->outgoing_bl.append(CEPH_MSGR_TAG_MSG); |
| 1154 | connection->outgoing_bl.append((char *)&header, sizeof(header)); |
| 1155 | |
| 1156 | ldout(cct, 20) << __func__ << " sending message type=" << header.type |
| 1157 | << " src " << entity_name_t(header.src) |
| 1158 | << " front=" << header.front_len << " data=" << header.data_len |
| 1159 | << " off " << header.data_off << dendl; |
| 1160 | |
| 1161 | if ((bl.length() <= ASYNC_COALESCE_THRESHOLD) && (bl.get_num_buffers() > 1)) { |
| 1162 | for (const auto &pb : bl.buffers()) { |
| 1163 | connection->outgoing_bl.append((char *)pb.c_str(), pb.length()); |
| 1164 | } |
| 1165 | } else { |
| 1166 | connection->outgoing_bl.claim_append(bl); |
| 1167 | } |
| 1168 | |
| 1169 | // send footer; if receiver doesn't support signatures, use the old footer |
| 1170 | // format |
| 1171 | ceph_msg_footer_old old_footer; |
| 1172 | if (connection->has_feature(CEPH_FEATURE_MSG_AUTH)) { |
| 1173 | connection->outgoing_bl.append((char *)&footer, sizeof(footer)); |
| 1174 | } else { |
| 1175 | if (messenger->crcflags & MSG_CRC_HEADER) { |
| 1176 | old_footer.front_crc = footer.front_crc; |
| 1177 | old_footer.middle_crc = footer.middle_crc; |
| 1178 | } else { |
| 1179 | old_footer.front_crc = old_footer.middle_crc = 0; |
| 1180 | } |
nothing calls this directly
no test coverage detected