[Bug 2049262] Re: mount.nfs: fix version negotiation laddering with parameters '-t nfs4' or '-o vers=4'
Heitor Alves de Siqueira
2049262 at bugs.launchpad.net
Thu Feb 22 16:34:55 UTC 2024
Hi Matthew,
thank you for the detailed description! Patches look good, and seem to be clean cherry-picks on top of Focal.
I've tested your changes and they seem to be working correctly, autopkgtest looks good as well.
I cleaned up some trailing whitespace on your changelog entry, but
otherwise left it untouched. Sponsored for Focal, thank you!
--
You received this bug notification because you are a member of Ubuntu
Foundations Bugs, which is subscribed to nfs-utils in Ubuntu.
https://bugs.launchpad.net/bugs/2049262
Title:
mount.nfs: fix version negotiation laddering with parameters '-t nfs4'
or '-o vers=4'
Status in nfs-utils package in Ubuntu:
Fix Released
Status in nfs-utils source package in Focal:
In Progress
Bug description:
[Impact]
Calling mount.nfs with parameters '-t nfs4' or '-o vers=4' will
default to attempting to connect with version 4.0 only, and if the
server does not support 4.0, the mount will fail.
The expected behaviour is first default to negotiating version 4.2,
and if that fails, then 4.1, and then 4.0, before raising an error.
This laddering approach was specified and agreed upon in:
commit f980298853d9b12a222421342418732f65883c30
Author: Benjamin Coddington <bcodding at redhat.com>
Date: Mon Dec 8 15:51:07 2014 -0500
Subject: mount.nfs: configurable minor version defaults
Link: https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=f980298853d9b12a222421342418732f65883c30
first introduced in nfs-utils in 2014, in version 1.3.2-rc6, and is
included in the version offered in focal.
This behaviour works when you don't specify a version at all, or even
specify nfs at all to the mount command.
A graphical explanation of the laddering approach is:
------------------
| nfsmount.conf |-----------------------------------
| Defaultvers= | arg option | attempts: |
|---------------------------------------------------|
| 4.2 | not set | v4.2 v4.1 v4.0 v3 |
| 4.2 | v4 | v4.2 v4.1 v4.0 |
| 4.1 | not set | v4.1 v4.0 v3 |
| 4.1 | v4 | v4.1 v4.0 |
| 4 | not set | v4.0 v3 |
| 4 | v4 | v4.0 |
| 3 | not set | v3 |
| any set | v4.2 | v4.2 |
| any set | v4.1 | v4.1 |
| any set | v4 | v4.0 |
| any set | v3 | v3 |
| not set | not set | v4.2 v4.1 v4.0 v3 |
-----------------------------------------------------
This should also apply to using the command line arguments '-t nfs4' or '-o vers=4' matching existing and current upstream designs.
[Testcase]
Create two VMs, one jammy and one focal.
The jammy VM will be the server.
Server VM:
$ sudo hostnamectl set-hostname jammy-nfs-server
$ sudo apt update && sudo apt upgrade -y
$ sudo apt install nfs-kernel-server
$ sudo mkdir /export
$ sudo mkdir /export/users
$ sudo mkdir /home/users
$ sudo vi /etc/fstab # add the following line:
/home/users /export/users none bind 0 0
$ sudo mount -a
$ sudo vi /etc/exports # add the following lines:
/export 192.168.122.0/24(rw,fsid=0,no_subtree_check,sync)
/export/users 192.168.122.0/24(rw,nohide,insecure,no_subtree_check,sync)
$ sudo vi /etc/nfs.conf # Under [nfsd], uncomment / change the following lines:
vers2=n
vers3=n
#vers4=y
vers4.0=n
vers4.1=y
vers4.2=y
$ sudo systemctl restart nfs-server.service
$ sudo cat /proc/fs/nfsd/versions # confirm nfs 4.0 is not allowed
-2 -3 +4 -4.0 +4.1 +4.2
Focal VM:
$ sudo hostnamectl set-hostname focal-nfs-client
$ sudo apt update && sudo apt upgrade -y
$ sudo apt install nfs-common
And then try to mount using '-o vers=4':
$ sudo mount -o vers=4 -vvv jammy-nfs-server:/ /mnt
You will see:
$ sudo mount -o vers=4 -vvv jammy-nfs-server:/ /mnt
mount.nfs: timeout set for Fri Jan 19 00:44:42 2024
mount.nfs: trying text-based options 'vers=4,addr=192.168.122.13,clientaddr=192.168.122.106'
mount.nfs: mount(2): Protocol not supported
mount.nfs: Protocol not supported
Test packages are available in the following ppa:
https://launchpad.net/~mruffell/+archive/ubuntu/sf377082-test
If you install the test package, you will see:
$ sudo mount -o vers=4 -vvv jammy-nfs-server:/ /mnt
mount.nfs: timeout set for Fri Jan 19 00:46:09 2024
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.122.13,clientaddr=192.168.122.106'
$ ll /mnt
total 12
drwxr-xr-x 3 root root 4096 Jan 17 22:30 ./
drwxr-xr-x 19 root root 4096 Jan 19 00:41 ../
drwxr-xr-x 2 root root 4096 Jan 17 22:30 users/
If you disable v4.2 on the jammy nfs server VM, and try and reconnect, we see
the laddering to 4.1:
$ sudo mount -o vers=4 -vvv jammy-nfs-server:/ /mnt
mount.nfs: timeout set for Fri Jan 19 00:53:43 2024
mount.nfs: trying text-based options 'vers=4.2,addr=192.168.122.13,clientaddr=192.168.122.106'
mount.nfs: mount(2): Protocol not supported
mount.nfs: trying text-based options 'vers=4.1,addr=192.168.122.13,clientaddr=192.168.122.106'
:~$ ll /mnt
total 12
drwxr-xr-x 3 root root 4096 Jan 17 22:30 ./
drwxr-xr-x 19 root root 4096 Jan 19 00:41 ../
drwxr-xr-x 2 root root 4096 Jan 17 22:30 users/
[Where problems could occur]
We are changing the default protocol negotiation code for mount.nfs,
so specifying '-t nfs4' or '-o vers=4' will no longer default to 4.0,
instead, it will now attempt 4.2, 4.1, 4.0 in a laddering fashion.
This may cause a different NFS version to be selected on mount, if the
fstab or shell scripts system administers use '-t nfs4' or '-o vers=4'
instead of specifying a specific version.
e.g. 4.2 may be selected instead of 4.0 used previously. This could
have an impact on workloads if there are any regressions in switching
to 4.2 from 4.0 etc. Network traffic may be different as newer
protocols are used.
The dependency commit "mount.nfs: improve version negotiation when
vers=4 is specified." also fixed a few bugs, with the most impactful
being that in some cases mount.nfs would downgrade from v4 to v3, even
when v4 was explicity asked for, if a particular namespace was
available in v3, but not in v4, e.g. by fsid=0.
If a regression were to occur, users could have trouble mounting NFS
v4.x shares as a client.
NFS server has no changes.
[Other info]
This was fixed in nfs-utils 2.1.2-rc4 by the following commits:
commit d406648690fa0fdf5333d7d54cf8210dab7f4d9c
Author: NeilBrown <neilb at suse.com>
Date: Thu Jun 1 09:42:16 2017 -0400
Subject: mount.nfs: improve version negotiation when vers=4 is specified.
Link: https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=d406648690fa0fdf5333d7d54cf8210dab7f4d9c
commit 62a4d95854e5cda4b772fa132cbd16c4429412c8
Author: Steve Dickson <steved at redhat.com>
Date: Tue Jun 13 12:00:39 2017 -0400
Subject: mount.nfs: Use default minor version when -t nfs4 is specified
Link: https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=62a4d95854e5cda4b772fa132cbd16c4429412c8
commit 90790d3129cf6f5fe095cf01e37d2d0a89d8dbec
Author: Steve Dickson <steved at redhat.com>
Date: Mon Jun 19 11:19:55 2017 -0400
Subject: mount.nfs: Use default minor version when -o v4 is specified
Link: https://git.linux-nfs.org/?p=steved/nfs-utils.git;a=commitdiff;h=90790d3129cf6f5fe095cf01e37d2d0a89d8dbec
These are found in Jammy and later.
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/nfs-utils/+bug/2049262/+subscriptions
More information about the foundations-bugs
mailing list