mirror of
https://github.com/facebook/sapling.git
synced 2024-10-05 14:28:17 +03:00
portmapper reply to getport
Summary: getport is the primary endpoint on the rpcbind/portmap server. NFS clients make a request on this endpoint to find the NFS RPC servers. In this diff we keep a mapping of RPC servers and respond to the getport request based on this mapping. Currently no rpc severs are registered, so we reply no port to all requests. Reviewed By: chadaustin Differential Revision: D44987893 fbshipit-source-id: 920171c6007b82609ae84fb7a9aff43d898e43dd
This commit is contained in:
parent
4ee4fa5e6b
commit
901f989bc7
@ -48,6 +48,19 @@ class RpcbinddServerProcessor final : public RpcServerProcessor {
|
|||||||
dump(folly::io::Cursor deser, folly::io::QueueAppender ser, uint32_t xid);
|
dump(folly::io::Cursor deser, folly::io::QueueAppender ser, uint32_t xid);
|
||||||
ImmediateFuture<folly::Unit>
|
ImmediateFuture<folly::Unit>
|
||||||
callit(folly::io::Cursor deser, folly::io::QueueAppender ser, uint32_t xid);
|
callit(folly::io::Cursor deser, folly::io::QueueAppender ser, uint32_t xid);
|
||||||
|
|
||||||
|
private:
|
||||||
|
typedef uint32_t RpcProtocolNumber;
|
||||||
|
typedef uint32_t RpcProtocolVersion;
|
||||||
|
typedef uint16_t PortNumber;
|
||||||
|
typedef std::pair<RpcProtocolNumber, RpcProtocolVersion> RpcIdentifier;
|
||||||
|
typedef std::map<RpcIdentifier, PortNumber> RpcMappings;
|
||||||
|
|
||||||
|
// contains the registered RPC services. Maps (server protocol number & server
|
||||||
|
// protocol version -> port. We assume all registered services are going to
|
||||||
|
// use TCP just because we only use TCP today. You can change that assumption,
|
||||||
|
// but you need to add the protocol to the key.
|
||||||
|
folly::Synchronized<RpcMappings> registeredServers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@ -111,10 +124,27 @@ ImmediateFuture<folly::Unit> RpcbinddServerProcessor::unset(
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImmediateFuture<folly::Unit> RpcbinddServerProcessor::getport(
|
ImmediateFuture<folly::Unit> RpcbinddServerProcessor::getport(
|
||||||
folly::io::Cursor /*deser*/,
|
folly::io::Cursor deser,
|
||||||
folly::io::QueueAppender ser,
|
folly::io::QueueAppender ser,
|
||||||
uint32_t xid) {
|
uint32_t xid) {
|
||||||
serializeReply(ser, accept_stat::PROC_UNAVAIL, xid);
|
serializeReply(ser, accept_stat::SUCCESS, xid);
|
||||||
|
|
||||||
|
auto args = XdrTrait<PortmapMapping2>::deserialize(deser);
|
||||||
|
XLOG(DBG7) << "prog: " << args.prog;
|
||||||
|
XLOG(DBG7) << "vers: " << args.vers;
|
||||||
|
XLOG(DBG7) << "protocol: " << args.prot;
|
||||||
|
if (args.prot == PortmapMapping2::kTcpProto) {
|
||||||
|
auto lockedServers = registeredServers_.rlock();
|
||||||
|
auto maybePort = lockedServers->find(std::make_pair<uint32_t, uint32_t>(
|
||||||
|
std::move(args.prog), std::move(args.vers)));
|
||||||
|
if (maybePort != lockedServers->end()) {
|
||||||
|
XLOG(DBG7) << "port: " << maybePort->second;
|
||||||
|
XdrTrait<uint32_t>::serialize(ser, maybePort->second);
|
||||||
|
return folly::unit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
XLOG(DBG7) << "port : none";
|
||||||
|
XdrTrait<uint32_t>::serialize(ser, 0);
|
||||||
return folly::unit;
|
return folly::unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user