Fix memset invocation in rx/event-t.c

The order of the parameters was swapped, which recent gcc complains
loudly about.

Change-Id: I2329ca3dd0eee81639731e78172621b580199024
Reviewed-on: http://gerrit.openafs.org/11451
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Add missing tests to tests/opr/.gitignore

dict-t and fmt-t were missing.

While here, sort the existing entries.

Change-Id: If62e0f9f93f4d51900cdd7747beede561861f51e
Reviewed-on: http://gerrit.openafs.org/11454
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Export heimdal's rand-fortuna PRNG to the kernel

Some systems (e.g., AIX, SGI, DFBSD, HPUX) do not supply a useful
implementation of osi_readRandom(), in some cases because the kernel
does not expose a random-number interface to kernel modules.  We want
real random numbers on all systems, because we want to use the for
setting the RX epoch and connection ID in the kernel.

Build hcrypto's rand-fortuna PRNG into the rand-kernel interface we expose,
and implement RAND_bytes using rand-fortuna when osi_ReadRandom()
is not useful.

Add stub routines to config.h as needed, and add a heim_threads.h
with the necessary locking for rand-fortuna.  The rand-fortuna algorithm
requires some measure of time's passage, so provide a stub gettimeofday()
with single-second resolution.  We use a single (global) mutex for the
hcrypto kernel code, so that we can statically declare an initializer to
be the address of that mutex.  Otherwise the locking is taken essentially
wholesale from rx_kmutex.

rand-fortuna requires the sha256 code for its hashing, and also
requires a stub rand-fortuna to satisfy linker symbol visibility.

Since the rand-fortuna code does not have any actual sources of entropy
available to it during its initialization routines, we must explicitly
seed the in-kernel rand-fortuna using entropy passed in from userland.
(Userland will always have at least /dev/random available, so the
userland hcrypto should always have usable entropy.)  Be sure to do so
early in the afsd startup sequence, before any daemons are started, so
that entropy is available to the core rx code for generating the epoch
and cid -- the rand-fortuna code will (erroneously) always claim that
it has startup entropy even though in this case it may not actually
have any entropy.  The rand-fortuna code does not consider itself
fully seeded until it has 128 bytes of entropy, so be sure to pass
more than that in from userspace.

It is preferrable to always build this code into the kernel, even on
systems when it is not going to be used, to help prevent bitrot.  This
also avoids the possibility of a new system being supported that would
attempt to use the rand-fortuna code but fail to supply any seed entropy,
which would not necessarily be readily apparent.

Change-Id: I614d2bd9ac52803ec3b9572cc694cd836c8427dd
Reviewed-on: http://gerrit.openafs.org/10840
Reviewed-by: D Brashear <shadow@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Move epoch and cid generation into the rx core

Now that we have hcrypto available everywhere, we can get real randomness
in the rx core (both uerspace and kernel), and thus can initialize the
RX epoch to a real random value when first initializing a host; there is
no need to rely on rxkad to produce randomness for this purpose.
Initialize a connection ID counter at the same time, and use that in
rx_NewConnection, also supplanting rxkad-specific logic.

The rxkad-specific logic is removed, and in particular there is no longer
a need to export rxkad_EpochWasSet to the rest of the world.
The code in afs_Daemon() to check whether the rxepoch was set can be
removed, as if the epoch is not set, rx initialization fails.

Add libafshcrypto to LIBS in the handful of places it hadn't crept already,
and likewise afshcrypto.lib in the NTMakefiles.

Change-Id: I1dd1015b29a600aaf72b6b4b36f8a17032453c97
Reviewed-on: http://gerrit.openafs.org/10841
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Garbage-collect afs_GCUserData's argument

We no longer need the ability to force all rxnull connections to be
reaped, as the epoch is set globally.  Change the prototype and
callers accordingly.

Change-Id: I0815fdd035c3dd9d56f72e43603f9c53f5cec79d
Reviewed-on: http://gerrit.openafs.org/10842
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Remove rx_SetEpoch, rx_SetConnectionEpoch, rx_SetConnectionId

The core RX code now manages the Epoch and CID; external callers
should not be modifying them.

Change-Id: Ia517205aa280b2a0bbd2568274be7fb010fba0bc
Reviewed-on: http://gerrit.openafs.org/10843
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Sort libtool symbol files

Some entropy had crept in.

Change-Id: I72ae9d16a3aa4b9b66bc8efcda46bdc35edf95c9
Reviewed-on: http://gerrit.openafs.org/11323
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Chas Williams - CONTRACTOR <chas@cmf.nrl.navy.mil>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: Prevent MDL leak on Cc*Mdl* failure

If CcMdlRead or CcPrepareMdlWrite fail, check the IoStatus.Information
field to see if any MDL pages have been locked.  If the Information
value is greater than zero, complete the Mdl operation to unlock the
pages.

Change-Id: Icb44e74e25b46c7976f3f418410364a90a723d91
Reviewed-on: http://gerrit.openafs.org/11442
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: cm_UpdateIFInfo consolidate syscfg_GetIFInfo calls

Add a new function cm_UpdateIFInfo() that consolidates all of the
syscfg_GetIFInfo() call functionality into a single rountine.  Replace
all of the existing call sites.

It is safe to call cm_UpdateIFInfo() without holding cm_syscfgLock
during afsd initialization because no other threads have been created.

Change-Id: Ifd4ca4f4f698014852a26d2c95a523c3b2cc851f
Reviewed-on: http://gerrit.openafs.org/11443
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: replace lana_OnlyLoopback() calls

lana_OnlyLoopback() relies upon Netbios over TCP being enabled but
Netbios over TCP is not officially supported on Vista and above.
Replace all lana_OnlyLoopback() calls with a test on the number of
network interfaces as computed by syscfg_GetIFInfo().   That list
excludes loopback interfaces.

Change-Id: I22d952f1487734ead02335108377bc404baa6024
Reviewed-on: http://gerrit.openafs.org/11444
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: introduce cm_MarkServerDown

Consolidate the operations necessary to mark a server down into a
new routine cm_MarkServerDown()

Change-Id: I9f70752498600046d677686c212c3adf3e810bde
Reviewed-on: http://gerrit.openafs.org/11445
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: No network, no probe

Modify cm_PingServer and cm_CheckServersMulti to avoid probing servers
when there are no network interfaces with which to do so.  Just mark
the servers down.

Change-Id: I5ba6c9813a28ec44b09dccd8f8c5ffc7e0c0ce10
Reviewed-on: http://gerrit.openafs.org/11446
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: power management suspend/resume changes

1. Call cm_UpdateIFInfo() for all power management events to force
   an update of the valid network interface count.

2. Ensure that regardless of which Suspend and Resume events are
   generated that the service only suspends once and resumes once.

Change-Id: If0c2fe5b6a18dd6b7ee01b511378cb78837efa3d
Reviewed-on: http://gerrit.openafs.org/11447
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: preserve prior vlserver list on dns failure

Do not destroy the existing vlserver list if the DNS resolver query
fails.  Continue using the prior vlserver values until a DNS response
is obtained.  This will result in repeated DNS queries and a delay
if there is continued failure, but it will permit VL RPCs to continue
to be issued in the face of a DNS failure or misconfiguration.

Change-Id: Icac97c2bebdef744cc316225c1a6b1888ceb2f6e
Reviewed-on: http://gerrit.openafs.org/11457
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: !overwrite IOMgr populated FileInfo data

I/O Manager will populate the FILE_ACCESS_INFORMATION,
FILE_MODE_INFORMATION, and FILE_ALIGNMENT_INFORMATION portions of
a FILE_ALL_INFORMATION structure prior to forwarding a FileAllInformation
FileInfo query to the file system.  There is no need for the file system
to duplicate the effort.

Change-Id: Iaa7f1de95c6b7e42bdc326cc3f4bfe8596add949
Reviewed-on: http://gerrit.openafs.org/11478
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: FileInfo too small INFO_LENGTH_MISMATCH

The FileAllInformation query is initially processed by the IO Manager
and when the IO Manager is passed a buffer that is too small to hold
the File Information structure it returns STATUS_INFO_LENGTH_MISMATCH.
Previously the afs redirector returned STATUS_BUFFER_TOO_SMALL in this
case.  Instead follow IO Manager's lead.

Change-Id: I74d1b68d37fb9e79cae79408eac1f5dc4dd05e1e
Reviewed-on: http://gerrit.openafs.org/11487
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: FilePhysicalNameInfo query AFS prefix

In response to the FilePhysicalNameInformation query the AFS redirector
failed to include the server name in the response.  Since the constructed
name is the same as the FileNameInformation query create a helper function
AFSGetFullFileName() to populate the file name into the provided buffer
and use it to satisfy both queries.

Change-Id: I78eef49a9902341c751d942a395921bb687c503b
Reviewed-on: http://gerrit.openafs.org/11488
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: Remove trailing slash on non-root directories

For the FileNameInformation and FilePhysicalNameInformation queries
a trailing slash is required for the \\server\share\ path but is
not required for directories below the root.

Change-Id: Iabbe7daed4f60ad995c04c70dfb2992af095281e
Reviewed-on: http://gerrit.openafs.org/11489
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: report AllocationSize in 1KB increments

Windows expects storage to be allocated in increments of some
block size.  The AFS servers allocate in 1K units so lets report
that to Windows.

Change-Id: I64ad1844339357733933cd9e360551fdcd450146
Reviewed-on: http://gerrit.openafs.org/11490
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Windows: Use the allocation size from the service

The prior patchset modified the service AllocationSize return value
to count the number of 1KB units.  Use the value from the service
without modification.  This corrects an inconsistency in the
FileStandardInformation response.

Change-Id: I9a5f0a4f43aa12de903875b6ed4c5493e37b0163
Reviewed-on: http://gerrit.openafs.org/11491
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>