kern/56461: FreeBSD client rpc.lockd incompatible with Linux server rpc.lockd

Bruce M Simpson bms at
Fri Jun 18 12:01:06 GMT 2004

The following reply was made to PR kern/56461; it has been noted by GNATS.

From: Bruce M Simpson <bms at>
To: freebsd-net at
Cc: alfred at, kris at,
	Jonathan Lennox <lennox at>,
	freebsd-gnats-submit at
Subject: Re: kern/56461: FreeBSD client rpc.lockd incompatible with Linux server rpc.lockd
Date: Fri, 18 Jun 2004 12:49:30 +0100

 Content-Type: multipart/mixed; boundary="mJm6k4Vb/yFcL9ZU"
 Content-Disposition: inline
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 I've attached my thoughts on this issue. I haven't gone ahead and
 committed the fix in the PR as it makes us just as braindead as Linux,
 but it would be good to be able to have this in GENERIC so that it
 can be enabled in those situations where it's needed.
 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: attachment; filename="lockd-linux-compat.txt"
 Linux NFS advisory locks are broken and incompatible with the rest
 of the world. FreeBSD 5.x in particular uses BSD/OS derived NFS code
 and thus is affected. FreeBSD 4.x does not implement client-side NFS
 advisory locks.
 This problem is also documented as existing for MacOS X, IRIX and BSD/OS:
 The patch provided in the PR is verified to solve the problem, but
 it would be good to make this functionality optional at run-time,
 as many people are likely to be using Linux NFS shares read/write
 with advisory locks.
 The addition of pid_start to struct lockd_msg_ident is what triggered
 this problem. The offending member is referenced by the NFS code, and
 rpc.lockd itself.
 The kernel interface code for rpc.lockd resides in
 LOCKD_MSG is what gets passed from the kernel to rpc.lockd via the
 named pipe /var/run/lock.
 NFSCLNT_LOCKDANS is used by lockd to send a response back. struct
 lockd_ans is the structure passed via this syscall. The kernel code
 for this is in nfslockdans(), in src/sys/nfsclient/nfs_lock.c.
 Proposed solution:
 Actual NLM request conversion to/from the kernel happens in rpc.lockd;
 there are several places in kern.c, notably test_request() and
 lock_request(), which reference struct nlm4_testargs, struct nlm_testargs,
 struct nlm_lockargs, and struct nlm4_lockargs.
 These are defined in src/include/rpcsvc/nlm_prot.x.
 XXX Are the lockd cookies different from the regular NFS filehandles?
 	arg4.cookie.n_bytes = (char *)&msg->lm_msg_ident;
 	arg4.cookie.n_len = sizeof(msg->lm_msg_ident);
 There's no need to change this structure, just the number of bytes
 provided by it; the lm_msg_ident structure needs to change if we're
 doing Linux compatbility, and is probably best served by adding
 a sysctl to keep track of whether we're in this mode or not.
 So embedding a union of structs in lm_msg_ident is probably the way to go,
 and taking the sizeof() the embedded struct as appropriate.
 I would suggest adding a sysctl to the tree: vfs.nfs.pid_start_locks,
 "Use process start time as well as PID to differentiate client-side NFS locks".
 This should be referenced from nfslockdans() as per the original patch
 to check if the timercmp comparison should be skipped.
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 Comment: ''

More information about the freebsd-bugs mailing list