openafs.git
2 years agobozo: Log a warning if the bosserver is not started in restricted mode 62/14762/4
Michael Meffie [Thu, 19 Aug 2021 15:47:04 +0000]
bozo: Log a warning if the bosserver is not started in restricted mode

Log a warning to the BosLog when the bosserver is not started in
restricted mode to encourage admins to enable restricted mode.

Also, log a notice when restricted mode is enabled to reassure admins
restricted mode is enabled on start up.

Change-Id: I2cbe0b95f44476d21215204f5ef186b07bba9b69
Reviewed-on: https://gerrit.openafs.org/14762
Reviewed-by: Stephan Wiesand <stephan.wiesand@desy.de>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agobozo: Fix problems found by static analysis 76/14676/7
Cheyenne Wills [Tue, 31 Aug 2021 14:48:33 +0000]
bozo: Fix problems found by static analysis

Several static analysis tools have identified various problems:
 - files left open from early exits/returns       (infer)
 - missing checks to ensure *alloc was successful (infer)
 - possible memory leaks                          (scan-build, cppcheck)

To resolve the above problems:
 - close files before exiting/returning
 - add checks to ensure *alloc was successful before using the memory
 - fix possible memory leaks by freeing memory

This commit is a reorganization of commits developed by Pat Riehecky,
who ran the static analysis tools and developed the fixes.

Change-Id: Iabebf46d2d1d8bb3bd2378cf2d1e7e4b94706bfd
Reviewed-on: https://gerrit.openafs.org/14676
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorxdebug: Remove rxdumptrace.c 48/14748/2
Andrew Deason [Sun, 8 Aug 2021 20:13:14 +0000]
rxdebug: Remove rxdumptrace.c

Ever since it was introduced in commit 8bc58a3d
(macos-10-6-support-20090216), rxdumptrace.c appears to have been
unused. While we do build a binary called rxdumptrace, we build it
from src/rx/rx_trace.c, not from rxdumptrace.c (which appears to be a
copy of the relevant portions of rx_trace.c).

Also remove rxdumptrace from src/rx/.gitignore, since the binary is
built in src/rxdebug/, not in src/rx/. While we're here, remove the
other entries in src/rx/.gitignore (rxperf and rxdebug), since those
are also built in different directories.

Change-Id: Ide816979168dcf70358f39db035ce16ef6c1dd17
Reviewed-on: https://gerrit.openafs.org/14748
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Remove check/test/tests subdir targets 36/14636/3
Andrew Deason [Mon, 7 Jun 2021 21:44:38 +0000]
tests: Remove check/test/tests subdir targets

Since commit a62de618 (Build util tests properly with make check),
running 'make check' in tests/ also runs 'make check' in each of the
tests subdirectories, which builds the tests in that dir. (And the
same goes for 'make test' and 'make tests'.)

This does ensure that the tests are built before we run them, but it's
a bit strange to build the tests under 'make check', a target that
usually runs tests.

We do this in the top-level tests dir to make sure that the tests are
built, but this purpose is served by the existing 'make all' target.
So to reduce some duplication of logic, and reduce the number of
targets the subdirs need to implement, just have 'make check' depend
on 'make all', so we know the tests are built when we go to run them.

Change-Id: I2fcbe88daeeae94cd7ef7a4a8326c4b56fadee5a
Reviewed-on: https://gerrit.openafs.org/14636
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: refactor PNewStatMount and PFlushMount 41/14541/8
Marcio Barbosa [Tue, 17 Aug 2021 19:52:11 +0000]
afs: refactor PNewStatMount and PFlushMount

Both functions use the same logic to find a name in a given directory.
To avoid repetition, move this logic to a separate function called
afs_LookupName().

No functional change is incurred by this commit.

Change-Id: Ic5da09091e7050dd5f91adc7a413328edfb8292d
Reviewed-on: https://gerrit.openafs.org/14541
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Generalize temp dir management 32/14632/4
Andrew Deason [Thu, 2 Jul 2020 02:18:04 +0000]
tests: Generalize temp dir management

Currently, afstest_BuildTestConfig calls afstest_mkdtemp (our thin
wrapper around mkdtemp) to create its temporary config dir. We may
want to make new tests, though, that create a temp dir for other
purposes. To make that easier, move a little more code into
afstest_mkdtemp, so the caller doesn't need to construct the template.

To allow callers to clean up such temporary dirs, change
afstest_UnlinkTestConfig into a more general function,
afstest_rmdtemp. Allow this new function to remove all files in a dir,
not just files one-level-deep. To avoid needing to write our own
traversal and removal logic, just run 'rm -rf' via a new function,
afstest_systemlp().

Move these temp dir-related functions from config.c into files.c,
since they are no longer specific to config dirs.

Change-Id: I16750a2f30e98c9ca2e14dfb7d3fc9bc5d456e8d
Reviewed-on: https://gerrit.openafs.org/14632
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce is_command() 40/14040/12
Andrew Deason [Tue, 21 Jan 2020 21:40:12 +0000]
tests: Introduce is_command()

Add a new function (is_command), to help implementing tests that
involve running a command. This works like is_string(), except the
string value we compare against is the output of the provided command,
and we also check the exit code of the command.

Convert the existing execl() call in volser/vos-t to use this new
function.

Change-Id: I4a75b1a0333e608da6a6cd69838350116a2503a9
Reviewed-on: https://gerrit.openafs.org/14040
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce afstest_*_path() 19/14319/9
Andrew Deason [Fri, 3 Jul 2020 00:16:40 +0000]
tests: Introduce afstest_*_path()

Currently, several of our tests contain logic to locate files (via
srcdir or objdir), based on the C_TAP_SOURCE/BUILD environment
variables. This logic is duplicated in several places, so consolidate
the code into a couple of new functions: afstest_src_path and
afstest_obj_path. Update all callers to use these new functions.

Change-Id: I67a5e5d7f8fd7a1edb55a45e52d877ac41f9a2ea
Reviewed-on: https://gerrit.openafs.org/14319
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce afstest_asprintf 20/14620/4
Andrew Deason [Wed, 14 Apr 2021 21:09:37 +0000]
tests: Introduce afstest_asprintf

Add a thin wrapper around asprintf, called afstest_asprintf (and
afstest_vasprintf), which does its own error checking. This just helps
makes tests a little less cluttered when needing to construct strings.

Adapt all asprintf callers in 'tests' to use the wrapper.

Change-Id: I6c4ae5b72af827e2c4c66ecfc57f152855b1d401
Reviewed-on: https://gerrit.openafs.org/14620
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Introduce libafstest_common 18/14318/6
Andrew Deason [Thu, 2 Jul 2020 03:42:37 +0000]
tests: Introduce libafstest_common

Currently, a few tests use the code in tests/common/ by linking
individual object files in there in addition to the test code (e.g.
linking ../common/config.o along with superuser-t.o).

This convention makes it very obnoxious to move code around in
tests/common/, since any users need to update their link lines. It
also makes it difficult for code in tests/common/ to make use of
functions in other tests/common/ files.

To fix this, just build all of the objects in tests/common/ into a
convenience library, called libafstest_common, and link the relevant
tests against that. Link a few requisite libraries (roken, rfc3961) in
libafstest_common, so each individual test doesn't need to link
against them.

Also link the TAP library itself in libafstest_common, so tests don't
have to explicitly link against it separately. To do this, convert it
into a libtool library, libafstest_tap.la.

Change-Id: I9c031c164efee20201336edcbfaff429e1d231b7
Reviewed-on: https://gerrit.openafs.org/14318
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoviced: Fix minor log message mistakes 24/14724/3
Mark Vitale [Mon, 22 Jun 2020 01:44:17 +0000]
viced: Fix minor log message mistakes

Fix a few minor mistakes/typos that have crept up in viced over time:

- In PrintCallBackStats, struct FEs and struct CBs are 64 bytes, not
  16 bytes. Show the actual size of the structs.

- A log message in cb_stateDiskEntryToFE is missing the trailing
  newline.

- In cb_stateVerifyHCBList, a log message mentions the non-existent
  cb_stateVerifyFCBList (instead of cb_stateVerifyHCBList)

Change-Id: I1146acae84d11980b6005cede9bb8bb53c54c70f
Reviewed-on: https://gerrit.openafs.org/14724
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: compare RX_ACK_TYPE_ACK as a bit-field 65/14465/5
Jeffrey Altman [Fri, 2 Oct 2020 23:51:06 +0000]
rx: compare RX_ACK_TYPE_ACK as a bit-field

The rx_ackPacket.acks array (the SACK table) consists of up to 255
octets.  Each octet stores either the value zero (RX_ACK_TYPE_NACK)
or one (RX_ACK_TYPE_ACK).  Effectively only bit-zero of each octet
is used.

The rx_ackPacket.acks array cannot be enlarged but one possible
method of encoding the ACK/NACK state for packets when the
window size is greater than 255 is to use bits 1-7 of each
octet.

This change alters the test for ACK vs NACK to be a bit comparison
instead of a equality comparison.  This change permits RX to be
compatible with any future use of bits 1-7.

No peer that treats the SACK table as bytes can ever send more
than 255 packets regardless of the advertised receive window.
Therefore, existing peers will never receive a SACK table with
more than 255 packets worth of bits.

Change-Id: I4dfcdc9ea18e060eeb257832297f557b7109e93a
Reviewed-on: https://gerrit.openafs.org/14465
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoLINUX: defer afs_remunlink when current->fs==NULL 91/14691/6
Yadavendra Yadav [Wed, 7 Jul 2021 16:32:36 +0000]
LINUX: defer afs_remunlink when current->fs==NULL

afs_remunlink is called to delete a file on the fileserver after it
has been silly-renamed (due to being unlinked while the file is open).
Sometimes current->fs is NULL when this happens, typically when the
process is shutting down, after current->fs has been freed and file
handles are getting released. During afs_remunlink, we need to
interact with our cache files, and so we call dentry_open, which calls
security_file_open, which calls into the configured LSM for security
checks. Certain LSMs (e.g. Crowdstrike Falcon) will panic the kernel
in this situation if current->fs is NULL.

There's no way to skip the LSM hooks, or to flag to the LSM that we're
making an in-kernel VFS call, so the only way to avoid these panics is
to do our I/O in another thread. Fortunately, we already have a way to
defer afs_remunlink calls to a background daemon (CUnlinkedDel), since
we already do this in some cases (when someone else is holding
afs_xvcache or afs_xdcache).

So, to avoid the panic in the above scenario, defer calls to
afs_remunlink to a background daemon using CUnlinkedDel when
current->fs is NULL, and we're using a disk cache.

More details on this issue is discussed at following thread:
https://lists.openafs.org/pipermail/openafs-info/2021-March/043073.html

Change-Id: I1ee83d088a9b661d2974ce24b36bfd9f6ea4e7e9
Reviewed-on: https://gerrit.openafs.org/14691
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Jonathan Billings <jsbillings@jsbillings.org>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

2 years agoAIX: Fix undefined symbols 07/14707/3
Andrew Deason [Fri, 16 Jul 2021 00:59:47 +0000]
AIX: Fix undefined symbols

Various pieces of our code try to use symbols in our internal
libraries that are not exported in the respective .sym file. On AIX,
this causes the following build failures:

ld: 0711-317 ERROR: Undefined symbol: .ubik_CallRock
ld: 0711-317 ERROR: Undefined symbol: DISK_function_names
ld: 0711-317 ERROR: Undefined symbol: VOTE_function_names
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:45: afscp] Error 8
make[4]: Leaving directory '/.../src/libadmin/test'

ld: 0711-317 ERROR: Undefined symbol: PR_function_names
ld: 0711-317 ERROR: Undefined symbol: KAA_function_names
ld: 0711-317 ERROR: Undefined symbol: KAT_function_names
ld: 0711-317 ERROR: Undefined symbol: KAM_function_names
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:117: rxstat_get_peer] Error 8
make[4]: Leaving directory '/.../src/libadmin/samples'

ld: 0711-317 ERROR: Undefined symbol: .osi_audit_cmd_Options
ld: 0711-317 ERROR: Undefined symbol: .osi_audit_open
ld: 0711-317 ERROR: Undefined symbol: .afsconf_SuperIdentity
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:71: butc] Error 8
make[3]: Leaving directory '/.../src/tbutc'

ld: 0711-317 ERROR: Undefined symbol: .pr_Initialize2
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:111: pts] Error 8
make[3]: Leaving directory '/.../src/tptserver'

ld: 0711-317 ERROR: Undefined symbol: .AFSVolListPartitions
ld: 0711-317 ERROR: Undefined symbol: .AFSVolXListPartitions
ld: 0711-317 ERROR: Undefined symbol: .RXAFS_GetStatistics64
ld: 0711-317 ERROR: Undefined symbol: .AFSVolPartitionInfo64
ld: 0711-317 ERROR: Undefined symbol: .AFSVolPartitionInfo
ld: 0711-317 ERROR: Undefined symbol: .RXAFS_GetStatistics
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:65: fsprobe_test] Error 8
make[3]: Leaving directory '/.../src/fsprobe'

ld: 0711-317 ERROR: Undefined symbol: fsprobe_Results
ld: 0711-317 ERROR: Undefined symbol: gtxframe_exitValue
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:45: scout] Error 8
make[3]: Leaving directory '/.../src/scout'

ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_toString
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_freeString
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:50: check_sysid] Error 8
make[3]: Leaving directory '/.../src/viced'

ld: 0711-317 ERROR: Undefined symbol: .GetLogLevel
make[3]: *** [Makefile:130: fileserver] Error 8
make[3]: Leaving directory '/.../src/viced'

ld: 0711-317 ERROR: Undefined symbol: .GetLogDest
ld: 0711-317 ERROR: Undefined symbol: .GetLogFilename
ld: 0711-317 ERROR: Undefined symbol: .CloseLog
make[3]: *** [Makefile:166: salvageserver] Error 8
make[3]: Leaving directory '/.../src/tsalvaged'

ld: 0711-317 ERROR: Undefined symbol: .rxkad_StringToLevel
ld: 0711-317 ERROR: Undefined symbol: .FilepathNormalize
ld: 0711-317 ERROR: Undefined symbol: .ConstructLocalPath
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:32: upserver] Error 8
make[3]: Leaving directory '/.../src/update'

ld: 0711-317 ERROR: Undefined symbol: xstat_fs_Results
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:77: xstat_fs_test] Error 8
make[3]: Leaving directory '/.../src/xstat'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteKeyBySubType
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteKeyByType
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[3]: *** [Makefile:35: asetkey] Error 8
make[3]: Leaving directory '/.../src/aklog'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_FindService
ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddKey
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetLatestKeyByTypes
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:19: authcon-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_IsSuperIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_AddIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetNthUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetNthIdentity
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteUser
ld: 0711-317 ERROR: Undefined symbol: .afsconf_DeleteIdentity
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:25: superuser-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeys
ld: 0711-317 ERROR: Undefined symbol: .rx_opaque_new
ld: 0711-317 ERROR: Undefined symbol: .rx_opaque_free
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeyByTypes
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetKeysByType
ld: 0711-317 ERROR: Undefined symbol: .afsconf_PutTypedKeyList
ld: 0711-317 ERROR: Undefined symbol: .afsconf_GetLatestKeysByType
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[4]: *** [Makefile:31: keys-t] Error 8
make[4]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: ._afsconf_Touch
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:34: realms-t] Error 8
make[1]: Leaving directory '/.../tests/auth'

ld: 0711-317 ERROR: Undefined symbol: .opr_cache_get
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_put
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_init
ld: 0711-317 ERROR: Undefined symbol: .opr_cache_free
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:16: cache-t] Error 8
make[1]: Leaving directory '/.../tests/opr'

ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_isNil
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_equal
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_hash
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_fromString
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_create
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_unpack
ld: 0711-317 ERROR: Undefined symbol: .opr_uuid_pack
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:37: uuid-t] Error 8
make[1]: Leaving directory '/.../tests/opr'

ld: 0711-317 ERROR: Undefined symbol: .rxevent_Init
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Post
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Cancel
ld: 0711-317 ERROR: Undefined symbol: .rxevent_RaiseEvents
ld: 0711-317 ERROR: Undefined symbol: .rxevent_Put
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
make[1]: *** [Makefile:18: event-t] Error 8
make[1]: Leaving directory '/.../tests/rx'

To fix these, export the relevant symbols from the library's .sym
file.

Change-Id: I969e7c99610d5c29c81f6d73c52dd5499a1152fd
Reviewed-on: https://gerrit.openafs.org/14707
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorxgen: rename list -> rxgen_list 02/14702/3
Andrew Deason [Thu, 15 Jul 2021 23:27:34 +0000]
rxgen: rename list -> rxgen_list

Our 'struct list' collides with a 'struct list' defined in
/usr/include/grp.h on AIX (at least on AIX 7.2). This is a very
generic structure name, so rename it to rxgen_list to avoid issues
like this.

Change-Id: Ic6d3a1fcde5e7f8a1ae57b974f711fb844f29f3f
Reviewed-on: https://gerrit.openafs.org/14702
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovol: Introduce and use FDH_BLOCKSIZE 62/14662/4
Andrew Deason [Wed, 3 Jun 2020 20:53:48 +0000]
vol: Introduce and use FDH_BLOCKSIZE

A couple of places in src/volser currently have some logic to get the
size and blocksize of a file. The existing logic is nontrivial due to
platform-specific quirks, and ignores afs_fstat errors.

To fix these issue and consolidate the code into one place, introduce
a new function, FDH_BLOCKSIZE, which gets the file size and blksize.
Update the places in src/volser to use the new function.

Change-Id: I4daeec84c8fdb5756a8d6a7f477d0045a19a8fe9
Reviewed-on: https://gerrit.openafs.org/14662
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotsm41: Fix libs for AIX 7.2 03/14703/3
Andrew Deason [Fri, 16 Jul 2021 19:02:07 +0000]
tsm41: Fix libs for AIX 7.2

AIX 7.2 doesn't seem to have libcsys, netinet.exp, sockets.exp, or
statcmd.exp available. To allow for our IMPORTS and LDFLAGS to change
depending on the AIX version, introduce the autoconf vars TSM_IMPORTS
and TSM_LIBS, which do not contain the missing libs on AIX 7.2, so we
can build on AIX 7.2.

Change-Id: I95feb22f8e2b35948d2024d5c29b917d064f30f3
Reviewed-on: https://gerrit.openafs.org/14703
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoAIX: Add buildsystem support for AIX 7.2 01/14701/2
Andrew Deason [Thu, 15 Jul 2021 22:53:43 +0000]
AIX: Add buildsystem support for AIX 7.2

Change-Id: Iae2523c333e5180c029ca205cf3f0b83a6839dd5
Reviewed-on: https://gerrit.openafs.org/14701
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agotests: Avoid WTERMSIG($?) in rx/perf-t 06/14706/2
Andrew Deason [Mon, 19 Jul 2021 18:48:01 +0000]
tests: Avoid WTERMSIG($?) in rx/perf-t

Currently, tests/rx/perf-t calls functions like WIFSIGNALED and
WTERMSIG on $?. However, functions like WTERMSIG expect the native
exit status code (that is, ${^CHILD_ERROR_NATIVE}). The $? var (aka
$CHILD_ERROR), is a synthetic value calculated by perl that stores the
term sig in the lowest 7 bits, and the exit code in the second-lowest
8 bits.

For most modern platforms, these two values tend to be the same. But
on modern AIX (and some other weird platforms, like VMS and BeOS), the
exit status integer is encoded differently. On AIX specifically, the
term sig is in the third-lowest 8 bits, so a process exiting on signal
15 would result in an exit status (${^CHILD_ERROR_NATIVE}) of 0xf000f,
but $? would be just 0xf. Calling WTERMSIG on 0xf000f returns 0xf, but
calling WTERMSIG on 0xf returns 0x0.

All of this means that running rx/perf-t causes the final test to fail
with "Server died with signal 0" (even when the process was killed by
signal 15), which is rather confusing.

To fix this, call WTERMSIG et al with ${^CHILD_ERROR_NATIVE} instead
of $?. Create a local var so we don't need to spell out
${^CHILD_ERROR_NATIVE} so many times.

Change-Id: I3c27642fcaf17c320a94caf57d3665d4b6a4a76e
Reviewed-on: https://gerrit.openafs.org/14706
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoopr: Avoid sigwait on SIGWAITING 05/14705/2
Andrew Deason [Mon, 19 Jul 2021 04:05:38 +0000]
opr: Avoid sigwait on SIGWAITING

On AIX, calling sigwait() on a sigset containing SIGWAITING (or
SIGKILL or SIGSTOP), causes sigwait to return with an EINVAL error.
Currently, signalHandler() calls sigwait() with SIGWAITING, because
SIGWAITING is in the sigset returned by softsigSignalSet(). And so,
sigwait() returns EINVAL, and our opr_Verify in signalHandler() fails,
causing a crash.

To avoid this, remove SIGWAITING from the sigset in
softsigSignalSet(). This is AIX-specific, since the SIGWAITING signal
is AIX-specific.

Change-Id: I42539d859212605e6b1aaeb6a5eecb0ad034cea5
Reviewed-on: https://gerrit.openafs.org/14705
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Add missing va_end in cmd/command-t 04/14704/2
Andrew Deason [Mon, 19 Jul 2021 01:55:57 +0000]
tests: Add missing va_end in cmd/command-t

Every va_start call is supposed to be paired with a matching va_end
call, but 'checkList' is missing any call to va_end. This doesn't
currently seem to cause any visible problems, but add the matching
va_end to avoid potential future issues.

Change-Id: I569618823f39f4da5b1787cc49c5509d8ea37528
Reviewed-on: https://gerrit.openafs.org/14704
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoCleanup usage of LINUX_VERSION_CODE for older kernels 89/14389/14
Cheyenne Wills [Thu, 17 Dec 2020 02:48:46 +0000]
Cleanup usage of LINUX_VERSION_CODE for older kernels

2.6.18 is the minimum supported linux kernel level. There are
preprocessor checks for specific kernel versions that predate 2.6.18.

Refactor the use of the LINUX_VERSION_CODE that checks for kernel
versions older than 2.6.18.

In addition, there are a couple of locations where the kernel version
is checked with an additional test to see if module_param or
module_param_array are defined.  These checks are used to determine
whether to use the macros module_param/module_param_array or to use
the macro MODULE_PARM. The macros module_param and module_param_array
were present in Linux prior to 2.6.12.  The macro MODULE_PARM was marked
as deprecated prior to 2.6.12 and removed in Linux 2.6.17 (8d3b33f67fd
'[PATCH] Remove MODULE_PARM').

Remove the preprocessor checks for module_param/module_param_array and
remove the use of MODULE_PARM.

The updates should have no functional changes.

Change-Id: I1dc5dca1252abfc865917757989df235c75059a6
Reviewed-on: https://gerrit.openafs.org/14389
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoCleanup AFS_*LINUX_ENV usage 88/14388/14
Cheyenne Wills [Fri, 19 Feb 2021 01:38:30 +0000]
Cleanup AFS_*LINUX_ENV usage

Commit 6329a523f6305541871bc3d1694065e7b17abe77 changed all
occurrences of AFS_*LINUXnn_ENV to AFS_*LINUX_ENV, but did not perform
any refactoring of the use of these variables.

This commit completes the task by refactoring the preprocessor
conditionals that involved removing dead code or collapsing statements.

The updates should have no functional changes.

Change-Id: I10fbefb7c862de2ec35ab77cafa2391e6e59f388
Reviewed-on: https://gerrit.openafs.org/14388
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoChange AFS*_LINUXnn_ENV to AFS*_LINUX_ENV 87/14387/12
Cheyenne Wills [Thu, 17 Jun 2021 18:01:34 +0000]
Change AFS*_LINUXnn_ENV to AFS*_LINUX_ENV

The minimum Linux kernel that is now supported is linux-2.6.18.  The
Linux versioned preprocessor macros AFS_*LINUXnn_ENV are no longer
needed to distinguish the different levels of Linux and can be merged
into just a single set of macros.

Perform a global change of _LINUX\d+_ENV to _LINUX_ENV. e.g.
   AFS_LINUX24_ENV       -> AFS_LINUX_ENV
   AFS_USR_LINUX24_ENV   -> AFS_USR_LINUX_ENV
   AFS_AMD64_LINUX20_ENV -> AFS_AMD64_LINUX_ENV

Replace the multiple definitions for the versioned 'AFS*_LINUXnn_ENV'
with just single non-version definitions 'AFS*_LINUX_ENV'.

Apart from replacing the now-redundant #define directives and tidying up
a few comments at the close of a preprocessor block to match their
current form, this commit was done using a mechanical change of the
variable names and did not reduce preprocessor statements that could now
be combined or eliminated.  Nor does this commit remove dead code.  A
follow-up commit (Cleanup AFS_*LINUX_ENV usage) will handle these
changes.

The updates should have no functional changes.

Change-Id: I71e32ca9818d28f82b4f23679868d1b9a62c44bd
Reviewed-on: https://gerrit.openafs.org/14387
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofs: Avoid unnecessary cell DNS lookups 40/13540/7
Andrew Deason [Thu, 4 Apr 2019 20:18:57 +0000]
fs: Avoid unnecessary cell DNS lookups

Currently, many routines in 'fs' cause afsconf_GetCellInfo to be
called for the given cell, which causes an AFSDB/SRV lookup for the
given cell if the cell has no dbservers specified in the local
CellServDB. Sites often define such CellServDB records to indicate
that the given cell exists, but the dbserver IPs should only be looked
up via DNS.

However, 'fs' is only calling afsconf_GetCellInfo in order to
canonicalize the cell name (we're allowed to give an abbreviated name
for a cell on the command line if the abbreviation is unambiguous, but
we want to give the full name to the kernel). We don't care about the
other cell info at all, so triggering a DNS lookup is completely
unnecessary.

If our DNS server is not responding, e.g. because we've lost network
access entirely, this causes the relevant 'fs' commands to fail,
possibly after a long delay. Some fs commands such as 'fs setcell' are
often run during client startup, and can still otherwise run fine
without network access, and so such failures are unnecessary.

To fix this, we introduce a new function, called afsconf_GetCellName,
which only returns the full name for a cell, and does not require a
DNS lookup for such "empty" cells in the local CellServDB. For all
code paths in 'fs' that just need the cell name (which is all of them
besides 'fs mkmount'), use this new function.

Change-Id: I45eb1bdc6ba3e3b4653be2306dcbf79c1015724c
Reviewed-on: https://gerrit.openafs.org/13540
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibadmin: Be sure to free the server list in ListCellsRPC 90/14690/2
Michael Meffie [Fri, 2 Jul 2021 00:14:12 +0000]
libadmin: Be sure to free the server list in ListCellsRPC

Commit 0d6b9defb36cb94f3d34b058f00055e9e99d85fc added a check to avoid
overrunning a buffer when the cell name returned by RXAFSCB_GetCellServDB
is too large for the libadmin buffer, but in that case missed freeing
the server list returned in the same rpc.

Move the xdr_free() of the server list under the cleanup label so the
server list returned by the RPC will always be freed.

Thanks to Mark Vitale for finding this bug.

Change-Id: I4c7228f8c8d48e267f6fbb01cb89fdf5232de97e
Reviewed-on: https://gerrit.openafs.org/14690
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoDARWIN: correct size of fstrace ICL_TYPE_LONG and ICL_TYPE_POINTER 58/14558/4
Mark Vitale [Wed, 10 Mar 2021 04:12:50 +0000]
DARWIN: correct size of fstrace ICL_TYPE_LONG and ICL_TYPE_POINTER

Commit 248da50aa56f19bdc8b2b322f5e17b3d2a363dce 'icl 64 bit platform
rationalization' introduced support for 64-bit ICL_TYPE_POINTER and
ICL_TYPE_LONG for fstrace running on DARWIN kernels.  However, it
neglected to make the matching change in the fstrace utility itself,
which reads and reports these trace entries.  The result is that all
fstrace records which contain 64-bit pointers or longs are misreported
as 32-bit values.  Furthermore, any subsequent values in the same
fstrace record are also misreported because the offsets are now
incorrect.

Move the definition of ICL_LONG from afs_icl.c to icl.h so fstrace.c may
share the ICL_LONG logic and value.

Modify fstrace to use logic similar to the recording logic in afs_icl.c
so that the correct size and offsets are maintained while decoding the
contents of each fstrace record.

We can use the build-time value of ICL_LONG (rather than the runtime
value of afs_sizeofLong) because the difference only matters for SGI62
32-bit kernels.  It is unknown whether the existing code works correctly
for SGI62 32-bit mode, but this commit should not affect that support
either way.

Change-Id: I240f76fed4618822b774451c5184b1160f17221d
Reviewed-on: https://gerrit.openafs.org/14558
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoopr: Allow softsig handlers for SIGFPE 80/14080/6
Andrew Deason [Fri, 21 Feb 2020 20:49:56 +0000]
opr: Allow softsig handlers for SIGFPE

SIGFPE is normally a synchronous signal, which would not be handled by
opr softsig. However, bosserver uses SIGFPE as an asynchronous signal
to modify the local restricted mode. So allow SIGFPE in softsig
handlers, so bosserver can use softsig.

Change-Id: I413edbed967babb3e60c6fa97f89b40b8d7b3ad7
Reviewed-on: https://gerrit.openafs.org/14080
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

2 years agoopr: Assert opr_cv_timedwait return codes 79/14079/6
Andrew Deason [Fri, 21 Feb 2020 15:49:09 +0000]
opr: Assert opr_cv_timedwait return codes

Almost all of our opr locking primitives assert that they did not
receive an error from pthreads. opr_cv_timedwait is the exception to
this, since it needs to return two possible codes that aren't
internal failures: 0 and ETIMEDOUT. As a result, most callers assert
that our returned code is one of these two values.

To make opr_cv_timedwait act more like our other locking primitives,
removing the need to add opr_Assert()s everywhere, change
opr_cv_timedwait to check that the returned code is 0 or ETIMEDOUT,
and remove the relevant asserts from its callers.

Change-Id: Ie9a62f2edb23969d66e4ed821af37077bc6400c4
Reviewed-on: https://gerrit.openafs.org/14079
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>

2 years agovol: Use FDH_SIZE more consistently 57/14657/2
Andrew Deason [Sun, 31 May 2020 23:20:04 +0000]
vol: Use FDH_SIZE more consistently

Several callers use OS_SIZE(fdP->fd_fd) instead of just calling
FDH_SIZE(fdP). Right now these calls are equivalent, but change all of
these callers to use FDH_SIZE, to make it easier to possibly change
the behavior of FDH_SIZE in the future.

Change-Id: If846c160c71f11935de8c0e4634afa2c7f7ee53f
Reviewed-on: https://gerrit.openafs.org/14657
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agovol: Blank fake linkHandles 56/14656/2
Andrew Deason [Sat, 17 Feb 2018 22:57:12 +0000]
vol: Blank fake linkHandles

A couple of places in namei_ops.c use "fake" linkHandle FdHandle_t's.
Make sure these are initialized, so we don't accidentally use
uninitialized fields in the FdHandle_t.

Currently, the code never uses any fields that are not explicitly set
in this same code path, but this seems rather fragile, and future
commits may change the fields in an FdHandle_t.

Change-Id: I9372f03a4d3b68afd3ab24a27ae669cba92e0abe
Reviewed-on: https://gerrit.openafs.org/14656
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agofstrace: add dump -debug option 57/14557/3
Mark Vitale [Tue, 9 Mar 2021 22:20:22 +0000]
fstrace: add dump -debug option

As a debugging aid, add a -debug option to the dump subcommand to
display each trace record in raw hex format as well as the normal
decoded format.

Change-Id: I80dd675a07e048e25749a9afb584515effcbc08a
Reviewed-on: https://gerrit.openafs.org/14557
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Free pioctlToken in extractPioctlToken 51/14651/4
Andrew Deason [Thu, 17 Jun 2021 22:15:13 +0000]
afs: Free pioctlToken in extractPioctlToken

Ever since it was introduced in commit 5ec5ad5 (New GetToken pioctl),
extractPioctlToken has incorrectly freed pioctlToken by passing
'&pioctlToken' to xdr_free (instead of 'pioctlToken').

This causes xdr_ktc_tokenUnion to interpret &pioctlToken (which is a
struct ktc_tokenUnion **) as a struct ktc_tokenUnion *. This doesn't
cause any corruption or panics, since ktc_tokenUnion doesn't contain
any freeable fields unless its at_type is 2 (AFSTOKEN_UNION_KAD). So
as long as the bogus 'at_type' from the misinterpreted pointer is not 2,
the xdr_free call will just not free anything (and return an error,
which we ignore).

If the bogus at_type is 2, this would probably cause some memory
corruption or other nastiness. For this to happen on 32-bit systems,
the value of the 'pioctlToken' pointer itself would need to be 0x2.
On 64-bit systems, the top or bottom 32-bits of the pointer would need
to be 0x2 (depending on endianness). Those situations seem impossible
or very unlikely on most systems, and have never been seen in the
wild.

FIXES 135238

Change-Id: Id14571d090570cfacfa920048f41c3b1e434f31c
Reviewed-on: https://gerrit.openafs.org/14651
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

2 years agocmd: version command should not call before or after procs 45/14645/3
Mark Vitale [Tue, 22 Jun 2021 03:29:09 +0000]
cmd: version command should not call before or after procs

Since the original IBM code import, the cmd_Dispatch processor has
avoided calling beforeProc and afterProc for the built-in 'help' and
'apropos' commands.  This is important, because these procs may rely on
application-defined common arguments (e.g., -cell <cell> or -noauth) for
proper operation.  However, application common arguments are not defined
for built-in commands 'help' and 'apropos'.

Unfortunately, when a new built-in 'version' command was added
(350c140d89198cb7 libcmd-support-version-switch-20060630), it was not
exempted from the before and after procs.

In order to avoid a segmentation fault in 'libadmin/test/afscp
version', modify cmd to also avoid calling beforeProc and afterProc for
the 'version' command.

Change-Id: Ic899397de808fd6c4a5f66a0f5add102340064e6
Reviewed-on: https://gerrit.openafs.org/14645
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agobos: Let xdr allocate rpc output strings 50/14650/5
Michael Meffie [Wed, 23 Jun 2021 00:02:18 +0000]
bos: Let xdr allocate rpc output strings

The bos client provides fixed sized buffers on the stack for RPC output
strings instead of letting xdr allocate output strings.  Unfortunately,
the fixed sized buffers do not account for the terminating nul char when
the output string is the maximum size defined for the bozo RPCs.

To avoid potential buffer overflows, and to allow for larger xdr string
sizes in the future, convert these to xdr allocated strings. Be sure to
always free the xdr allocated strings.

The following bozo RPCs have xdr output strings, and are addressed in
this commit:

BOZO_EnumerateInstance
BOZO_GetCellHost
BOZO_GetCellName
BOZO_GetInstanceInfo
BOZO_GetInstanceParm
BOZO_GetInstanceStrings
BOZO_GetStatus
BOZO_ListSUsers

Thanks to Cheyenne Wills for pointing out this issue.

Change-Id: I7fb48ff6766420a2d84723e1663ff24e86313ccf
Reviewed-on: https://gerrit.openafs.org/14650
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoihandle: Remove FDH_READV/WRITEV references 55/14655/2
Andrew Deason [Wed, 27 May 2020 23:06:24 +0000]
ihandle: Remove FDH_READV/WRITEV references

FDH_READV and FDH_WRITEV have been unused since commit
335ccb40 (ihandle positional read and write). Remove a couple of
lingering references to them.

Change-Id: I640d411782440958a823ef0e2aa810bddd8ceee2
Reviewed-on: https://gerrit.openafs.org/14655
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agonamei: Calculate offset before use in GetFreeTag 54/14654/2
Andrew Deason [Fri, 29 May 2020 19:22:34 +0000]
namei: Calculate offset before use in GetFreeTag

We pass 'offset' to FDH_LOCKFILE here, but 'offset' is calculated a
few lines below. The compiler doesn't catch this, since FDH_LOCKFILE
is a macro that ignores the second argument (except on WINNT).

Just move the calculation a few lines above, to ensure 'offset' is set
before it's actually used, to avoid issues if and when FDH_LOCKFILE is
changed to use the second argument.

Change-Id: If858005cb83370ca905f93f9d3d7eed2941ddf99
Reviewed-on: https://gerrit.openafs.org/14654
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoviced: remove dead code from h_Alloc_r 35/14335/2
Mark Vitale [Fri, 28 Aug 2020 19:16:01 +0000]
viced: remove dead code from h_Alloc_r

These two lines have been ifdef'd out since commit 8f2df21ffe59
pull-prototypes-to-head-20020821.  Remove them.

No functional change is incurred by this commit.

Change-Id: I5d1d97d285ad50777bc5a26a53d6e0357140941d
Reviewed-on: https://gerrit.openafs.org/14335
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibadmin: Let xdr allocate rpc output strings 26/14626/4
Michael Meffie [Fri, 21 May 2021 16:38:01 +0000]
libadmin: Let xdr allocate rpc output strings

In most functions, the libadmin library provides fixed sized buffers for
RPC output strings instead of letting xdr allocate the output string.
Unfortunately the fixed sized buffers do not account for the terminating
nul char when the output string is the maximum length possible for the
xdr output strings.

To avoid potential buffer overflows, and to allow for larger xdr string
sizes in the future, convert these to xdr allocated strings and use safe
string functions to copy the results to the application buffers. Fail
with an error if the application buffer is too small, instead of
overflowing the buffer or truncating results.

Thanks to Cheyenne Wills for pointing out this issue.

Change-Id: I963e1b790417863c036e897811c86a634d1d4e7f
Reviewed-on: https://gerrit.openafs.org/14626
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoutil: remove dead code KTimeCmp 34/14334/4
Mark Vitale [Fri, 28 Aug 2020 19:12:33 +0000]
util: remove dead code KTimeCmp

This routine has been dead code since the original IBM code import.  It
was ifdef'd out in commit 45376df63f7f util-warning-cleanup-20011005.

Remove the dead code from the tree.

No functional change is incurred by this commit.

Change-Id: I33689db8e016e1dd5abb88910af8da6208a75ce6
Reviewed-on: https://gerrit.openafs.org/14334
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agorxgen: remove dead code deverbatim 33/14333/2
Mark Vitale [Fri, 28 Aug 2020 19:09:17 +0000]
rxgen: remove dead code deverbatim

This routine has been dead code since the original IBM import.  It was
ifdef'd out in commit 8f2df21ffe59 pull-prototypes-to-head-20020821.

Remove it from the tree.

No functional change is incurred by this commit.

Change-Id: Ie81bd8ed1764026e872dcf07e0b12e3c8a31c64d
Reviewed-on: https://gerrit.openafs.org/14333
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: remove dead code xdrrx_getpos, xdrrx_setpos 32/14332/2
Mark Vitale [Fri, 28 Aug 2020 19:01:50 +0000]
rx: remove dead code xdrrx_getpos, xdrrx_setpos

These routines have been dead code since the original IBM code import.
They were ifdef'd out in commit 1d93f2da22eb
'rx-warnings-and-prototyping-20010623'

Remove them from the tree.

No functional change is incurred by this commit.

Change-Id: I958c07487e2453690535acd01b92c59fcecd1189
Reviewed-on: https://gerrit.openafs.org/14332
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agolibafsauthent: export pr_IsAMemberOf 77/14377/2
Benjamin Kaduk [Wed, 30 Sep 2020 04:47:55 +0000]
libafsauthent: export pr_IsAMemberOf

Reported by Alexander Chernyakhovsky <achernya@mit.edu>

Change-Id: I0e0282d89a62ab577ceba3d10aa2ee2819c3f882
Reviewed-on: https://gerrit.openafs.org/14377
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoklog.krb5: remove "save and reuse password" logic 43/14643/2
Marcio Barbosa [Sun, 20 Jun 2021 03:52:36 +0000]
klog.krb5: remove "save and reuse password" logic

In order to avoid repeated requests for the user's password, klog.krb5
caches and reuses it whenever necessary. However, with the introduction
of commit 3a9a5783cd1fd73902655f0876e2069b42688c94, klog.krb5 always
requests a TGT regardless of the state of writeTicketFile, eliminating
the need for possible extra requests for the user's password.

Moreover, krb5_get_init_creds_password() does not accept a custom
prompter on macOS (returns EINVAL). Consequently, if the -password
argument is omitted, klog.krb5 fails with the following error:

klog: Invalid argument Unable to authenticate in realm <REALM>

Given that the user won't be prompted for a password multiple times,
remove the "save and reuse password" logic and use krb5_prompter_posix()
as the prompter function (instead of klog_prompter).

Relevant issue identified by gangovind@in.ibm.com.

Change-Id: Ia994a18d1d166893f12ee78d3e6f25192ff327ee
Reviewed-on: https://gerrit.openafs.org/14643
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Tested-by: Ganesh G. Chaudhari <gangovind@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Avoid verbose output for 'make check V=0' 19/14619/3
Andrew Deason [Mon, 28 Dec 2020 18:22:38 +0000]
tests: Avoid verbose output for 'make check V=0'

For "pretty" V=0 builds, change 'make check' to run 'runtests' in
non-verbose mode, so we just get a summary of test results, instead of
the raw test output. Without V=0, the default is unchanged, so we
still print out all test output by default.

Change-Id: I554f9d32ed5a9cd27e83fef6245af589d91e801f
Reviewed-on: https://gerrit.openafs.org/14619
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agotests: Introduce 'make check TESTS=test/name' 17/14317/5
Andrew Deason [Wed, 1 Jul 2020 19:21:35 +0000]
tests: Introduce 'make check TESTS=test/name'

Currently 'make check' always runs all tests. We can run individual
tests manually, but doing so is a bit cumbersome to do under the same
environment as 'make check', since doing so means running something
like this:

    $ MAKECHECK=1 $(abs_top_srcdir)/tests/libwrap @TOP_OBJDIR@/lib \
        ./runtests opr/fmt util/ktime

To make it easier to run single tests introduce a way of calling 'make
check' like this:

    $ make check TESTS='opr/fmt util/ktime'

Which will run the same commands as 'make check', but will run
runtests with only the specified tests, instead of running the default
list.

Some makefiles currently use a "TESTS" or "tests" variable to list
their test binaries; rename them all to "BINS" to avoid conflicting
with this new use for "TESTS" and to make our makefiles a little more
consistent.

Change-Id: I427f83be0d4571794644a97123bcd1f32427bd05
Reviewed-on: https://gerrit.openafs.org/14317
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove NoAuth procedures from Admin Guide 38/14638/2
Benjamin Kaduk [Thu, 10 Jun 2021 15:27:58 +0000]
Remove NoAuth procedures from Admin Guide

Retain the factual description of what the file/flag does, but remove
the suggestion that it is useful in favor of a disclaimer that it is
not needed, and replace the emergency-recovery procedure with a short
description using -localauth.

Change-Id: I18b0dad9740f01515717d572a0374cd2f77fc02d
Reviewed-on: https://gerrit.openafs.org/14638
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove recommendation to use NoAuth from NoAuth.5 42/12142/5
Benjamin Kaduk [Fri, 25 Dec 2015 01:46:29 +0000]
Remove recommendation to use NoAuth from NoAuth.5

Do not document that there are cases when this file should exist;
there are not.

Installation no longer needs this file, and key emergencies can
be handled using asetkey or, on 1.8.x, the kerberos tooling to modify
rxkad.keytab.

Change-Id: I0c3ba15f3ffca8660be2d8b092f10053258742e6
Reviewed-on: https://gerrit.openafs.org/12142
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove rpctestlib 17/14617/3
Andrew Deason [Fri, 7 May 2021 20:02:06 +0000]
Remove rpctestlib

There is some code in tests/rpctestlib that appears to be for testing
fileserver RPCs and callback processing, added in commit 262a678d (An
RPC test dispatch library for vice). However, it has never been used,
it seems unlikely that it will be used anytime soon, and it's not
clear if it even works (it contains many hard-coded references to
interfaces and IP addresses).

Just remove the unused code, and some references to rpctestlib. It can
always be added back if needed (or more likely, reimplemented to be
more in line with our current test framework in tests/ ).

Change-Id: Ied3be7474581d8ee75ae000815bb7364d143fd31
Reviewed-on: https://gerrit.openafs.org/14617
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoRemove a few unused opr/util components 47/14547/5
Andrew Deason [Wed, 3 Mar 2021 18:24:27 +0000]
Remove a few unused opr/util components

A few pieces of opr and util have no callers, have never been used
since they were added, and are not expected to be used in the near
future. Remove the unused code; if we ever want to use any of this
again, it can be re-added when we actually need it.

Specifically, this removes:

- 'stoupper' in src/opr/casestrcpy.c, added in e117599f
  (fileserver-hates-pruclient-20060626)

- 'opr_ffsll' and 'opr_flsll' in src/opr/ffs.h, added in d4369917
  (opr: implement the BSD ffs() functions)

- src/util/thread_pool.c and related headers, added in 4ca57f3f
  (Provide an abstract thread pool object)

Change-Id: Id098cb86318ac9e2412937f4b63b5d99e35be568
Reviewed-on: https://gerrit.openafs.org/14547
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agocf: Resolve implicit function definition for memset 31/14631/4
Cheyenne Wills [Fri, 4 Jun 2021 16:18:39 +0000]
cf: Resolve implicit function definition for memset

The autoconf function OPENAFS_HAVE_STRUCT_FIELD can produce a compiler
warning for an implicit function definition for memset, however with
macOS 11 (Big Sur) the default compiler flags have been changed
(-Werror=implicit-function-declaration) so that this is now flagged as an
error. As an error this can lead to an incorrect result returned by
OPENAFS_HAVE_STRUCT_FIELD.

Add an include for <string.h> to provide the necessary definition for
memset.

Note, both gcc and clang can produce the implicit function definition
warning.

Change-Id: I05ea43e1712c0450b7d1a78d4e953bfad9be28b9
Reviewed-on: https://gerrit.openafs.org/14631
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Avoid creating unused conns 37/14637/2
Andrew Deason [Mon, 7 Jun 2021 23:23:39 +0000]
afs: Avoid creating unused conns

In afs_LoopServers and PCallBackAddr, we loop over our known servers
to issue an RPC, but we skip over servers on various conditions. For
most of those, we skip over the server before creating the relevant
conn (via afs_ConnBySA), but not for the
SRVADDR_ISDOWN/afs_HaveCallBacksFrom check. If we skip over the server
for that reason, we'll create an afs_conn and rx_connection, and then
release our refs without using them.

This doesn't cause any big problems, but it does create extra
connections and peers that linger around for at least a couple of
hours (until they get cleaned up by afs_GCUserData).

It's very easy to avoid these extra useless conns; just perform the
SRVADDR_ISDOWN/afs_HaveCallBacksFrom check before we call
afs_ConnBYSA. This also makes the check a bit more consistent with the
other checks we do.

Change-Id: Ie49b87e5dd755f77364502528a02c14944e8c23d
Reviewed-on: https://gerrit.openafs.org/14637
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agocf: Fix typo in test for enable-shared/with-swig 28/14628/3
Cheyenne Wills [Tue, 1 Jun 2021 18:17:01 +0000]
cf: Fix typo in test for enable-shared/with-swig

The commit cf: Disable swig if shared libraries are disabled (0e84b7405)
contains a typo in a test: "x$enable_shared" != "yes".  This causes
configure to exit due to incorrectly testing --enable-shared.

Update swig.m4 to correct the typo.

Change-Id: I0d769ec41e2e7896f2232965b5eaa19734033c83
Reviewed-on: https://gerrit.openafs.org/14628
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agodeorbit afsinstall 24/14624/3
Mark Vitale [Thu, 20 May 2021 16:41:24 +0000]
deorbit afsinstall

This is a very old perl script (with accompanying documentation) to
install AFS.  It has not been maintained at all since the license was
updated in 2000.

Remove it from the tree.

Change-Id: I8fb4ce9d969b8bd246f7f640b8fd63921556a529
Reviewed-on: https://gerrit.openafs.org/14624
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agocf: Disable swig if shared libraries are disabled 06/14606/4
Cheyenne Wills [Mon, 26 Apr 2021 22:17:39 +0000]
cf: Disable swig if shared libraries are disabled

When building with the option --disable-shared and swig is also enabled
(either explicitly, or autodetected) a build failure occurs when trying
to link libuafs/PERLUAFS/ukernel.so

Update the configure test for swig to disable the swig autodetection
when --disable-shared was specified, as well as emitting a notice
message stating that the swig autodetection has been disabled.

If --with-swig=yes was specified along with --disable-shared, generate a
configure error stating --with-swig is incompatible with
--disable-shared.

Change-Id: I766cf13b41c1d160e98eb160e0f907d5de2472c9
Reviewed-on: https://gerrit.openafs.org/14606
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agorx: Remove multi_End_Ignore 25/14425/7
Andrew Deason [Tue, 3 Nov 2020 19:49:15 +0000]
rx: Remove multi_End_Ignore

Since commit "rx: Remove delays in multi_End_Ignore", multi_End_Ignore
and multi_Finalize_Ignore are unused in the tree, and should not be
used by callers. Remove the dead functions.

This commit bumps LT_current in libafsrpc to 3, because we are
removing the exported symbol multi_Finalize_Ignore.

Change-Id: I4d298f5118a69cfd04de44c3f268691a87a6d9a7
Reviewed-on: https://gerrit.openafs.org/14425
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agorx: Remove delays in multi_End_Ignore 95/14595/3
Andrew Deason [Fri, 16 Apr 2021 16:11:35 +0000]
rx: Remove delays in multi_End_Ignore

When using our multi_Rx mechanism, callers can use either multi_End or
multi_End_Ignore at the end of the multi_Rx block. Among other things,
these macros run 'rx_EndCall(call, code)' for each call in the
multi_Rx invocation that hasn't already ended. For multi_End, 'code'
is RX_USER_ABORT, and for multi_End_Ignore, 'code' is 0; the macros
are otherwise equivalent.

When multi_End is used, this means any un-ended calls are aborted with
RX_USER_ABORT, and the call immediately ends. But when
multi_End_Ignore is used, the call is not aborted, and so we must wait
for the peer to acknowledge that it has received our packets before
ending (done via an rxi_ReadProc call in rx_EndCall).

This means that if a caller multi_Abort's out of a multi call and uses
multi_End_Ignore, we'll wait for the peer to acknowledge our packets
for all of the calls we haven't processed. Waiting for that is a
complete waste of time, since we don't care about the results of those
calls (since we multi_Abort'd). This doesn't matter much if those
calls are responded to promptly, but if the peer is not up or is just
slow, it can cause us to wait several seconds until we timeout.

There are currently only three users of multi_End_Ignore:

- DoProbe in src/ubik/recovery.c

- MultiBreakCallBackAlternateAddress_r in src/viced/callback.c

- MultiProbeAlternateAddress_r in src/viced/callback.c

All of these use multi_Rx to try and probe multiple IPs for the same
machine in parallel, and so some of the calls may very well be trying
to contact unreachable IPs; we only need one to work for the call to
succeed.

To avoid the unnecessary delays in these codepaths, convert them to
use multi_End. Change multi_End_Ignore to be the same as multi_End,
and multi_Finalize_Ignore to the same as multi_Finalize, to make sure
the bad behavior is not used. The _Ignore macros/functions are now
unused in the tree, but keep them around for now since
multi_Finalize_Ignore is exported by libafsrpc.

Thanks to mbarbosa@sinenomine.net for discovering this weird behavior.

Change-Id: I65536a0975bd7a16bb805555943c032c5e6afdf3
Reviewed-on: https://gerrit.openafs.org/14595
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: Assert avc->lock is held in afs_IAS_once 92/14592/3
Andrew Deason [Mon, 12 Apr 2021 23:21:23 +0000]
afs: Assert avc->lock is held in afs_IAS_once

Commit 3be5880d (afs: Avoid panics in afs_InvalidateAllSegments) added
an assert to check that vcache->lock is write-locked before we call
afs_InvalidateAllSegments_once from a background operation.

However, afs_InvalidateAllSegments_once should always be called with
vcache->lock write-locked; there's nothing specific about the
backgrounded call that requires this. So to make sure we catch all
cases, move this assert to afs_InvalidateAllSegments_once itself.

Also remove the conditional check for WriteLocked(&avc->lock) in here,
since clearly avc->lock must be write-locked (and actually is, since
change Ic309e4006bf47bcb38fa2b53bf103e0c645a856d "afs: write-lock
vcache->lock in afs_InactiveVCache").

Add some comments to this function while we're here, to more clearly
indicate what locks are needed.

Change-Id: I10c47021e94220879cd79c0f7390c52a13ee0eee
Reviewed-on: https://gerrit.openafs.org/14592
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: write-lock vcache->lock in afs_InactiveVCache 84/14584/3
Mark Vitale [Sat, 27 Mar 2021 04:00:17 +0000]
afs: write-lock vcache->lock in afs_InactiveVCache

Since the original IBM code import, the comments for
afs_InvalidateAllSegments indicate that vcache->lock W should be held at
entry.  However, even back then, only LINUX and IRIX honored this
requirement when the 'inactive' vnode operation reached
afs_InvalidateAllSegments.

Over the years, a number of commits have changed the operation and
locking for the LINUX inactive vnode op:

5293aa35617a6ad35980ce16fdf492ea960cc18a linux-iput-and-glock-changes-20010130
e8591334602e5e8dad78dc6426d3c44d564572c1 linux-osi-clear-inode-locking-fix-20010816
652f3bd9cb7a5d7833a760ba50ef7c2c67214bba linux-dynamic-inodes-20050710
e0d9e434bb778a2507c1cd6d96c1faa2071f2b2c put-inode-speedup-20050815
b21c13dc3ab751118220dc31276995050841a1ae linux-dentry-iput-20060813

Eventually, ac52e2f3c0bec9298d020de963036409165f380e
linux-dont-lock-around-inactivevcache-20061010 removed the vcache->lock
from afs_dentry_iput (the current OpenAFS handler for inactive vcaches).
The commit message states:

    "iafs_InactiveVCache() [sic] calls afs_InvalidateAllSegments() which says
    it should be called with the vnode locked. so the lock should
    probably be moved to afs_InactiveVCache() so it can be droppped
    before calling afs_remunlink()."

Unfortunately, the vcache->lock was never moved to afs_InactiveVCache.

Finally, 3be5880d1d2a0aef6600047ed43d602949cd5f4d 'afs: Avoid panics in
afs_InvalidateAllSegments' introduced a background operation
BInvalidateSegments that contains an assert for vcache->lock.  This
assert has exposed the existing lack of proper locking for some paths to
afs_InvalidateAllSegments by causing a kernel panic:

  d_iput -> afs_dentry_iput -> afs_InactiveVCache ->
  afs_InvalidateAllSegments -> afs_BQueue(BOP_INVALIDATE_SEGMENTS..) ->
  BInvalidateSegments -> osi_Assert(WriteLocked(&vcache->lock))

Prevent the panic by modifying afs_InactiveVCache to obtain vcache->lock
W before calling afs_InvalidateAllSegments, and dropping it before
calling afs_remunlink.

Thanks to Chaskiel Grundman for reporting and diagnosing the problem.

Change-Id: Ic309e4006bf47bcb38fa2b53bf103e0c645a856d
Reviewed-on: https://gerrit.openafs.org/14584
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agodoc: Look in $srcdir for documentation sources 22/14622/2
Andrew Deason [Wed, 12 May 2021 20:35:01 +0000]
doc: Look in $srcdir for documentation sources

In several places, we look for documentation source files in e.g.
'doc/man-pages', 'doc/xml', etc. But if we are running an objdir
build, those directories won't exist relative to the current working
directory; we need to look in $srcdir to find them.

So, if we're running an objdir build, our man pages and other
documentation won't be installed. We don't report any error in this
case (the relevant steps are just skipped), since building the
documentation is optional, in case the doc sources are not present.

To fix this, look in $srcdir in the various places that reference doc
source files. Fixing the 'for' loops in the 'dest' and 'install'
targets in doc/man-pages requires some extra cd'ing around, because $M
is used as part of another path in the body of the loop.

Change-Id: Ic3c90ab5e64aeefe6235efb6f6ec26080d7b3a70
Reviewed-on: https://gerrit.openafs.org/14622
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: clarify cold and warm shutdown logic 82/12182/7
Mark Vitale [Fri, 29 Jan 2016 06:00:56 +0000]
afs: clarify cold and warm shutdown logic

Currently, any code that wants to perform a cold shutdown must first set
global afs_cold_shutdown = 1, then call afs_shutdown(void).

Instead, modify afs_shutdown() to accept a single parm which specifies
AFS_WARM or AFS_COLD shutdown, and to set the value of global
afs_cold_shutdown based on this parm.  Remove all other assignments for
afs_cold_shutdown.  Modify all callers of afs_shutdown() to specify
AFS_WARM or AFS_COLD as needed to maintain equivalent function.

This should make it much easier to tell at a glance what type of
shutdown is being requested by each caller to afs_shutdown().

No functional change should be incurred by this commit.

Change-Id: I921eca5b4d2659209154fbe37d575db69bf708b8
Reviewed-on: https://gerrit.openafs.org/12182
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafsd: remove unused variable afs_shutdown 80/14380/3
Mark Vitale [Thu, 1 Oct 2020 21:13:51 +0000]
afsd: remove unused variable afs_shutdown

Since the original IBM code import, the variable afs_shutdown has been
set but never read.

Remove it from the code base.

No functional change is incurred by this commit.

Change-Id: Iac603465ee911fa3601010b67f3f34f22d7b0e3f
Reviewed-on: https://gerrit.openafs.org/14380
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: remove duplicate declaration for afs_shutdown() 81/12181/6
Mark Vitale [Fri, 29 Jan 2016 04:38:59 +0000]
afs: remove duplicate declaration for afs_shutdown()

Somehow there were two.  Now there is but one.

Change-Id: I60c793cf3b13508e89020e9f19847a41de4d0277
Reviewed-on: https://gerrit.openafs.org/12181
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

2 years agoafs: afsd -shutdown sets afs_cold_shutdown too soon 80/12180/6
Mark Vitale [Thu, 28 Jan 2016 15:01:13 +0000]
afs: afsd -shutdown sets afs_cold_shutdown too soon

'afsd -shutdown' always invokes syscall(AFSOP_SHUTDOWN)
with parm2 set to 1 to indicate a "cold" shutdown.
(There are no other callers to AFSOP_SHUTDOWN).

AFSOP_SHUTDOWN sets global variable afs_cold_shutdown
based on the value of parm2.  Then it checks to see if
AFS is still mounted; if so, we return early with EACCES.
However, global afs_cold_shutdown remains set.

Therefore, the next successful 'umount' after a "failed"
'afsd -shutdown' will always trigger a "cold" shutdown.
This is contrary to the intent of the current implementation,
which is to perform a "warm" shutdown upon 'umount' for
most platforms.  (Exceptions:  AIX, OBSD, NBSD always
specify a cold shutdown upon 'umount').

This bug would never be noticed on the "cold" exception
platforms, but on the "warm" platforms the inconsistency
of seeing an unexpected "COLD" shutdown may be confusing
and surprising.

Make shutdown operation more self-consistent by modifying
AFSOP_SHUTDOWN to defer setting of afs_cold_shutdown until
after the mount test.

Change-Id: If4ddb592d0b8fc8098f7ef96cec82f9f545b9099
Reviewed-on: https://gerrit.openafs.org/12180
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

2 years agoafs: free the Buffers array correctly during shutdown 83/12183/6
Mark Vitale [Fri, 29 Jan 2016 06:30:47 +0000]
afs: free the Buffers array correctly during shutdown

DInit() allocates 'Buffers' with afs_max_buffers = 4*nbuffers
worth of buffer structs to allow for run-time expansion.

But shutdown_bufferpackage() free 'Buffers' as if it only had
nbuffers worth of buffer structs.

Correct the size of Buffers passed to afs_osi_Free().

Discovered during Solaris shutdown testing with kmem_flags=x0f.
This bug is not Solaris-specific, but it may be symptomless on other
platforms.

Introduced by commit e7c966354c428a5a5929a3db6a829ee71c8ba2fc 'Flexible
client buffer growth'; this only affected cold shutdowns (afsd
-shutdown).

After commit 2336164d1bf63980419d3a870f908f1f384fdfc0 'afs: Actually
free resources during warm shutdown', this bug also affects warm
shutdowns (the default when /afs is unmounted).

Change-Id: I6b77f4f8f432a1c20efb1ff2349e349b46a9d58d
Reviewed-on: https://gerrit.openafs.org/12183
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>

2 years agoauth_depinstall: Add rxgk_depinstall as dependency 09/14609/4
Cheyenne Wills [Mon, 3 May 2021 16:14:37 +0000]
auth_depinstall: Add rxgk_depinstall as dependency

In a clean workspace, a 'make libuafs' fails to build due a missing
header file 'rx/rxgk_types.h' since the file rxgk_types.h was not
installed in the includes directory.  The libuafs target consumes
rxgk_types.h (installed by rxgk_depinstall) indirectly via
auth/cellconfig.p.h that includes rxgk_types.h.

 make libuafs
 ...
 In file included from .../src/afs/UKERNEL/afs_usrops.c:27:
  .../include/afs/cellconfig.h:49:10: fatal error: rx/rxgk_types.h:
  No such file or directory

Add rxgk_depinstall to the list of dependencies for the auth_depinstall
target in the top Makefile to reflect the header dependency.

Change-Id: I01239396c4a5c162b75a29a8e6aaf602b3c1ebb9
Reviewed-on: https://gerrit.openafs.org/14609
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agomacos: delegate sock_* calls to bkg daemons 31/14431/12
Marcio Barbosa [Fri, 9 Apr 2021 15:14:52 +0000]
macos: delegate sock_* calls to bkg daemons

As part of Apple's ongoing effort to modernize macOS, improve security
and reliability, the deprecation of kernel extensions was officially
announced at WWDC19. According to this announcement, Kernel programming
interfaces will be deprecated as alternatives become available, and
future OS releases will no longer load kernel extensions that use
deprecated KPIs by default.

Unfortunately, the following KPIs, extensively used by rx, are included
in the list of deprecated KPIs as of macOS 10.15:

- sock_receivembuf
- sock_close
- sock_send
- sock_socket
- sock_setsockopt
- sock_bind

To workaround this problem, delegate calls to the functions mentioned
above to bkg daemons forked by afsd. Notice that the ifadd_* and ifnet_*
functions are also deprecated. Fortunately, these calls can be avoided
enabling AFS_USERSPACE_IP_ADDR.

Thanks to Andrew Deason for his assistance (ideas, suggestions,
documentation, etc).

Change-Id: I916b66455bec73138c55e2764cc1146b998cb19f
Reviewed-on: https://gerrit.openafs.org/14431
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agomacos: packaging support for MacOS X 11.0 30/14430/4
Marcio Barbosa [Thu, 28 Jan 2021 23:49:25 +0000]
macos: packaging support for MacOS X 11.0

This commit introduces the new set of changes / files required to
successfully create the dmg installer on OS X 11.0 "Big Sur".

Change-Id: I600aba528305d8d42393e90fd56e98e4557d9233
Reviewed-on: https://gerrit.openafs.org/14430
Reviewed-by: Yadavendra Yadav <yadayada@in.ibm.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agomacos: add support for MacOS 11.0 29/14429/6
Marcio Barbosa [Thu, 28 Jan 2021 22:45:10 +0000]
macos: add support for MacOS 11.0

This commit introduces the new set of changes / files required to
successfully build the OpenAFS source code on OS X 11.0 "Big Sur".

While here, refactor the code that checks if the "-Xlinker -kext"
system-specific linker option is needed.

Change-Id: I9895ce97143aec500a5bbb4a9502eca19769c85e
Reviewed-on: https://gerrit.openafs.org/14429
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovol: ensure ih package defaults are set for salvage 78/14378/6
Mark Vitale [Thu, 30 Jul 2020 20:42:19 +0000]
vol: ensure ih package defaults are set for salvage

Like most OpenAFS components that work with ihandles, salvager relies on
implicit invocation of ih_PkgDefaults via the one-shot in the first call
to IH_INIT.

Unfortunately, there is at least one reachable code path in salvager
that asserts (panics) because vol_io_params has not yet been
initialized.  This is when salvaging a volume group that does not have a
link table; the salvager then panics while attempting to create a new
link table:

SalvageFileSys -> SalvageFileSys1 -> DoSalvageVolumeGroup ->
CreateLinkTable -> IH_CREATE -> namei_icreate -> icreate ->
namei_SetLinkCount -> FDH_SYNC -> ih_fdsync -> osi_Assert(0)

This path was discovered while testing the non-dafs salvager, but it has
also been observed in the field with the DAFS salvageserver.  It is
possible that there are additional undiscovered paths where
vol_io_params are required but uninitialized.

Add an implicit ih_PkgDefaults call to icreate to avoid triggering the
assert via the code path above.

Change-Id: If348d7f8ab2d34d55727b5a6d78db6e1c8e14cdf
Reviewed-on: https://gerrit.openafs.org/14378
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agovol: move ih_PkgDefaultsSet check inside ih_PkgDefaults 83/14383/6
Mark Vitale [Fri, 9 Oct 2020 20:28:15 +0000]
vol: move ih_PkgDefaultsSet check inside ih_PkgDefaults

Instead of repeating the oneshot check in each caller of ih_PkgDefaults,
move the oneshot check into ih_PkgDefaults itself.

While here, ensure that ih_PkgDefaults does its work under IH_LOCK.

Finally, make ih_PkgDefaultsSet a local static variable (no longer
exported).

Change-Id: I66717de12cb5cc70de0507a768f968f6afbd38f8
Reviewed-on: https://gerrit.openafs.org/14383
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Mark Vitale <mvitale@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoFBSD: Add support for FreeBSD 12.2 74/14474/3
Tim Creech [Fri, 30 Oct 2020 01:29:10 +0000]
FBSD: Add support for FreeBSD 12.2

Change-Id: I28aeccbc1f4e57fc2f0aeef6e0613e43b0208705
Reviewed-on: https://gerrit.openafs.org/14474
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: Remove ISAFS_GLOCK in afs_ConnBySA 81/14581/2
Andrew Deason [Sat, 12 Oct 2019 19:17:35 +0000]
afs: Remove ISAFS_GLOCK in afs_ConnBySA

We must be holding AFS_GLOCK at this point in the code, since we're
calling functions like ObtainSharedLock, which require AFS_GLOCK to be
held. Remove the call to ISAFS_GLOCK and the relevant conditionals, to
get rid of some visual noise.

The call to ISAFS_GLOCK was added in commit cb9e0292 (unix cm
rx-oblivious connection pooling), in which it was also unnecessary.

Change-Id: I9281108453359acf079828c1625556e2380c3a51
Reviewed-on: https://gerrit.openafs.org/14581
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agocf: Run AFS_LT_INIT after setting CC 85/14585/3
Cheyenne Wills [Wed, 7 Apr 2021 16:51:58 +0000]
cf: Run AFS_LT_INIT after setting CC

Since libtool support was introduced for 1.8.x in commit 69f26ece (Add
libtool support), we've run LT_INIT or AFS_LT_INIT early on in
configure.ac.

If CC isn't set, AFS_LT_INIT defaults to using gcc when it's available.
On Solaris, we set CC and CFLAGS ourselves later (in osconf.m4) to use
the Solaris Studio compiler, but this doesn't change the compiler that
AFS_LT_INIT already chose. As a result, on Solaris if no value for CC is
given during configure and gcc is available, some libtool commands will
try to use gcc with CFLAGS intended for the Solaris Studio compiler,
which will fail.

  /bin/sh ../../libtool --quiet --mode=link --tag=CC ... -mt ...
  gcc: error: unrecognized command line option '-mt'; did you mean '-t'?

To fix this, move AFS_LT_INIT into osconf.m4 after our platform-specific
macros have had a chance to set CC. Also move our checks for AR, AS,
etc. to after AFS_LT_INIT, since AFS_LT_INIT sets those.

Note.  Without GCC installed on a Solaris system, libtool will find the
Solaris Studio compiler (assuming that PATH is set up correctly) and the
build will proceed successfully. Just installing the GCC package is
sufficient to break the build.

This commit fixes a regression from 1.6.x where having the GCC package
installed on the system would not break the build.

Change-Id: I6458739fa5050eb98e6980e8d7b0ebfcc62d493f
Reviewed-on: https://gerrit.openafs.org/14585
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agovolser: Remove unused UV_* operations 80/14580/2
Andrew Deason [Thu, 31 Oct 2019 18:52:38 +0000]
volser: Remove unused UV_* operations

The UV_ functions UV_AddVLDBEntry, UV_ZapVolumeClones, and
UV_GenerateVolumeClones are not called by anyone in the tree. Remove
the dead code.

Change-Id: I8dfd0f183702d9f059cd5a71fb72272d0864ecc0
Reviewed-on: https://gerrit.openafs.org/14580
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Fix the test for bosserver '-cores none' 59/14559/2
Cheyenne Wills [Thu, 18 Mar 2021 14:28:22 +0000]
bozo: Fix the test for bosserver '-cores none'

The check for the '-cores none' parameter is incorrect resulting in the
parameter to be taken as a directory path.

Update the string comparison.

Change-Id: I0d72c1add52d36e40f75981a86c16b5689d38fd8
Reviewed-on: https://gerrit.openafs.org/14559
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoMake OpenAFS 1.9.1 60/14560/2 openafs-devel-1_9_1
Benjamin Kaduk [Fri, 19 Mar 2021 01:50:35 +0000]
Make OpenAFS 1.9.1

Update version strings for the second 1.9.x development release.

Change-Id: I318ff00f02f618e0a25571a3c957ae6a6500e65c
Reviewed-on: https://gerrit.openafs.org/14560
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoUpdate NEWS for OpenAFS 1.9.1 39/14539/4
Michael Meffie [Thu, 18 Feb 2021 23:35:33 +0000]
Update NEWS for OpenAFS 1.9.1

Change-Id: I20c23a3d0a84491c1eb4b9c36aee62726fb0b4e9
Reviewed-on: https://gerrit.openafs.org/14539
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agofstrace: remove common dead code 56/14556/2
Mark Vitale [Thu, 11 Mar 2021 22:34:29 +0000]
fstrace: remove common dead code

Previous commits removed dead code from both fstrace.c and afs_icl.c.
Now remove anything from config/icl.h that is no longer needed.

No functional change is incurred by this commit.

Change-Id: Ibdad10ec4c91cd8c2d3fbd637354357f05ac2621
Reviewed-on: https://gerrit.openafs.org/14556
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoafs: remove dead ICL (fstrace) code 55/14555/2
Mark Vitale [Thu, 11 Mar 2021 20:36:54 +0000]
afs: remove dead ICL (fstrace) code

The ICL code (afs/afs_icl.c) which supports fstrace includes a number of
functions that have been dead code since the original IBM code import.
Some of these seem to have been intended to support fine-grained event
tracing, but the implementation was never completed.

Remove the dead code.  No functional change is incurred by this commit.

Change-Id: If4d6d993175df57d4c5d827ab178ed3ba0bc7ed8
Reviewed-on: https://gerrit.openafs.org/14555
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agofstrace: remove dead code 54/14554/2
Mark Vitale [Thu, 11 Mar 2021 20:19:58 +0000]
fstrace: remove dead code

Numerous functions in venus/fstrace.c with names icl_* have been dead
code since the original IBM code import.  Furthermore, many of them have
similar implementations in afs/afs_icl.c with names afs_icl_*.

Remove the dead code.  No functional change is incurred by this commit.

Change-Id: I3943a9cf333c4044c877b46e7b2eec4285358c18
Reviewed-on: https://gerrit.openafs.org/14554
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agobozo: Fix memory leak, check for malloc failures 51/14551/5
Cheyenne Wills [Fri, 12 Mar 2021 19:29:57 +0000]
bozo: Fix memory leak, check for malloc failures

While reading the BosConfig file, the buffer obtained to hold the notp
(notify) parameter is never freed. Reading the BosConfig is only
done once at bosserver start up, so this is a one-time memory
allocation.

There are no checks for malloc failures.

Release the notp buffer and add checks for memory allocation errors.

Change-Id: Iffcb0db12f983a6a6d6a810a98be30152fa73c89
Reviewed-on: https://gerrit.openafs.org/14551
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoLinux 5.12: Add user_namespace param to inode ops 49/14549/6
Cheyenne Wills [Fri, 5 Mar 2021 23:31:03 +0000]
Linux 5.12: Add user_namespace param to inode ops

The Linux commits:
"fs: make helpers idmap mount aware" (549c72977) and
"attr: handle idmapped mounts" (2f221d6f7) that were merged into
Linux-5.12-rc1 cause a build failure when creating the kernel module.

Several functions within the inode_operations structure had their
signature updated to include a user_namespace parameter.  This allows
a filesystem to support idmapped mounts.

OpenAFS only implements some of the changed functions.

   LINUX/vnodeops function inode_operation
   =====================   ===============
   afs_notify_change       setattr
   afs_linux_getattr       getattr
   afs_linux_create        create
   afs_linux_symlink       symlink
   afs_linux_mkdir         mkdir
   afs_linux_rename        rename
   afs_linux_permission    permission

Update the autoconf tests to determine if the Linux kernel requires
the user_namespace structure for inode_operations functions. If so,
define a generic "IOP_TAKES_USER_NAMESPACE" macro.

Update the above vnodeops functions to accept a 'struct user_namespace'
parameter.

When using the 'setattr_prepare' function a user namespace must be
now provided. In order to provide compatibility as a non-idmapped mount
filesystem the initial user namespace can be used. With OpenAFS, the
initial user namespace obtained at kernel module load time is stored in
a global variable 'afs_ns'.

Update the call to setattr_prepare to pass the user namespace pointed
to by the 'afs_ns' global variable.

Update calls to setattr to pass the user namespace pointed to by
the 'afs_ns' global variable.

Notes:

The changes introduced with Linux 5.12 allow a filesystem to support
idmapped mounts if desired. This commit does not implement support for
idmapped mounts, but will continue to use the same initial user
namespace as prior to Linux 5.12.

With Linux 5.12 the following autoconf checks fail:

 HAVE_LINUX_INODE_OPERATIONS_RENAME_TAKES_FLAGS
 HAVE_LINUX_SETATTR_PREPARE
 IOP_CREATE_TAKES_BOOL
 IOP_GETATTR_TAKES_PATH_STRUCT
 IOP_MKDIR_TAKES_UMODE_T

The new macro 'IOP_TAKES_USER_NAMESPACE' covers the cases where these
macros where used.

Change-Id: Id450d5c716137340ed20af5531c0cd756e4435cd
Reviewed-on: https://gerrit.openafs.org/14549
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoLinux: Create wrapper for setattr_prepare 48/14548/5
Cheyenne Wills [Mon, 8 Mar 2021 16:22:04 +0000]
Linux: Create wrapper for setattr_prepare

Move call to setattr_prepare/inode_change_ok into an osi_compat.h
wrapper called 'afs_setattr_prepare'.  This moves some of the #if logic
out of the mainline code.

Change-Id: Ie17cf4c645d754c9e9efd8a603f1bc752d07cf36
Reviewed-on: https://gerrit.openafs.org/14548
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Avoid recursive osi_VM_StoreAllSegments lock 00/14000/6
Andrew Deason [Wed, 1 Jan 2020 23:09:24 +0000]
FBSD: Avoid recursive osi_VM_StoreAllSegments lock

Currently, osi_VM_StoreAllSegments calls vget() for the given vnode,
which requires locking the vnode. However, the vnode should already be
locked. For example, when called from the close syscall, we reach this
function via: vn_close1 -> afs_vop_close -> afs_close ->
afs_StoreOnLastReference -> afs_StoreAllSegments ->
osi_VM_StoreAllSegments. This causes a panic like so:

    kernel: panic: lockmgr_xlock_hard: recursing on non recursive lockmgr 0x[...] @ /usr/src/sys/kern/vfs_subr.c:2730

We can also reach this code path from the BOP_STORE background
operation (BStore -> afs_StoreOnLastReference -> afs_StoreAllSegments
-> osi_VM_StoreAllSegments), initiated from afs_close(), which has the
vnode locked. In this case, we won't be recursively locking the vnode,
since the process calling afs_close() is the one that holds the lock,
and the background thread is the process trying to lock the vnode
again. So we'll just deadlock.

From the comments in this function, it seems like locking the vnode at
all in here is unnecessary, since the vnode should be locked from the
higher-level functions anyway. So just skip the vget and all of the
related looping retry logic. As a result, this function can now become
somewhat simplified.

Change-Id: Ic5a18de46e51dc86190207163ad0fe73bc03cbd7
Reviewed-on: https://gerrit.openafs.org/14000
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Accommodate 12.0's 64-bit inodes 54/13854/9
Tim Creech [Fri, 30 Aug 2019 01:35:36 +0000]
FBSD: Accommodate 12.0's 64-bit inodes

In FreeBSD 12 (see: https://reviews.freebsd.org/rS318736), the layout
of struct dirent changed to allow for 64-bit inodes and a few other
changes. Update our struct min_direct to accommodate, to allow our
readdir() results to be accurate. Without this, readdir() can yield
garbage entries, due to the mismatch in the structure definitions.

Change-Id: I36c2bf1f35b4d1ab61a2b4d51da7514827b3551b
Reviewed-on: https://gerrit.openafs.org/13854
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agodir: Explicitly 'make all' in src/dir/test 50/14550/2
Andrew Deason [Sat, 6 Mar 2021 04:20:35 +0000]
dir: Explicitly 'make all' in src/dir/test

Currently, we 'cd test' and then just run 'make', which makes the
first target specified in the Makefile. On some platforms (FreeBSD),
this results in 'make' trying to build '%.c', which of course we
cannot do, since that's a pattern rule, and so 'make' fails.

To fix this, just 'make all' explicitly, to make the intended targets
in src/dir/test.

Change-Id: Icbbf60c9c163c24fbbed01c754c4f1eefeae6b78
Reviewed-on: https://gerrit.openafs.org/14550
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoFBSD: Lock vm object before vm_page_undirty 62/14162/4
Andrew Deason [Sun, 26 Apr 2020 01:56:01 +0000]
FBSD: Lock vm object before vm_page_undirty

We must write-lock the underlying vm object before calling
vm_page_undirty; otherwise vm_page_undirty asserts if INVARIANTS is
defined. For example:

    kernel: panic: Lock vm object not exclusively locked @ /usr/src/sys/vm/vm_page.c:4487
    kernel:
    kernel: cpuid = 0
    kernel: time = 1587858280
    kernel: KDB: stack backtrace:
    kernel: #0 0xffffffff80bf0c07 at kdb_backtrace+0x67
    kernel: #1 0xffffffff80ba7f8d at vpanic+0x19d
    kernel: #2 0xffffffff80ba7d73 at panic+0x43
    kernel: #3 0xffffffff80ba3a7e at __rw_assert+0x17e
    kernel: #4 0xffffffff828da525 at vm_page_undirty+0x15
    kernel: #5 0xffffffff828da33e at afs_vop_putpages+0x36e
    kernel: #6 0xffffffff811ef0ae at VOP_PUTPAGES_APV+0x8e
    kernel: #7 0xffffffff80ef4c2d at vnode_pager_putpages+0x7d
    kernel: #8 0xffffffff80ee77cf at vm_pageout_flush+0xff
    kernel: #9 0xffffffff80edd1b9 at vm_object_page_collect_flush+0x239
    kernel: #10 0xffffffff80edce99 at vm_object_page_clean+0x179
    kernel: #11 0xffffffff828d681c at osi_VM_StoreAllSegments+0x18c
    kernel: #12 0xffffffff828508cd at afs_StoreAllSegments+0x9d
    kernel: #13 0xffffffff8287ae0e at afs_StoreOnLastReference+0x17e
    kernel: #14 0xffffffff8287c3a5 at afs_close+0x245
    kernel: #15 0xffffffff828d7766 at afs_vop_close+0x166
    kernel: #16 0xffffffff811eb7a8 at VOP_CLOSE_APV+0x88
    kernel: #17 0xffffffff80c80ba3 at vn_close1+0xe3

So, lock the vm object before undirtying our pages in
afs_vop_putpages.

Change-Id: Ifd047e3caf8c2b3e624aaf2bbdb1235a8c38a414
Reviewed-on: https://gerrit.openafs.org/14162
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Use VM_CNT_INC/VM_CNT_ADD on FreeBSD 12 59/13859/7
Tim Creech [Fri, 30 Aug 2019 02:12:41 +0000]
FBSD: Use VM_CNT_INC/VM_CNT_ADD on FreeBSD 12

r317061 changed where v_vnodein &c are stored. Use the new
VM_CNT_INC/VM_CNT_ADD macros when available to accommodate.

Change-Id: I576e333ebdf9e1c6ebb14ff1a1af4c3ad89faa47
Reviewed-on: https://gerrit.openafs.org/13859
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: avoid vrefl() 73/14373/3
Benjamin Kaduk [Fri, 25 Sep 2020 16:22:16 +0000]
FBSD: avoid vrefl()

Commit 20dc2832268eb (correctly) introduced changes so that we
avoid interacting with vnodes marked as VI_DOOMED to the extent
possible, but in doing so inadvertendly used the vrefl() KPI that
was only introduced in FreeBSD 11.0.

Rewrite the relevant logic to use the older vref() KPI, at the cost
of a few more unlock/locks, in order to have a single codepath that
works on all supported FreeBSD versions.

Change-Id: Ib315d59ea6c6208bbd0c908d8eaf502a4de51869
Reviewed-on: https://gerrit.openafs.org/14373
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Handle missing LINK_MAX 60/13860/7
Tim Creech [Fri, 30 Aug 2019 02:13:20 +0000]
FBSD: Handle missing LINK_MAX

LINK_MAX was removed in r327598. When we don't have a LINK_MAX, just
use its value from before it was removed (32767).

Change-Id: Id66a2ba8b7085b392def1d17eace22c7f742e1a4
Reviewed-on: https://gerrit.openafs.org/13860
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Use syscall "helper" functions 58/13858/8
Tim Creech [Fri, 30 Aug 2019 01:55:05 +0000]
FBSD: Use syscall "helper" functions

syscall_register/syscall_deregister were effectively removed in
r329647. Use syscall_helper_register/syscall_helper_unregister
instead, which have existed since r205321 in FreeBSD 9.

Change-Id: I2d5e3101024a44c18395d7eb95c644df6005e0aa
Reviewed-on: https://gerrit.openafs.org/13858
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoFBSD: Handle malloc/free changes in FBSD 12 56/13856/8
Tim Creech [Fri, 30 Aug 2019 01:40:26 +0000]
FBSD: Handle malloc/free changes in FBSD 12

FreeBSD 12 (r328417) removed the deprecated compatibility macros
MALLOC and FREE. Convert our users to just use the normal malloc and
free, so we can build.

FreeBSD 12 (r334545) also changed malloc() into a macro, which breaks
our own malloc macro in our hcrypto config.h. To fix this, just undef
malloc, if it's already a macro.

Change-Id: I5c683e3834710a60cc78476cbaa7203218b11fe0
Reviewed-on: https://gerrit.openafs.org/13856
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoFBSD: Use CK_STAILQ_FOREACH for ifaces on FBSD 12 99/13999/7
Andrew Deason [Sun, 22 Dec 2019 00:34:20 +0000]
FBSD: Use CK_STAILQ_FOREACH for ifaces on FBSD 12

FreeBSD 12 changed how network interfaces and network addresses are
linked together; we're supposed to use CK_STAILQ_FOREACH to traverse
them now, instead of TAILQ_FOREACH. To try to keep this change
simpler, introduce a new macro, AFS_FBSD_NET_FOREACH, which picks the
right macro to use.

Based on a commit by tcreech@tcreech.com.

Change-Id: Iab0f93701dd60dcf4237a7fbbf461019bceaeb38
Reviewed-on: https://gerrit.openafs.org/13999
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoFBSD: Add proper locks when traversing net ifaces 98/13998/7
Tim Creech [Sun, 22 Dec 2019 00:22:40 +0000]
FBSD: Add proper locks when traversing net ifaces

When traversing the list of network interfaces, or the list of
addresses for a network interface, we're supposed to lock the relevant
resource with IFNET_RLOCK, if_addr_rlock, or IN_IFADDR_RLOCK. Add
these locks around our code that examines network interfaces, to
avoid issues if the interface or address list changes while we're
traversing them.

While we're doing this, move around some "AFS_DARWIN_ENV ||
AFS_FBSD_ENV" ifdefs, since these were getting a bit hard to read.
This commit adds some duplicated code, but the result should be easier
to follow.

Also for FreeBSD 12, we must be in NET_EPOCH_ENTER when calling
ifa_ifwithnet/rx_ifaddr_withnet (it panics if we don't, with
INVARIANTS). Add the needed NET_EPOCH_ENTER/EXIT calls, but do so a
bit higher up the call stack, since the returned structures are
potentially no longer valid after we NET_EPOCH_EXIT. Since this means
we're calling these in a few places in libafs, create a couple of rx
abstractions (RX_NET_EPOCH_ENTER) to handle the relevant ifdefs.

[adeason@dson.org: Various adjustments to locking calls; splitting up
DARWIN/FBSD ifdefs.]

Change-Id: I65d63b99b6f6ef3254325cce9338be27ef78478c
Reviewed-on: https://gerrit.openafs.org/13998
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agorx: Indent ifdef maze in rx_kernel.h 61/14161/4
Andrew Deason [Sat, 25 Apr 2020 22:20:54 +0000]
rx: Indent ifdef maze in rx_kernel.h

Change-Id: I3a10206234496b9de6f7ddeafebdee8ab10e5546
Reviewed-on: https://gerrit.openafs.org/14161
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Tim Creech <tcreech@tcreech.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: Indent ifdef maze in rx_kcommon.c 97/13997/7
Andrew Deason [Sat, 21 Dec 2019 04:09:35 +0000]
rx: Indent ifdef maze in rx_kcommon.c

Change-Id: I8b898fb5f7bcc142de3a111baaa6dfb9606fa199
Reviewed-on: https://gerrit.openafs.org/13997
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: BuildBot <buildbot@rampaginggeek.com>

3 years agoafs: Indent ifdef maze in afs_server.c 96/13996/6
Andrew Deason [Sat, 21 Dec 2019 03:51:18 +0000]
afs: Indent ifdef maze in afs_server.c

Change-Id: I223b932490ca1e89711844e41cbff2cd9b50a0f4
Reviewed-on: https://gerrit.openafs.org/13996
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agorx: correctly count RX_PACKET_TYPE_VERSION packets 19/14519/2
Mark Vitale [Wed, 17 Feb 2021 18:53:55 +0000]
rx: correctly count RX_PACKET_TYPE_VERSION packets

Since the original IBM code import, rx statistics for counting incoming
packet types have inadvertently omitted RX_PACKET_TYPE_VERSION packets.
This results in rxdebug -rxstats always reporting 0 for the number of
version packets read.

A similar bug causes a debugging facility in rxi_ReceivePacket to emit
"*UNKNOWN*" instead of "version" for version packets.

Correct all versions of the offending logic.

Change-Id: I9e713eb595b75ef06a347a1c05edb9efffd0b366
Reviewed-on: https://gerrit.openafs.org/14519
Tested-by: Mark Vitale <mvitale@sinenomine.net>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>

3 years agoResolve missing printf args 55/13155/5
Pat Riehecky [Fri, 1 Jun 2018 20:32:57 +0000]
Resolve missing printf args

A handful of printf's requested more args than they were given.  The
missing args are now provided. (via cppcheck)

Change-Id: I3d2bfd1b68a3518ee4c8a65f02446a2bae85d926
Reviewed-on: https://gerrit.openafs.org/13155
Reviewed-by: Andrew Deason <adeason@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>