Skip to contentSkip to conversation

lockd: Fix comment about NLMv3 backwards compatibility

PATCH Applied Pali Rohár 4 participants 9 messages Sep 12, 2024 – Oct 18, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lockd: Fix comment about NLMv3 backwards compatibility

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +3 -1
index a3e97278b997..81ffa521f945 100644
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

#2 lore raw
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

#3 lore raw
Quoted 32 lines · On Friday 13 September 2024 01:22:07 Pali Rohár wrote:
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *
Quoted 8 lines
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

Just very quickly I found this Illumos XDR file for NLM:
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/rpcsvc/nlm_prot.x

And it defines NLMv2 with two procedures numbered 17 and 18, plus there is a comment in file header about v2.

So probably the best reference would be the Illumos source code.

#4 lore raw
Quoted 42 lines · Pali Rohár
Quoted 32 lines · On Friday 13 September 2024 01:22:07 Pali Rohár wrote:
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *
Quoted 8 lines
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

Quoted 7 lines

Just very quickly I found this Illumos XDR file for NLM:
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/rpcsvc/nlm_prot.x

And it defines NLMv2 with two procedures numbered 17 and 18, plus there is a comment in file header about v2.

So probably the best reference would be the Illumos source code.

What you see in the Illumos code is not something that is part of the standard NLM protocol, but rather a private upcall protocol between the kernel and user space that is special sauce added by each implementation of NLM/NSM.

Also note the way NLMv3 is defined in this file: it defines only a handful of new operations. The other operations are inherited from NLMv1.

IMO the comment is accurate and does not warrant a change.

Signature · 1 line
Chuck Lever
#5 lore raw
Quoted 49 lines · On Thursday 12 September 2024 19:34:02 Chuck Lever wrote:
Quoted 48 lines · Pali Rohár
Quoted 32 lines · On Friday 13 September 2024 01:22:07 Pali Rohár wrote:
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
 fs/lockd/clntxdr.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
  * linux/fs/lockd/clntxdr.c
  *
  * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
  *
  * NLM client-side only.
  *
Quoted 8 lines
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

Just very quickly I found this Illumos XDR file for NLM:
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/rpcsvc/nlm_prot.x

And it defines NLMv2 with two procedures numbered 17 and 18, plus there is a comment in file header about v2.

Quoted 6 lines
Quoted 1 line

So probably the best reference would be the Illumos source code.

What you see in the Illumos code is not something that is part of the standard NLM protocol, but rather a private upcall protocol between the kernel and user space that is special sauce added by each implementation of NLM/NSM.

Ok. But this applies for v2, no?

Quoted 3 lines

Also note the way NLMv3 is defined in this file: it defines only a handful of new operations. The other operations are inherited from NLMv1.

Yes, v3 is there and is inherited from v1. This is also what I pointed in the comment. That v3 inherits from v1, not v2.

In header file of that nlm_prot.x is written:

* There are currently 3 versions of the protocol in use. Versions 1
* and 3 are used with NFS version 2. Version 4 is used with NFS
* version 3.
*
* (Note: there is also a version 2, but it defines an orthogonal set of
* procedures that the status monitor uses to notify the lock manager of
* changes in monitored systems.)

Which sounds like version 3 has nothing with version 2.

My understanding of that comment is that version 2 contains only those private upcall protocol between kernel and userspace about which you wrote, and therefore version 3 is not backward compatible with version 2.

Quoted 1 line

IMO the comment is accurate and does not warrant a change.

#6 lore raw
Quoted 54 lines · Pali Rohár
Quoted 49 lines · On Thursday 12 September 2024 19:34:02 Chuck Lever wrote:
Quoted 48 lines · Pali Rohár
Quoted 32 lines · On Friday 13 September 2024 01:22:07 Pali Rohár wrote:
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
fs/lockd/clntxdr.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
 * linux/fs/lockd/clntxdr.c
 *
 * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
 *
 * NLM client-side only.
 *
Quoted 8 lines
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

Just very quickly I found this Illumos XDR file for NLM:
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/rpcsvc/nlm_prot.x

And it defines NLMv2 with two procedures numbered 17 and 18, plus there is a comment in file header about v2.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

So probably the best reference would be the Illumos source code.

What you see in the Illumos code is not something that is part of the standard NLM protocol, but rather a private upcall protocol between the kernel and user space that is special sauce added by each implementation of NLM/NSM.

Ok. But this applies for v2, no?

On Linux, those operations are part of the NLMv1/3/4 protocol implementation, so essentially the NLM v2 functionality is a part of all NLM versions on Linux.

Quoted 6 lines
Quoted 3 lines

Also note the way NLMv3 is defined in this file: it defines only a handful of new operations. The other operations are inherited from NLMv1.

Yes, v3 is there and is inherited from v1. This is also what I pointed in the comment. That v3 inherits from v1, not v2.

Generally this is an abuse of the purpose of the RPC program versioning mechanism. Linux has a very similar upcall mechanism, but uses NLM procedure numbers that are set aside for this purpose instead of abusing a moribund protocol version.

Quoted 10 lines

In header file of that nlm_prot.x is written:

* There are currently 3 versions of the protocol in use. Versions 1
* and 3 are used with NFS version 2. Version 4 is used with NFS
* version 3.
*
* (Note: there is also a version 2, but it defines an orthogonal set of
* procedures that the status monitor uses to notify the lock manager of
* changes in monitored systems.)

Quoted 7 lines

Which sounds like version 3 has nothing with version 2.

My understanding of that comment is that version 2 contains only those private upcall protocol between kernel and userspace about which you wrote, and therefore version 3 is not backward compatible with version 2.

Quoted 1 line

IMO the comment is accurate and does not warrant a change.

How about this replacement:

* XDR functions to encode/decode NLM version 1 and 3 RPC
* arguments and results. NLM version 2 is not specified
* by a standard, thus it is not implemented.

--
Chuck Lever

#7 lore raw
Quoted 70 lines · On Saturday 05 October 2024 17:52:13 Chuck Lever III wrote:
Quoted 52 lines · Pali Rohár
Quoted 49 lines · On Thursday 12 September 2024 19:34:02 Chuck Lever wrote:
Quoted 48 lines · Pali Rohár
Quoted 32 lines · On Friday 13 September 2024 01:22:07 Pali Rohár wrote:
Quoted 31 lines · On Friday 13 September 2024 09:10:45 NeilBrown wrote:
Quoted 17 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

---
fs/lockd/clntxdr.c | 4 +++-

1 file changed, 3 insertions(+), 1 deletion(-)
fs/lockd/clntxdr.c +0 -0
index a3e97278b997..81ffa521f945 100644

fs/lockd/clntxdr.c line 11

Quoted 10 lines
fs/lockd/clntxdr.c +3 -1
@@ -3,7 +3,9 @@
 * linux/fs/lockd/clntxdr.c
 *
 * XDR functions to encode/decode NLM version 3 RPC arguments and results.
- * NLM version 3 is backwards compatible with NLM versions 1 and 2.
+ * NLM version 3 is backwards compatible with NLM version 1.
+ * NLM version 2 is different protocol used only for RPC loopback callbacks
+ * from statd to lockd and is not implemented on Linux.
 *
 * NLM client-side only.
 *
Quoted 8 lines
Quoted 4 lines

Do you have a reference for that info about v2? I hadn't heard of it before.

NeilBrown

I have just this information in my notes. I guess it should be possible to gather more information about v2 from released Sun/Solaris source code via OpenSolaris / Illumos projects.

Just very quickly I found this Illumos XDR file for NLM:
https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/rpcsvc/nlm_prot.x

And it defines NLMv2 with two procedures numbered 17 and 18, plus there is a comment in file header about v2.

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

So probably the best reference would be the Illumos source code.

What you see in the Illumos code is not something that is part of the standard NLM protocol, but rather a private upcall protocol between the kernel and user space that is special sauce added by each implementation of NLM/NSM.

Ok. But this applies for v2, no?

On Linux, those operations are part of the NLMv1/3/4 protocol implementation, so essentially the NLM v2 functionality is a part of all NLM versions on Linux.

Quoted 4 lines
Quoted 3 lines

Also note the way NLMv3 is defined in this file: it defines only a handful of new operations. The other operations are inherited from NLMv1.

Quoted 8 lines
Quoted 2 lines

Yes, v3 is there and is inherited from v1. This is also what I pointed in the comment. That v3 inherits from v1, not v2.

Generally this is an abuse of the purpose of the RPC program versioning mechanism. Linux has a very similar upcall mechanism, but uses NLM procedure numbers that are set aside for this purpose instead of abusing a moribund protocol version.

I agree that this abuse of the versioning scheme. But it is there and used in this way for a very long time.

Quoted 17 lines
Quoted 17 lines

In header file of that nlm_prot.x is written:

* There are currently 3 versions of the protocol in use. Versions 1
* and 3 are used with NFS version 2. Version 4 is used with NFS
* version 3.
*
* (Note: there is also a version 2, but it defines an orthogonal set of
* procedures that the status monitor uses to notify the lock manager of
* changes in monitored systems.)

Which sounds like version 3 has nothing with version 2.

My understanding of that comment is that version 2 contains only those private upcall protocol between kernel and userspace about which you wrote, and therefore version 3 is not backward compatible with version 2.

Quoted 7 lines
Quoted 1 line
Quoted 1 line

IMO the comment is accurate and does not warrant a change.

How about this replacement:

* XDR functions to encode/decode NLM version 1 and 3 RPC
* arguments and results. NLM version 2 is not specified
* by a standard, thus it is not implemented.

That is perfect! Covers everything.

maintainer Applied
#8 lore raw
In reply to Pali Rohár

From: Chuck Lever <[email protected]>

Quoted 8 lines · Pali Rohár

NLMv2 is completely different protocol than NLMv1 and NLMv3, and in original Sun implementation is used for RPC loopback callbacks from statd to lockd services. Linux does not use nor does not implement NLMv2.

Hence, NLMv3 is not backward compatible with NLMv2. But NLMv3 is backward compatible with NLMv1. Fix comment.

[...]

Applied to nfsd-next for v6.13, thanks!

[1/1] lockd: Fix comment about NLMv3 backwards compatibility

      commit: 6c64686e6bb8b5ec1e3cca4f495ba38341666745                                                                      
Signature · 1 line
Chuck Lever