nfs4: let nfs4 use kernel utils for random numbers

This commit is contained in:
Pawel Dziepak 2013-04-11 04:28:14 +02:00
parent 5c455f803f
commit b56330de8e
4 changed files with 10 additions and 8 deletions

View File

@ -16,8 +16,9 @@
#include <unistd.h>
#include <AutoDeleter.h>
#include <util/kernel_cpp.h>
#include <net/dns_resolver.h>
#include <util/kernel_cpp.h>
#include <util/Random.h>
#define NFS4_PORT 2049
@ -655,7 +656,7 @@ Connection::Connect()
PeerAddress address(fPeerAddress.Family());
do {
port = rand() % (IPPORT_RESERVED - NFS_MIN_PORT);
port = get_random<uint16>() % (IPPORT_RESERVED - NFS_MIN_PORT);
port += NFS_MIN_PORT;
if (attempt == 9)

View File

@ -13,6 +13,7 @@
#include <AutoDeleter.h>
#include <lock.h>
#include <util/Random.h>
#include "Request.h"
#include "RootInode.h"
@ -32,9 +33,7 @@ FileSystem::FileSystem(const MountConfiguration& configuration)
fId(1),
fConfiguration(configuration)
{
fOpenOwner = rand();
fOpenOwner <<= 32;
fOpenOwner |= rand();
fOpenOwner = get_random<uint64>();
mutex_init(&fOpenOwnerLock, NULL);
mutex_init(&fOpenLock, NULL);

View File

@ -12,6 +12,7 @@
#include <stdlib.h>
#include <util/AutoLock.h>
#include <util/Random.h>
#include "RPCCallbackServer.h"
#include "RPCReply.h"
@ -83,7 +84,7 @@ Server::Server(Connection* connection, PeerAddress* address)
fPrivateData(NULL),
fCallback(NULL),
fRepairCount(0),
fXID(rand() << 1)
fXID(get_random<uint32>())
{
ASSERT(connection != NULL);
ASSERT(address != NULL);

View File

@ -12,6 +12,8 @@
#include <errno.h>
#include <string.h>
#include <util/Random.h>
#include "Cookie.h"
#include "OpenState.h"
#include "RPCCallback.h"
@ -659,8 +661,7 @@ RequestBuilder::SetClientID(RPC::Server* server)
return B_NO_MEMORY;
fRequest->Stream().AddUInt(OpSetClientID);
uint64 verifier = rand();
verifier = verifier << 32 | rand();
uint64 verifier = get_random<uint64>();
fRequest->Stream().AddUHyper(verifier);
status_t result = _GenerateClientId(fRequest->Stream(), server);