svc_rpcsec_gss.c: Separate out the non-vnet initialization

Without this patch, a single initialization function was
used to initialize both the vnet'd and non-vnet'd data.
This patch separates out the non-vnet'd initializations
into a separate function invoked by SYSINIT().
This avoids use of IS_DEFAULT_VNET() in the initialization
functions and also configures the non-vnet'd initialization
function to be called first, although ordering is not
currently needed.

Reviewed by:	glebius
MFC after:	3 months
Differential Revision:	https://reviews.freebsd.org/D38749
This commit is contained in:
Rick Macklem 2023-03-01 15:29:25 -08:00
parent a90b47abcb
commit 57ff348804

View File

@ -205,6 +205,25 @@ KGSS_VNET_DEFINE_STATIC(uint32_t, svc_rpc_gss_next_clientid) = 1;
static void
svc_rpc_gss_init(void *unused __unused)
{
svc_auth_reg(RPCSEC_GSS, svc_rpc_gss, rpc_gss_svc_getcred);
sx_init(&svc_rpc_gss_lock, "gsslock");
}
SYSINIT(svc_rpc_gss_init, SI_SUB_VFS, SI_ORDER_ANY,
svc_rpc_gss_init, NULL);
static void
svc_rpc_gss_cleanup(void *unused __unused)
{
sx_destroy(&svc_rpc_gss_lock);
}
SYSUNINIT(svc_rpc_gss_cleanup, SI_SUB_VFS, SI_ORDER_ANY,
svc_rpc_gss_cleanup, NULL);
static void
svc_rpc_gss_vnetinit(void *unused __unused)
{
int i;
@ -214,26 +233,20 @@ svc_rpc_gss_init(void *unused __unused)
for (i = 0; i < svc_rpc_gss_client_hash_size; i++)
TAILQ_INIT(&KGSS_VNET(svc_rpc_gss_client_hash)[i]);
TAILQ_INIT(&KGSS_VNET(svc_rpc_gss_clients));
if (IS_DEFAULT_VNET(curvnet)) {
svc_auth_reg(RPCSEC_GSS, svc_rpc_gss, rpc_gss_svc_getcred);
sx_init(&svc_rpc_gss_lock, "gsslock");
}
}
VNET_SYSINIT(svc_rpc_gss_init, SI_SUB_VNET_DONE, SI_ORDER_ANY,
svc_rpc_gss_init, NULL);
VNET_SYSINIT(svc_rpc_gss_vnetinit, SI_SUB_VNET_DONE, SI_ORDER_ANY,
svc_rpc_gss_vnetinit, NULL);
static void
svc_rpc_gss_cleanup(void *unused __unused)
svc_rpc_gss_vnet_cleanup(void *unused __unused)
{
mem_free(KGSS_VNET(svc_rpc_gss_client_hash),
sizeof(struct svc_rpc_gss_client_list) *
svc_rpc_gss_client_hash_size);
if (IS_DEFAULT_VNET(curvnet))
sx_destroy(&svc_rpc_gss_lock);
}
VNET_SYSUNINIT(svc_rpc_gss_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY,
svc_rpc_gss_cleanup, NULL);
VNET_SYSUNINIT(svc_rpc_gss_vnet_cleanup, SI_SUB_VNET_DONE, SI_ORDER_ANY,
svc_rpc_gss_vnet_cleanup, NULL);
bool_t
rpc_gss_set_callback(rpc_gss_callback_t *cb)