From owner-svn-src-all@freebsd.org Sat Feb 10 01:09:23 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9AE52F12277; Sat, 10 Feb 2018 01:09:23 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4E4A783595; Sat, 10 Feb 2018 01:09:23 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 485644CF0; Sat, 10 Feb 2018 01:09:23 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w1A19NqF004167; Sat, 10 Feb 2018 01:09:23 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w1A19N3R004166; Sat, 10 Feb 2018 01:09:23 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201802100109.w1A19N3R004166@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Sat, 10 Feb 2018 01:09:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r329097 - head/sys/nlm X-SVN-Group: head X-SVN-Commit-Author: brooks X-SVN-Commit-Paths: head/sys/nlm X-SVN-Commit-Revision: 329097 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Feb 2018 01:09:23 -0000 Author: brooks Date: Sat Feb 10 01:09:22 2018 New Revision: 329097 URL: https://svnweb.freebsd.org/changeset/base/329097 Log: Use syscall_helper_register() to register syscalls and initialize though the module interface. This is the more common approach and the syscall_helper interface is easier to understand. Reviewed by: jhb Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D14251 Modified: head/sys/nlm/nlm_prot_impl.c Modified: head/sys/nlm/nlm_prot_impl.c ============================================================================== --- head/sys/nlm/nlm_prot_impl.c Sat Feb 10 00:55:46 2018 (r329096) +++ head/sys/nlm/nlm_prot_impl.c Sat Feb 10 01:09:22 2018 (r329097) @@ -93,17 +93,10 @@ static SYSCTL_NODE(_vfs_nlm, OID_AUTO, sysid, CTLFLAG_ /* * Syscall hooks */ -static int nlm_syscall_offset = SYS_nlm_syscall; -static struct sysent nlm_syscall_prev_sysent; -#if __FreeBSD_version < 700000 -static struct sysent nlm_syscall_sysent = { - (sizeof(struct nlm_syscall_args) / sizeof(register_t)) | SYF_MPSAFE, - (sy_call_t *) nlm_syscall +static struct syscall_helper_data nlm_syscalls[] = { + SYSCALL_INIT_HELPER(nlm_syscall), + SYSCALL_INIT_LAST }; -#else -MAKE_SYSENT(nlm_syscall); -#endif -static bool_t nlm_syscall_registered = FALSE; /* * Debug level passed in from userland. We also support a sysctl hook @@ -287,8 +280,8 @@ ng_cookie(struct netobj *src) /* * Initialise NLM globals. */ -static void -nlm_init(void *dummy) +static int +nlm_init(void) { int error; @@ -296,24 +289,18 @@ nlm_init(void *dummy) TAILQ_INIT(&nlm_waiting_locks); TAILQ_INIT(&nlm_hosts); - error = syscall_register(&nlm_syscall_offset, &nlm_syscall_sysent, - &nlm_syscall_prev_sysent, SY_THR_STATIC_KLD); - if (error) + error = syscall_helper_register(nlm_syscalls, SY_THR_STATIC_KLD); + if (error != 0) NLM_ERR("Can't register NLM syscall\n"); - else - nlm_syscall_registered = TRUE; + return (error); } -SYSINIT(nlm_init, SI_SUB_LOCK, SI_ORDER_FIRST, nlm_init, NULL); static void -nlm_uninit(void *dummy) +nlm_uninit(void) { - if (nlm_syscall_registered) - syscall_deregister(&nlm_syscall_offset, - &nlm_syscall_prev_sysent); + syscall_helper_unregister(nlm_syscalls); } -SYSUNINIT(nlm_uninit, SI_SUB_LOCK, SI_ORDER_FIRST, nlm_uninit, NULL); /* * Create a netobj from an arbitrary source. @@ -2412,8 +2399,10 @@ nfslockd_modevent(module_t mod, int type, void *data) switch (type) { case MOD_LOAD: - return (0); + return (nlm_init()); + case MOD_UNLOAD: + nlm_uninit(); /* The NLM module cannot be safely unloaded. */ /* FALLTHROUGH */ default: