Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 11 Feb 2018 18:37:08 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r329128 - head/sys/kgssapi
Message-ID:  <201802111837.w1BIb8Oo075573@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: brooks
Date: Sun Feb 11 18:37:08 2018
New Revision: 329128
URL: https://svnweb.freebsd.org/changeset/base/329128

Log:
  Use syscall_helper_register(9) rather than syscall_register().
  
  The usage is simpler, documented, and more common.
  
  Reviewed by:	cem
  Sponsored by:	DARPA, AFRL
  Differential Revision:	https://reviews.freebsd.org/D14227

Modified:
  head/sys/kgssapi/gss_impl.c

Modified: head/sys/kgssapi/gss_impl.c
==============================================================================
--- head/sys/kgssapi/gss_impl.c	Sun Feb 11 17:45:38 2018	(r329127)
+++ head/sys/kgssapi/gss_impl.c	Sun Feb 11 18:37:08 2018	(r329128)
@@ -56,39 +56,33 @@ MALLOC_DEFINE(M_GSSAPI, "GSS-API", "GSS-API");
 /*
  * Syscall hooks
  */
-static int gssd_syscall_offset = SYS_gssd_syscall;
-static struct sysent gssd_syscall_prev_sysent;
-MAKE_SYSENT(gssd_syscall);
-static bool_t gssd_syscall_registered = FALSE;
+static struct syscall_helper_data gssd_syscalls[] = {
+	SYSCALL_INIT_HELPER(gssd_syscall),
+	SYSCALL_INIT_LAST
+};
 
 struct kgss_mech_list kgss_mechs;
 CLIENT *kgss_gssd_handle;
 struct mtx kgss_gssd_lock;
 
-static void
-kgss_init(void *dummy)
+static int
+kgss_load(void)
 {
 	int error;
 
 	LIST_INIT(&kgss_mechs);
-	error = syscall_register(&gssd_syscall_offset, &gssd_syscall_sysent,
-	    &gssd_syscall_prev_sysent, SY_THR_STATIC_KLD);
-	if (error)
-		printf("Can't register GSSD syscall\n");
-	else
-		gssd_syscall_registered = TRUE;
+	error = syscall_helper_register(gssd_syscalls, SY_THR_STATIC_KLD);
+	if (error != 0)
+		return (error);
+	return (0);
 }
-SYSINIT(kgss_init, SI_SUB_LOCK, SI_ORDER_FIRST, kgss_init, NULL);
 
 static void
-kgss_uninit(void *dummy)
+kgss_unload(void)
 {
 
-	if (gssd_syscall_registered)
-		syscall_deregister(&gssd_syscall_offset,
-		    &gssd_syscall_prev_sysent);
+	syscall_helper_unregister(gssd_syscalls);
 }
-SYSUNINIT(kgss_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, kgss_uninit, NULL);
 
 int
 sys_gssd_syscall(struct thread *td, struct gssd_syscall_args *uap)
@@ -293,6 +287,8 @@ kgssapi_modevent(module_t mod, int type, void *data)
 
 	switch (type) {
 	case MOD_LOAD:
+		if (error != 0)
+			return (error);
 		rpc_gss_entries.rpc_gss_refresh_auth = rpc_gss_refresh_auth;
 		rpc_gss_entries.rpc_gss_secfind = rpc_gss_secfind;
 		rpc_gss_entries.rpc_gss_secpurge = rpc_gss_secpurge;
@@ -317,8 +313,11 @@ kgssapi_modevent(module_t mod, int type, void *data)
 		rpc_gss_entries.rpc_gss_svc_max_data_length =
 		    rpc_gss_svc_max_data_length;
 		mtx_init(&kgss_gssd_lock, "kgss_gssd_lock", NULL, MTX_DEF);
+		error = kgss_load();
 		break;
 	case MOD_UNLOAD:
+		kgss_unload();
+		mtx_destroy(&kgss_gssd_lock);
 		/*
 		 * Unloading of the kgssapi module is not currently supported.
 		 * If somebody wants this, we would need to keep track of



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802111837.w1BIb8Oo075573>