]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/net: prevent reusing the sent messages
authorYingxin Cheng <yingxin.cheng@intel.com>
Fri, 5 Jul 2019 09:32:41 +0000 (17:32 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Fri, 5 Jul 2019 13:51:34 +0000 (21:51 +0800)
We are tracking sent messages by seq, so reusing messages will cause
undefined behavior because seq should not be shared between different
messages.

Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/net/ProtocolV1.cc
src/crimson/net/ProtocolV2.cc
src/test/crimson/test_messenger.cc

index 4601b3460b18c4fb1b699b5abbf385e4a6ed3b67..093cb1c3288d90105c5a4a0c97765b8c29351fb8 100644 (file)
@@ -691,6 +691,7 @@ ceph::bufferlist ProtocolV1::do_sweep_messages(
   }
 
   std::for_each(msgs.begin(), msgs.begin()+num_msgs, [this, &bl](const MessageRef& msg) {
+    ceph_assert(!msg->get_seq() && "message already has seq");
     msg->set_seq(++conn.out_seq);
     auto& header = msg->get_header();
     header.src = messenger.get_myname();
index d86f2bcd1d7ce8dad51f63b43b9c6668424d6054..e5bee37a5eba2f7341e3f0d1664d71718a392fff 100644 (file)
@@ -1368,6 +1368,7 @@ ceph::bufferlist ProtocolV2::do_sweep_messages(
 
     msg->encode(conn.features, 0);
 
+    ceph_assert(!msg->get_seq() && "message already has seq");
     msg->set_seq(++conn.out_seq);
     uint64_t ack_seq = conn.in_seq;
     // ack_left = 0;
index 3e22643b0329907ba7a25604fae292d180d44ab4..f5eb576d20546b3ce544943506f295bfaed0d6ab 100644 (file)
@@ -36,7 +36,6 @@ static seastar::future<> test_echo(unsigned rounds,
         : public ceph::net::Dispatcher,
           public seastar::peering_sharded_service<Server> {
       ceph::net::Messenger *msgr = nullptr;
-      MessageRef msg_pong{new MPing(), false};
       ceph::auth::DummyAuthClientServer dummy_auth;
 
       Dispatcher* get_local_shard() override {
@@ -51,7 +50,7 @@ static seastar::future<> test_echo(unsigned rounds,
           logger().info("server got {}", *m);
         }
         // reply with a pong
-        return c->send(msg_pong);
+        return c->send(make_message<MPing>());
       }
 
       seastar::future<> init(const entity_name_t& name,
@@ -95,7 +94,6 @@ static seastar::future<> test_echo(unsigned rounds,
       ceph::net::Messenger *msgr = nullptr;
       std::map<ceph::net::Connection*, seastar::promise<>> pending_conns;
       std::map<ceph::net::Connection*, PingSessionRef> sessions;
-      MessageRef msg_ping{new MPing(), false};
       ceph::auth::DummyAuthClientServer dummy_auth;
 
       Client(unsigned rounds, double keepalive_ratio)
@@ -230,7 +228,7 @@ static seastar::future<> test_echo(unsigned rounds,
                                 seastar::stop_iteration::no);
                             });
                         } else {
-                          return conn->send(msg_ping)
+                          return conn->send(make_message<MPing>())
                             .then([&count_ping] {
                               count_ping += 1;
                               return seastar::make_ready_future<seastar::stop_iteration>(