From: Sage Weil Date: Tue, 12 Jun 2018 19:12:19 +0000 (-0500) Subject: msg/async: mark accepted connections with addr type (legacy or msgr2) X-Git-Tag: v14.0.1~951^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ccad66390f4e8765185a42946e680759259b5631;p=ceph.git msg/async: mark accepted connections with addr type (legacy or msgr2) 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 --- diff --git a/src/msg/async/PosixStack.cc b/src/msg/async/PosixStack.cc index 9a2ceab6b85e..410bcc4b52be 100644 --- a/src/msg/async/PosixStack.cc +++ b/src/msg/async/PosixStack.cc @@ -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( - new PosixServerSocketImpl(net, listen_sd))); + new PosixServerSocketImpl(net, listen_sd, sa.get_type()))); return 0; } diff --git a/src/msg/async/Stack.h b/src/msg/async/Stack.h index 49857a2c8394..3835b8483c62 100644 --- a/src/msg/async/Stack.h +++ b/src/msg/async/Stack.h @@ -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; diff --git a/src/msg/async/dpdk/DPDKStack.cc b/src/msg/async/dpdk/DPDKStack.cc index 9772d0f08b94..a48e99d435bf 100644 --- a/src/msg/async/dpdk/DPDKStack.cc +++ b/src/msg/async/dpdk/DPDKStack.cc @@ -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) diff --git a/src/msg/async/dpdk/DPDKStack.h b/src/msg/async/dpdk/DPDKStack.h index 5bc8f3122a23..6953dce11ca2 100644 --- a/src/msg/async/dpdk/DPDKStack.h +++ b/src/msg/async/dpdk/DPDKStack.h @@ -38,7 +38,8 @@ template 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 DPDKServerSocketImpl::DPDKServerSocketImpl( - Protocol& proto, uint16_t port, const SocketOptions &opt) - : _listener(proto.listen(port)) {} + Protocol& proto, uint16_t port, const SocketOptions &opt, int type) + : ServerSocketImpl(type), _listener(proto.listen(port)) {} template int DPDKServerSocketImpl::accept(ConnectedSocket *s, const SocketOptions &options, entity_addr_t *out, Worker *w) { @@ -192,8 +193,10 @@ int DPDKServerSocketImpl::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> csi( new NativeConnectedSocketImpl(std::move(*c))); *s = ConnectedSocket(std::move(csi)); diff --git a/src/msg/async/dpdk/TCP-Stack.h b/src/msg/async/dpdk/TCP-Stack.h index 86872560c6ea..996ae93c0018 100644 --- a/src/msg/async/dpdk/TCP-Stack.h +++ b/src/msg/async/dpdk/TCP-Stack.h @@ -32,7 +32,7 @@ template class tcp; int tcpv4_listen(tcp& tcpv4, uint16_t port, const SocketOptions &opts, - ServerSocket *sa); + int type, ServerSocket *sa); int tcpv4_connect(tcp& tcpv4, const entity_addr_t &addr, ConnectedSocket *sa); diff --git a/src/msg/async/dpdk/TCP.cc b/src/msg/async/dpdk/TCP.cc index 3fd8341e7511..d215a4c105b5 100644 --- a/src/msg/async/dpdk/TCP.cc +++ b/src/msg/async/dpdk/TCP.cc @@ -153,9 +153,9 @@ bool ipv4_tcp::forward(forward_hash& out_hash_data, Packet& p, size_t off) } int tcpv4_listen(tcp& tcpv4, uint16_t port, const SocketOptions &opts, - ServerSocket *sock) + int type, ServerSocket *sock) { - auto p = new DPDKServerSocketImpl>(tcpv4, port, opts); + auto p = new DPDKServerSocketImpl>(tcpv4, port, opts, type); int r = p->listen(); if (r < 0) { delete p; diff --git a/src/msg/async/rdma/RDMAServerSocketImpl.cc b/src/msg/async/rdma/RDMAServerSocketImpl.cc index df1dfda94154..d87fdee58239 100644 --- a/src/msg/async/rdma/RDMAServerSocketImpl.cc +++ b/src/msg/async/rdma/RDMAServerSocketImpl.cc @@ -21,8 +21,12 @@ #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());