aboutsummaryrefslogtreecommitdiff
path: root/sys/nlm
Commit message (Collapse)AuthorAgeFilesLines
* Use syscall_helper_register() to register syscalls and initialize thoughBrooks Davis2018-02-101-24/+13
| | | | | | | | | | | | | | 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 Notes: svn path=/head/; revision=329097
* Do pass removing some write-only variables from the kernel.Alexander Kabaev2017-12-251-4/+0
| | | | | | | | | | | | This reduces noise when kernel is compiled by newer GCC versions, such as one used by external toolchain ports. Reviewed by: kib, andrew(sys/arm and sys/arm64), emaste(partial), erj(partial) Reviewed by: jhb (sys/dev/pci/* sys/kern/vfs_aio.c and sys/kern/kern_synch.c) Differential Revision: https://reviews.freebsd.org/D10385 Notes: svn path=/head/; revision=327173
* sys: general adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-275-0/+10
| | | | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. No functional change intended. Notes: svn path=/head/; revision=326272
* Commit the 64-bit inode project.Konstantin Belousov2017-05-231-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Extend the ino_t, dev_t, nlink_t types to 64-bit ints. Modify struct dirent layout to add d_off, increase the size of d_fileno to 64-bits, increase the size of d_namlen to 16-bits, and change the required alignment. Increase struct statfs f_mntfromname[] and f_mntonname[] array length MNAMELEN to 1024. ABI breakage is mitigated by providing compatibility using versioned symbols, ingenious use of the existing padding in structures, and by employing other tricks. Unfortunately, not everything can be fixed, especially outside the base system. For instance, third-party APIs which pass struct stat around are broken in backward and forward incompatible ways. Kinfo sysctl MIBs ABI is changed in backward-compatible way, but there is no general mechanism to handle other sysctl MIBS which return structures where the layout has changed. It was considered that the breakage is either in the management interfaces, where we usually allow ABI slip, or is not important. Struct xvnode changed layout, no compat shims are provided. For struct xtty, dev_t tty device member was reduced to uint32_t. It was decided that keeping ABI compat in this case is more useful than reporting 64-bit dev_t, for the sake of pstat. Update note: strictly follow the instructions in UPDATING. Build and install the new kernel with COMPAT_FREEBSD11 option enabled, then reboot, and only then install new world. Credits: The 64-bit inode project, also known as ino64, started life many years ago as a project by Gleb Kurtsou (gleb). Kirk McKusick (mckusick) then picked up and updated the patch, and acted as a flag-waver. Feedback, suggestions, and discussions were carried by Ed Maste (emaste), John Baldwin (jhb), Jilles Tjoelker (jilles), and Rick Macklem (rmacklem). Kris Moore (kris) performed an initial ports investigation followed by an exp-run by Antoine Brodin (antoine). Essential and all-embracing testing was done by Peter Holm (pho). The heavy lifting of coordinating all these efforts and bringing the project to completion were done by Konstantin Belousov (kib). Sponsored by: The FreeBSD Foundation (emaste, kib) Differential revision: https://reviews.freebsd.org/D10439 Notes: svn path=/head/; revision=318736
* When sleeping waiting for either local or remote advisory lock,Konstantin Belousov2016-06-262-4/+13
| | | | | | | | | | | | | | | | | | | interrupt sleeps with the ERESTART on the suspension attempts. Otherwise, single-threading requests are deferred until the locks are granted for NFS files, which causes hangs. When retrying local registration of the remotely-granted adv lock, allow full suspension and check for suspension, for usual reasons. Reported by: markj, pho Reviewed by: jilles Tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks Approved by: re (gjb) Notes: svn path=/head/; revision=302216
* Remote and local adv lock servers might de-synchronize (the added commentKonstantin Belousov2016-06-191-1/+31
| | | | | | | | | | | | | | | | | explains the plausible scenario), resulting in EDEADLK returned on the local registration attempt. Handle this by re-trying the local op [1]. On unmount, local registration abort is indicated as EINTR, abort the nlm call as well. Reported and tested by: pho Suggested and reviewed by: dfr (previous version, [1]) Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (delphij) Notes: svn path=/head/; revision=302020
* After the vnode unlock, mount point might be destroyed immediately,Konstantin Belousov2016-06-181-5/+9
| | | | | | | | | | | | | | dropping the reference on mnt_cred. Prevent this by referencing the temporal credentials before unlock. Tested by: pho Reviewed by: dfr Sponsored by: The FreeBSD Foundation MFC after: 1 week Approved by: re (gjb) Notes: svn path=/head/; revision=302013
* Remove slightly used const values that can be replaced with nitems().Pedro F. Giffuni2016-04-211-2/+1
| | | | | | | Suggested by: jhb Notes: svn path=/head/; revision=298411
* Avoid a possible heap overflow in our nlm code by limiting the numberSean Bruno2016-04-201-0/+6
| | | | | | | | | | | | | | of service to the arbitrary value of 256. Log an appropriate message that indicates the hard limit. PR: 208808 Submitted by: cturt@hardenedbsd.org Reviewed by: dfr Obtained from: HardenedBSD MFC after: 2 weeks Notes: svn path=/head/; revision=298351
* Avoid dynamic syscall overhead for statically compiled modules.Mateusz Guzik2014-10-261-1/+1
| | | | | | | | | | | | | | | | The kernel tracks syscall users so that modules can safely unregister them. But if the module is not unloadable or was compiled into the kernel, there is no need to do this. Achieve this by adding SY_THR_STATIC_KLD macro which expands to SY_THR_STATIC during kernel build and 0 otherwise. Reviewed by: kib (previous version) MFC after: 2 weeks Notes: svn path=/head/; revision=273707
* Correct a typo in nlm_find_host_by_addr(): the intention of theXin LI2014-03-111-1/+1
| | | | | | | | | | code is to give "<unknown>" rather than comparing the buffer against it. MFC after: 2 weeks Notes: svn path=/head/; revision=262991
* Intermittent crashes in the NLM (rpc.lockd) code during systemRick Macklem2013-09-061-75/+52
| | | | | | | | | | | | | | | | | | | | | | shutdown was reporetd via email. The crashes occurred because the client side NLM would attempt to use its socket after it had been destroyed. Looking at the code, it would soclose() once the reference count on the socket handling structure went to 0. Unfortunately, nlm_host_get_rpc() will simply allocate a new socket handling structure when none exists and use the now soclose()d socket. Since there doesn't seem to be a safe way to determine when the socket is no longer needed, this patch modifies the code so that it never soclose()es the socket. Since there is only one socket ever created, this does not introduce a leak when the rpc.lockd is stopped/restarted. The patch also disables unloading of the nfslockd module, since it is not safe to do so (and has never been safe to do so, from what I can see). Reported by: mav Tested by: mav MFC after: 2 weeks Notes: svn path=/head/; revision=255333
* Remove the support for using non-mpsafe filesystem modules.Konstantin Belousov2012-10-221-3/+0
| | | | | | | | | | | | | | | In particular, do not lock Giant conditionally when calling into the filesystem module, remove the VFS_LOCK_GIANT() and related macros. Stop handling buffers belonging to non-mpsafe filesystems. The VFS_VERSION is bumped to indicate the interface change which does not result in the interface signatures changes. Conducted and reviewed by: attilio Tested by: pho Notes: svn path=/head/; revision=241896
* Fix grammar.Konstantin Belousov2012-08-161-1/+1
| | | | | | | | Submitted by: jh MFC after: 1 week Notes: svn path=/head/; revision=239328
* Add a sysctl kern.pid_max, which limits the maximum pid the system isKonstantin Belousov2012-08-151-0/+1
| | | | | | | | | | allowed to allocate, and corresponding tunable with the same name. Note that existing processes with higher pids are left intact. MFC after: 1 week Notes: svn path=/head/; revision=239301
* jwd@ reported a problem via email to freebsd-fs@ on Aug 25, 2011Rick Macklem2012-01-311-28/+46
| | | | | | | | | | | | | | | | | | | under the subject "F_RDLCK lock to FreeBSD NFS fails to R/O target file". This occurred because the server side NLM always checked for VWRITE access, irrespective of the type of lock request. This patch replaces VOP_ACCESS(..VWRITE..) with one appropriate to the lock operation. It allows unlock and lock cancellation to be done without a check of VOP_ACCESS(), so that files can't be left locked indefinitely after the file permissions have been changed. Discussed with: zack Submitted by: jwd (earlier version) Reviewed by: dfr MFC after: 2 weeks Notes: svn path=/head/; revision=230801
* Mark all SYSCTL_NODEs static that have no corresponding SYSCTL_DECLs.Ed Schouten2011-11-071-2/+3
| | | | | | | | | The SYSCTL_NODE macro defines a list that stores all child-elements of that node. If there's no SYSCTL_DECL macro anywhere else, there's no reason why it shouldn't be static. Notes: svn path=/head/; revision=227309
* In order to maximize the re-usability of kernel code in user space thisKip Macy2011-09-161-1/+1
| | | | | | | | | | | | | | | | patch modifies makesyscalls.sh to prefix all of the non-compatibility calls (e.g. not linux_, freebsd32_) with sys_ and updates the kernel entry points and all places in the code that use them. It also fixes an additional name space collision between the kernel function psignal and the libc function of the same name by renaming the kernel psignal kern_psignal(). By introducing this change now we will ease future MFCs that change syscalls. Reviewed by: rwatson Approved by: re (bz) Notes: svn path=/head/; revision=225617
* Add a lock flags argument to the VFS_FHTOVP() file systemRick Macklem2011-05-221-1/+1
| | | | | | | | | | | | | | method, so that callers can indicate the minimum vnode locking requirement. This will allow some file systems to choose to return a LK_SHARED locked vnode when LK_SHARED is specified for the flags argument. This patch only adds the flag. It does not change any file system to use it and all callers specify LK_EXCLUSIVE, so file system semantics are not changed. Reviewed by: kib Notes: svn path=/head/; revision=222167
* sysctl(9) cleanup checkpoint: amd64 GENERIC builds cleanly.Matthew D Fleming2011-01-121-2/+2
| | | | | | | Commit the kernel changes. Notes: svn path=/head/; revision=217326
* Fix the nlm so that it no longer depends on the regularRick Macklem2011-01-032-6/+3
| | | | | | | | | | | nfs client and, as such, can be loaded for the experimental nfs client without the regular client. Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=216931
* Modify the NFS clients and the NLM so that the NLM can be usedRick Macklem2010-10-192-12/+7
| | | | | | | | | | | | | | | | by both clients. Since the NLM uses various fields of the nfsmount structure, those fields were extracted and put in a separate nfs_mountcommon structure stored in sys/nfs/nfs_mountcommon.h. This structure also has a function pointer for a function that extracts the required information from the mount point and nfs vnode for that particular client, for information stored differently by the clients. Reviewed by: jhb MFC after: 2 weeks Notes: svn path=/head/; revision=214048
* Make the RPC specific __rpc_inet_ntop() and __rpc_inet_pton() generalAttilio Rao2010-09-241-2/+2
| | | | | | | | | | | | | in the kernel (just as inet_ntoa() and inet_aton()) are and sync their prototype accordingly with already mentioned functions. Sponsored by: Sandvine Incorporated Reviewed by: emaste, rstone Approved by: dfr MFC after: 2 weeks Notes: svn path=/head/; revision=213103
* Handle GRANTED_RES messages more gracefully: Send along a grant cookieZachary Loafman2009-10-073-18/+152
| | | | | | | | | | | | to reference the lock, look up the grant cookie when the GRANTED_RES comes back. Properly handle the case of an error on the grant. Add a short expiration window so that granted locks are not freed immediately. Approved by: dfr (mentor) MFC after: 2 weeks Notes: svn path=/head/; revision=197840
* unifdef NFSCLIENT because the nlm depends on the nfsclient even if NFSCLIENTYoshihiro Takahashi2009-10-031-13/+0
| | | | | | | | | | | | is not defined. Now the nfslockd module works with the nfsclient module. Reviewed by: kib MFC after: 3 days Notes: svn path=/head/; revision=197730
* Since svc_[dg|vc|tli|tp]_create() did not hold a reference count on theRick Macklem2009-06-171-1/+5
| | | | | | | | | | | | | | | | SVCXPTR structure returned by them, it was possible for the structure to be free'd before svc_reg() had been completed using the structure. This patch acquires a reference count on the newly created structure that is returned by svc_[dg|vc|tli|tp]_create(). It also adds the appropriate SVC_RELEASE() calls to the callers, except the experimental nfs subsystem. The latter will be committed separately. Submitted by: dfr Tested by: pho Approved by: kib (mentor) Notes: svn path=/head/; revision=194407
* Rename the host-related prison fields to be the same as the host.*Jamie Gritton2009-06-131-1/+1
| | | | | | | | | | parameters they represent, and the variables they replaced, instead of abbreviated versions of them. Approved by: bz (mentor) Notes: svn path=/head/; revision=194118
* Correct typo; errno => error.Ed Schouten2009-06-041-1/+1
| | | | Notes: svn path=/head/; revision=193434
* Don't panic in nlm_record_lock if we get ENOENT from lf_advlockasync. ThisDoug Rabson2009-06-041-2/+2
| | | | | | | | is likely to be because the file was just removed and in our context this is harmless. Notes: svn path=/head/; revision=193432
* Place hostnames and similar information fully under the prison system.Jamie Gritton2009-05-291-7/+5
| | | | | | | | | | | | | | | | | | | | The system hostname is now stored in prison0, and the global variable "hostname" has been removed, as has the hostname_mtx mutex. Jails may have their own host information, or they may inherit it from the parent/system. The proper way to read the hostname is via getcredhostname(), which will copy either the hostname associated with the passed cred, or the system hostname if you pass NULL. The system hostname can still be accessed directly (and without locking) at prison0.pr_host, but that should be avoided where possible. The "similar information" referred to is domainname, hostid, and hostuuid, which have also become prison parameters and had their associated global variables removed. Approved by: bz (mentor) Notes: svn path=/head/; revision=193066
* Remove the unmaintained University of Michigan NFSv4 client from 8.xRobert Watson2009-05-221-1/+1
| | | | | | | | | | prior to 8.0-RELEASE. Rick Macklem's new and more feature-rich NFSv234 client and server are replacing it. Discussed with: rmacklem Notes: svn path=/head/; revision=192578
* Add a function to sys/nlm/nlm_prot_impl.c that returns a uniqueRick Macklem2009-05-212-0/+19
| | | | | | | | | | | | lock sysid to be used for non-nlm remote locking. This is required for the experimental nfsv4 server, so that it can acquire byte range locks correctly on behalf of nfsv4 clients. Reviewed by: dfr Approved by: kib (mentor) Notes: svn path=/head/; revision=192501
* Do not embed struct ucred into larger netcred parent structures.Alexander Kabaev2009-05-091-1/+4
| | | | | | | | | | | | | | | | Credential might need to hang around longer than its parent and be used outside of mnt_explock scope controlling netcred lifetime. Use separate reference-counted ucred allocated separately instead. While there, extend mnt_explock coverage in vfs_stdexpcheck and clean-up some unused declarations in new NFS code. Reported by: John Hickey PR: kern/133439 Reviewed by: dfr, kib Notes: svn path=/head/; revision=191940
* Work around non-standard behaviour of rpcbind in some versions of Linux (FC4?).Doug Rabson2009-05-091-14/+17
| | | | | | | Submitted by: zachary dot loafman at isilon dot com Notes: svn path=/head/; revision=191937
* Use log(9) for debug and status messages and hide some of the details withDoug Rabson2009-05-081-68/+60
| | | | | | | | | macros to allow for future flexibility in logging. Submitted by: zachary dot loafman at isilon dot com Notes: svn path=/head/; revision=191918
* Introduce a new virtualization container, provisionally named vprocg, to holdMarko Zec2009-05-081-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | virtualized instances of hostname and domainname, as well as a new top-level virtualization struct vimage, which holds pointers to struct vnet and struct vprocg. Struct vprocg is likely to become replaced in the near future with a new jail management API import. As a consequence of this change, change struct ucred to point to a struct vimage, instead of directly pointing to a vnet. Merge vnet / vimage / ucred refcounting infrastructure from p4 / vimage branch. Permit kldload / kldunload operations to be executed only from the default vimage context. This change should have no functional impact on nooptions VIMAGE kernel builds. Reviewed by: bz Approved by: julian (mentor) Notes: svn path=/head/; revision=191915
* Don't call svc_freereq() before svc_freeargs().Doug Rabson2008-11-121-1/+1
| | | | Notes: svn path=/head/; revision=184886
* Implement support for RPCSEC_GSS authentication to both the NFS clientDoug Rabson2008-11-034-78/+121
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and server. This replaces the RPC implementation of the NFS client and server with the newer RPC implementation originally developed (actually ported from the userland sunrpc code) to support the NFS Lock Manager. I have tested this code extensively and I believe it is stable and that performance is at least equal to the legacy RPC implementation. The NFS code currently contains support for both the new RPC implementation and the older legacy implementation inherited from the original NFS codebase. The default is to use the new implementation - add the NFS_LEGACYRPC option to fall back to the old code. When I merge this support back to RELENG_7, I will probably change this so that users have to 'opt in' to get the new code. To use RPCSEC_GSS on either client or server, you must build a kernel which includes the KGSSAPI option and the crypto device. On the userland side, you must build at least a new libc, mountd, mount_nfs and gssd. You must install new versions of /etc/rc.d/gssd and /etc/rc.d/nfsd and add 'gssd_enable=YES' to /etc/rc.conf. As long as gssd is running, you should be able to mount an NFS filesystem from a server that requires RPCSEC_GSS authentication. The mount itself can happen without any kerberos credentials but all access to the filesystem will be denied unless the accessing user has a valid ticket file in the standard place (/tmp/krb5cc_<uid>). There is currently no support for situations where the ticket file is in a different place, such as when the user logged in via SSH and has delegated credentials from that login. This restriction is also present in Solaris and Linux. In theory, we could improve this in future, possibly using Brooks Davis' implementation of variant symlinks. Supporting RPCSEC_GSS on a server is nearly as simple. You must create service creds for the server in the form 'nfs/<fqdn>@<REALM>' and install them in /etc/krb5.keytab. The standard heimdal utility ktutil makes this fairly easy. After the service creds have been created, you can add a '-sec=krb5' option to /etc/exports and restart both mountd and nfsd. The only other difference an administrator should notice is that nfsd doesn't fork to create service threads any more. In normal operation, there will be two nfsd processes, one in userland waiting for TCP connections and one in the kernel handling requests. The latter process will create as many kthreads as required - these should be visible via 'top -H'. The code has some support for varying the number of service threads according to load but initially at least, nfsd uses a fixed number of threads according to the value supplied to its '-n' option. Sponsored by: Isilon Systems MFC after: 1 month Notes: svn path=/head/; revision=184588
* Rename RPC's 'struct pmap' to 'struct portmap' to avoid confusing it withDoug Rabson2008-08-251-2/+2
| | | | | | | | | | the other 'struct pmap'. Pointed out by: kmacy MFC after: 2 weeks Notes: svn path=/head/; revision=182154
* Add a missing return statement in nlm4_unlock_msg_4_svc which prevented itDoug Rabson2008-08-251-0/+1
| | | | | | | | | | | | from returning a reply message in most cases. This in turn caused interoperability problems with Mac OS X clients. PR: 126561 Submitted by: Richard.Conto at gmail.com MFC after: 1 week Notes: svn path=/head/; revision=182153
* Fix an interop issue with Linux: If you do nothing but TCPDoug Rabson2008-08-131-54/+115
| | | | | | | | | | | | | | mounts, Linux won't even bother registering nlockmgr for UDP. This causes nlm_get_rpc to fail, which means any attempts to deliver the GRANTED callback fail. Add code to nlm_get_rpc to try to locate the TCP version as well. If it finds it on TCP, it establishes a clnt_reconnect to the host. Submitted by: zachary.loafman at isilon.com MFC after: 2 weeks Notes: svn path=/head/; revision=181683
* Introduce a new lock, hostname_mtx, and use it to synchronize accessRobert Watson2008-07-051-0/+4
| | | | | | | | | | | | | | | to global hostname and domainname variables. Where necessary, copy to or from a stack-local buffer before performing copyin() or copyout(). A few uses, such as in cd9660 and daemon_saver, remain under-synchronized and will require further updates. Correct a bug in which a failed copyin() of domainname would leave domainname potentially corrupted. MFC after: 3 weeks Notes: svn path=/head/; revision=180291
* Add module dependancy on nfs.Doug Rabson2008-07-031-0/+1
| | | | Notes: svn path=/head/; revision=180217
* Fixing NO_INET6 build.Tai-hwa Liang2008-06-271-1/+4
| | | | Notes: svn path=/head/; revision=180069
* Re-implement the client side of rpc.lockd in the kernel. This implementationDoug Rabson2008-06-266-470/+2125
| | | | | | | | | | | | | | | provides the correct semantics for flock(2) style locks which are used by the lockf(1) command line tool and the pidfile(3) library. It also implements recovery from server restarts and ensures that dirty cache blocks are written to the server before obtaining locks (allowing multiple clients to use file locking to safely share data). Sponsored by: Isilon Systems PR: 94256 MFC after: 2 weeks Notes: svn path=/head/; revision=180025
* Back out the nlm_global_lock part of the last change - I forgot that onlyDoug Rabson2008-06-031-1/+0
| | | | | | | | | exists in my perforce branch :( Pointy hat: dfr Notes: svn path=/head/; revision=179510
* When attempting to use the NSM state number in a lock request to detectDoug Rabson2008-06-021-8/+10
| | | | | | | | | | | | | a client reboot, do this check before performing the lock otherwise we will trash the new lock along with any other old locks the client held before rebooting. Make sure nlm_check_idle always returns with nlm_global_lock held. MFC after: 1 week Notes: svn path=/head/; revision=179488
* Don't rely on NSM to help us forget about RPC client handles forDoug Rabson2008-05-301-6/+17
| | | | | | | | | | | clients that have rebooted (or otherwise changed port numbers). If the client is broken or has no active locks, it won't notify us. Fall back on the two minute timeout logic used by the userland rpc.lockd code. MFC after: 1 week Notes: svn path=/head/; revision=179425
* Tighten up the error-handling in nlm_get_rpc. While I'm here, fix aDoug Rabson2008-04-161-3/+7
| | | | | | | couple of spelling mistakes in comments. Notes: svn path=/head/; revision=178241
* Fix some issues that showed up during Kris' testing.Doug Rabson2008-04-111-14/+28
| | | | | | | | Reported by: kris MFC after: 3 days Notes: svn path=/head/; revision=178112