| 315 | } |
| 316 | |
| 317 | Message *decode_message(CephContext *cct, |
| 318 | int crcflags, |
| 319 | ceph_msg_header& header, |
| 320 | ceph_msg_footer& footer, |
| 321 | ceph::bufferlist& front, |
| 322 | ceph::bufferlist& middle, |
| 323 | ceph::bufferlist& data, |
| 324 | Message::ConnectionRef conn) |
| 325 | { |
| 326 | #ifdef WITH_CRIMSON |
| 327 | // In crimson, conn is independently maintained outside Message. |
| 328 | ceph_assert(conn == nullptr); |
| 329 | #endif |
| 330 | // verify crc |
| 331 | if (crcflags & MSG_CRC_HEADER) { |
| 332 | __u32 front_crc = front.crc32c(0); |
| 333 | __u32 middle_crc = middle.crc32c(0); |
| 334 | |
| 335 | if (front_crc != footer.front_crc) { |
| 336 | if (cct) { |
| 337 | ldout(cct, 0) << "bad crc in front " << front_crc << " != exp " << footer.front_crc |
| 338 | #ifndef WITH_CRIMSON |
| 339 | << " from " << conn->get_peer_addr() |
| 340 | #endif |
| 341 | << dendl; |
| 342 | ldout(cct, 20) << " "; |
| 343 | front.hexdump(*_dout); |
| 344 | *_dout << dendl; |
| 345 | } |
| 346 | return 0; |
| 347 | } |
| 348 | if (middle_crc != footer.middle_crc) { |
| 349 | if (cct) { |
| 350 | ldout(cct, 0) << "bad crc in middle " << middle_crc << " != exp " << footer.middle_crc |
| 351 | #ifndef WITH_CRIMSON |
| 352 | << " from " << conn->get_peer_addr() |
| 353 | #endif |
| 354 | << dendl; |
| 355 | ldout(cct, 20) << " "; |
| 356 | middle.hexdump(*_dout); |
| 357 | *_dout << dendl; |
| 358 | } |
| 359 | return 0; |
| 360 | } |
| 361 | } |
| 362 | if (crcflags & MSG_CRC_DATA) { |
| 363 | if ((footer.flags & CEPH_MSG_FOOTER_NOCRC) == 0) { |
| 364 | __u32 data_crc = data.crc32c(0); |
| 365 | if (data_crc != footer.data_crc) { |
| 366 | if (cct) { |
| 367 | ldout(cct, 0) << "bad crc in data " << data_crc << " != exp " << footer.data_crc |
| 368 | #ifndef WITH_CRIMSON |
| 369 | << " from " << conn->get_peer_addr() |
| 370 | #endif |
| 371 | << dendl; |
| 372 | ldout(cct, 20) << " "; |
| 373 | data.hexdump(*_dout); |
| 374 | *_dout << dendl; |