]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
msg/async: mark accepted connections with addr type (legacy or msgr2)
authorSage Weil <sage@redhat.com>
Tue, 12 Jun 2018 19:12:19 +0000 (14:12 -0500)
committerSage Weil <sage@redhat.com>
Tue, 3 Jul 2018 18:01:24 +0000 (13:01 -0500)
We have to note the addr type we are listening for in the ServerSocketImpl
and pass that on to any AsyncConnections that result.

Signed-off-by: Sage Weil <sage@redhat.com>
src/msg/async/PosixStack.cc
src/msg/async/Stack.h
src/msg/async/dpdk/DPDKStack.cc
src/msg/async/dpdk/DPDKStack.h
src/msg/async/dpdk/TCP-Stack.h
src/msg/async/dpdk/TCP.cc
src/msg/async/rdma/RDMAServerSocketImpl.cc

index 9a2ceab6b85e8c7b694c25c0bd98eda8d6cee8bd..410bcc4b52be70e57c15eea562123271c674bfb5 100644 (file)
@@ -169,7 +169,9 @@ class PosixServerSocketImpl : public ServerSocketImpl {
   int _fd;
 
  public:
-  explicit PosixServerSocketImpl(NetHandler &h, int f): handler(h), _fd(f) {}
+  explicit PosixServerSocketImpl(NetHandler &h, int f, int type)
+    : ServerSocketImpl(type),
+      handler(h), _fd(f) {}
   int accept(ConnectedSocket *sock, const SocketOptions &opts, entity_addr_t *out, Worker *w) override;
   void abort_accept() override {
     ::close(_fd);
@@ -203,6 +205,7 @@ int PosixServerSocketImpl::accept(ConnectedSocket *sock, const SocketOptions &op
 
   assert(NULL != out); //out should not be NULL in accept connection
 
+  out->set_type(addr_type);
   out->set_sockaddr((sockaddr*)&ss);
   handler.set_priority(sd, opt.priority, out->get_family());
 
@@ -255,7 +258,7 @@ int PosixWorker::listen(entity_addr_t &sa, const SocketOptions &opt,
 
   *sock = ServerSocket(
           std::unique_ptr<PosixServerSocketImpl>(
-              new PosixServerSocketImpl(net, listen_sd)));
+           new PosixServerSocketImpl(net, listen_sd, sa.get_type())));
   return 0;
 }
 
index 49857a2c8394bc4f0cb11eaae1102dc74ea8583d..3835b8483c62984e4553be5b51c144d17649e31f 100644 (file)
@@ -47,6 +47,8 @@ struct SocketOptions {
 /// \cond internal
 class ServerSocketImpl {
  public:
+  int addr_type = 0;
+  ServerSocketImpl(int t) : addr_type(t) {}
   virtual ~ServerSocketImpl() {}
   virtual int accept(ConnectedSocket *sock, const SocketOptions &opt, entity_addr_t *out, Worker *w) = 0;
   virtual void abort_accept() = 0;
index 9772d0f08b946ef5a077bd1c79fe2ba9ce821557..a48e99d435bfc55584dbd10a4f6c1db4cad26078 100644 (file)
@@ -225,7 +225,8 @@ int DPDKWorker::listen(entity_addr_t &sa, const SocketOptions &opt,
   // _inet.set_host_address(ipv4_address(std::get<0>(tuples[idx])));
   // _inet.set_gw_address(ipv4_address(std::get<1>(tuples[idx])));
   // _inet.set_netmask_address(ipv4_address(std::get<2>(tuples[idx])));
-  return tcpv4_listen(_impl->_inet.get_tcp(), sa.get_port(), opt, sock);
+  return tcpv4_listen(_impl->_inet.get_tcp(), sa.get_port(), opt, sa.get_type(),
+                     sock);
 }
 
 int DPDKWorker::connect(const entity_addr_t &addr, const SocketOptions &opts, ConnectedSocket *socket)
index 5bc8f3122a23bc53016e12a2bd0c7e946d2f4faa..6953dce11ca24ce1c8a9e0ba637e34966b9df5e0 100644 (file)
@@ -38,7 +38,8 @@ template <typename Protocol>
 class DPDKServerSocketImpl : public ServerSocketImpl {
   typename Protocol::listener _listener;
  public:
-  DPDKServerSocketImpl(Protocol& proto, uint16_t port, const SocketOptions &opt);
+  DPDKServerSocketImpl(Protocol& proto, uint16_t port, const SocketOptions &opt,
+                      int type);
   int listen() {
     return _listener.listen();
   }
@@ -181,8 +182,8 @@ class NativeConnectedSocketImpl : public ConnectedSocketImpl {
 
 template <typename Protocol>
 DPDKServerSocketImpl<Protocol>::DPDKServerSocketImpl(
-        Protocol& proto, uint16_t port, const SocketOptions &opt)
-        : _listener(proto.listen(port)) {}
+  Protocol& proto, uint16_t port, const SocketOptions &opt, int type)
+  : ServerSocketImpl<Protocol>(type), _listener(proto.listen(port)) {}
 
 template <typename Protocol>
 int DPDKServerSocketImpl<Protocol>::accept(ConnectedSocket *s, const SocketOptions &options, entity_addr_t *out, Worker *w) {
@@ -192,8 +193,10 @@ int DPDKServerSocketImpl<Protocol>::accept(ConnectedSocket *s, const SocketOptio
   if (!c)
     return -EAGAIN;
 
-  if (out)
+  if (out) {
     *out = c->remote_addr();
+    out->set_type(addr_type);
+  }
   std::unique_ptr<NativeConnectedSocketImpl<Protocol>> csi(
           new NativeConnectedSocketImpl<Protocol>(std::move(*c)));
   *s = ConnectedSocket(std::move(csi));
index 86872560c6ea87a65d0c7b9a4c9267c924900350..996ae93c00187ba629892dc5d7d1fc824daea929 100644 (file)
@@ -32,7 +32,7 @@ template <typename InetTraits>
 class tcp;
 
 int tcpv4_listen(tcp<ipv4_traits>& tcpv4, uint16_t port, const SocketOptions &opts,
-                 ServerSocket *sa);
+                 int type, ServerSocket *sa);
 
 int tcpv4_connect(tcp<ipv4_traits>& tcpv4, const entity_addr_t &addr,
                   ConnectedSocket *sa);
index 3fd8341e7511561bd2382da5fb258a28c2ba243f..d215a4c105b5a1c99be0e8dca1a1ba0512f7241a 100644 (file)
@@ -153,9 +153,9 @@ bool ipv4_tcp::forward(forward_hash& out_hash_data, Packet& p, size_t off)
 }
 
 int tcpv4_listen(tcp<ipv4_traits>& tcpv4, uint16_t port, const SocketOptions &opts,
-                 ServerSocket *sock)
+                 int type, ServerSocket *sock)
 {
-  auto p = new DPDKServerSocketImpl<tcp<ipv4_traits>>(tcpv4, port, opts);
+  auto p = new DPDKServerSocketImpl<tcp<ipv4_traits>>(tcpv4, port, opts, type);
   int r = p->listen();
   if (r < 0) {
     delete p;
index df1dfda94154c2a78d0afed26ae47bda66d611a9..d87fdee5823938b811f375de7a9a146537948273 100644 (file)
 #undef dout_prefix
 #define dout_prefix *_dout << " RDMAServerSocketImpl "
 
-RDMAServerSocketImpl::RDMAServerSocketImpl(CephContext *cct, Infiniband* i, RDMADispatcher *s, RDMAWorker *w, entity_addr_t& a)
-  : cct(cct), net(cct), server_setup_socket(-1), infiniband(i), dispatcher(s), worker(w), sa(a)
+RDMAServerSocketImpl::RDMAServerSocketImpl(
+  CephContext *cct, Infiniband* i, RDMADispatcher *s, RDMAWorker *w,
+  entity_addr_t& a)
+  : ServerSocketImpl(a.get_type()),
+    cct(cct), net(cct), server_setup_socket(-1), infiniband(i),
+    dispatcher(s), worker(w), sa(a)
 {
 }
 
@@ -100,6 +104,7 @@ int RDMAServerSocketImpl::accept(ConnectedSocket *sock, const SocketOptions &opt
 
   assert(NULL != out); //out should not be NULL in accept connection
 
+  out->set_type(addr_type);
   out->set_sockaddr((sockaddr*)&ss);
   net.set_priority(sd, opt.priority, out->get_family());