sahlberg / libnfs

NFS client library
Other
510 stars 200 forks source link

nfs-ls does not work with NFSv4-only server #446

Closed gisburn closed 5 months ago

gisburn commented 5 months ago

nfs-ls does not work with NFSv4-only server

Example:

$ nfs-ls  nfs://derfwnb4966_ipv4//bigdisk
Failed to mount nfs share : mount/mnt call failed with "Server responded: Program version mismatch

NFS server is Debian 11 with Linux 6.6 LTS kernel, NFSv2 support is not build, and NFSv3 support has been disabled with "--no-nfs-version 3" per security policy requirements (e.g. only NFSv4.x is allowed):

# NFS versions support on server
$ cat /proc/fs/nfsd/versions 
-3 +4 +4.1 +4.2
gisburn commented 5 months ago

Is it possible to modify the libnfs-tools so they try NFSv4 first, or have an env var to set this ?

gisburn commented 5 months ago

BTW specifying version=4 does not work:

$ nfs-ls  nfs://derfwnb4966_ipv4//bigdisk
Failed to mount nfs share : mount/mnt call failed with "Server responded: Program version mismatch"

$ nfs-ls "nfs://derfwnb4966_ipv4//bigdisk?version=4"
Failed to mount nfs share : mount/mnt call failed with "Server responded: Program version mismatch"

$ nfs-ls "nfs://derfwnb4966_ipv4//bigdisk?version=4&nfsport=2049"
Failed to mount nfs share : mount/mnt call failed with "Server responded: Program version mismatch"
sahlberg commented 5 months ago

mount/mnt means it still tries to connect using nfsv3 and not v4. Mount protocol is only used with v3.

I have verified his works locally using: ./utils/nfs-ls nfs://10.10.10.11/data/SNAP-4/\?version=4

and in wireshark I see it connects directly to the default port 2049 and uses the nfsv4 protocol.

Try this with current master of libnfs.

sahlberg commented 5 months ago

I have tested this and it works on current master. I have also added a fall-back to try v4 mounts if v3 failed.

Unless you specify a specific version. In that case only that version will be tried and no fall-back will be attempted.