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);
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());
*sock = ServerSocket(
std::unique_ptr<PosixServerSocketImpl>(
- new PosixServerSocketImpl(net, listen_sd)));
+ new PosixServerSocketImpl(net, listen_sd, sa.get_type())));
return 0;
}
/// \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;
// _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)
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();
}
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) {
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));
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);
}
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;
#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)
{
}
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());