Re: [RFC] Making mount_nfs to attempt NFSv4 before NFSv3 and NFSv2?

From: Tomoaki AOKI <junchoon_at_dec.sakura.ne.jp>
Date: Tue, 04 Jan 2022 00:07:47 UTC
I myself never used NFS, but I don't think it a POLA violation,
because...
  *Keeping latest-stable (formerly, v3?) to oldest (v2) order.

  *Usually, once new version is considered stable, security fixes
   are first done on the latest, then backported to older revs,
   causing delay. It can cause fatal security incident for servers.
   So always as newer as possible rev should be always preferred
   unless no specific rev is specified.

But development versions would better not automatically selected.
If v4 is already considered as production quality on FreeBSD,
it would be best preferred first on automatic selection.

On Mon, 3 Jan 2022 10:51:31 -0800
Xin Li via freebsd-current <freebsd-current@freebsd.org> wrote:

> Hi,
> 
> Currently, mount_nfs will attempt to use NFSv3 and fallback to NFSv2. 
> The manual page says:
> 
>       nfsv2   Use the NFS Version 2 protocol (the default is to try
>               version 3 first then version 2).  Note that NFS version 2
>               has a file size limit of 2 gigabytes.
> 
> And the code agrees, too:
> 
> %%%%%%%%
>          if (trymntmode == V4) {
>                  nfsvers = 4;
>                  mntvers = 3; /* Workaround for GCC. */
>          } else if (trymntmode == V2) {
>                  nfsvers = 2;
>                  mntvers = 1;
>          } else {
>                  nfsvers = 3;
>                  mntvers = 3;
>          }
> %%%%%%%%
> 
> When trymntmode == ANY, which is the default, mount_nfs would attempt 
> NFSv3, and if rpcb_getaddr() returned RPC_PROGVERSMISMATCH, it would try 
> again with trymntmode = V2.
> 
> Nowadays, it seems that NFSv4 is becoming more and more popular.  If a 
> server is providing only NFSv4 service, when mounting without -o nfsv4, 
> the user would receive message like:
> 
> 	RPCPROG_MNT: RPC:Timed out
> 
> A friend of mine who is using TrueNAS core hit this yesterday and his 
> Linux client worked just fine.  It took me some time to figure out that 
> the root cause.  It seems that modern Linux distributions have been 
> using NFSv4 by default for some time.
> 
> So I think it makes sense to teach mount_nfs to attempt NFSv4, then 
> NFSv3 and NFSv2.  However, this might be a POLA violation and we would 
> like to know if there is any objections.
> 
> (I've attached a patch but I haven't actually tested it yet).
> 
> Cheers,


-- 
Tomoaki AOKI    <junchoon@dec.sakura.ne.jp>