]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async/AsyncConnection: resurrect support for !CEPH_FEATURE_MSG_AUTH
authorIlya Dryomov <idryomov@gmail.com>
Mon, 20 Nov 2017 15:23:15 +0000 (16:23 +0100)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 20 Nov 2017 15:35:41 +0000 (16:35 +0100)
Revert CEPH_FEATURE_MSG_AUTH-related hunks of commit 83f7e392a163
("msg/async/AsyncConnection: remove legacy feature case handle"), which
removed code that handled !CEPH_FEATURE_MSG_AUTH footers.  It's needed
for kernels prior to 3.19, where cephx signatures aren't supported.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
src/msg/async/AsyncConnection.cc

index a2abbce56297eb2e41ba1ea03f5b0ba7811b6de0..99a631a740508e38811da381e6403897c5e12e9a 100644 (file)
@@ -639,8 +639,15 @@ void AsyncConnection::process()
       case STATE_OPEN_MESSAGE_READ_FOOTER_AND_DISPATCH:
         {
           ceph_msg_footer footer;
-
-          r = read_until(sizeof(footer), state_buffer);
+          ceph_msg_footer_old old_footer;
+          unsigned len;
+          // footer
+          if (has_feature(CEPH_FEATURE_MSG_AUTH))
+            len = sizeof(footer);
+          else
+            len = sizeof(old_footer);
+
+          r = read_until(len, state_buffer);
           if (r < 0) {
             ldout(async_msgr->cct, 1) << __func__ << " read footer data error " << dendl;
             goto fail;
@@ -648,7 +655,16 @@ void AsyncConnection::process()
             break;
           }
 
-          footer = *((ceph_msg_footer*)state_buffer);
+          if (has_feature(CEPH_FEATURE_MSG_AUTH)) {
+            footer = *((ceph_msg_footer*)state_buffer);
+          } else {
+            old_footer = *((ceph_msg_footer_old*)state_buffer);
+            footer.front_crc = old_footer.front_crc;
+            footer.middle_crc = old_footer.middle_crc;
+            footer.data_crc = old_footer.data_crc;
+            footer.sig = 0;
+            footer.flags = old_footer.flags;
+          }
           int aborted = (footer.flags & CEPH_MSG_FOOTER_COMPLETE) == 0;
           ldout(async_msgr->cct, 10) << __func__ << " aborted = " << aborted << dendl;
           if (aborted) {
@@ -2199,7 +2215,22 @@ ssize_t AsyncConnection::write_message(Message *m, bufferlist& bl, bool more)
     outcoming_bl.claim_append(bl);  
   }
 
-  outcoming_bl.append((char*)&footer, sizeof(footer));
+  // send footer; if receiver doesn't support signatures, use the old footer format
+  ceph_msg_footer_old old_footer;
+  if (has_feature(CEPH_FEATURE_MSG_AUTH)) {
+    outcoming_bl.append((char*)&footer, sizeof(footer));
+  } else {
+    if (msgr->crcflags & MSG_CRC_HEADER) {
+      old_footer.front_crc = footer.front_crc;
+      old_footer.middle_crc = footer.middle_crc;
+      old_footer.data_crc = footer.data_crc;
+    } else {
+       old_footer.front_crc = old_footer.middle_crc = 0;
+    }
+    old_footer.data_crc = msgr->crcflags & MSG_CRC_DATA ? footer.data_crc : 0;
+    old_footer.flags = footer.flags;
+    outcoming_bl.append((char*)&old_footer, sizeof(old_footer));
+  }
 
   m->trace.event("async writing message");
   ldout(async_msgr->cct, 20) << __func__ << " sending " << m->get_seq()