sahlberg / libnfs

NFS client library
Other
510 stars 200 forks source link

Specifying custom (non-2049) port number with RFC 1738 <hostport> URL syntax does not work #447

Closed gisburn closed 5 months ago

gisburn commented 5 months ago

Specifying custom (non-2049) port number with RFC 1738 URL syntax does not work. See https://datatracker.ietf.org/doc/html/rfc1738 , description of "hostport" (hostname:portnumber)

# in this case I just use 2049, not it does not work with any number
$ nfs-ls  nfs://derfwnb4966_ipv4:2049//bigdisk                                                                                                                                                                                                                          
Failed to mount nfs share : nfs_mount_async failed
sahlberg commented 5 months ago

Please try this with current master. It works here.

Note that libnfs defaults to version3 and the mount process differs between nfsv3 and nfsv4.

In nfsv4 there is no portmapper used so a client, like libnfs, will connect directory to the port used by the server. This defaults to port 2049. To connect to a nfsv4 server that uses a different port you need to specify BOTH the port to use as well as that version=4 should be used.

Example: ./utils/nfs-ls nfs://10.10.10.11:2050/data/SNAP-4/\?version=4 I.e. connect to NFSv4 server on port 2050

In nfsv3 the process is different. By default, the portmapper service is used to discover the ports on the server but also the pound protocol is used. There process here is 1, use portmapper to discover the port for MOUND 2, use MOUND to find the root filehandle for he share 3, user pormapper to discover the port for NFSD 4, connect to NFSD

When you specify : on he URL, or use he "nfsport=" URL argument his only affects step 3. In his case 3, is skipped and here is no portmapper call to discover NFSD. Insead in sep 4, we connect directly to he specified port.

In NFS3, we will need to connect to MOUNTD before we switch to NFS since we still need to discover the root handle. .If you use NFSv3 bu do not have a portmapper you can use the "mountport=" URL argumentt to tell libnfs where o find MOUNTD.

On Fri, 22 Mar 2024 at 22:53, Roland Mainz @.***> wrote:

Specifying custom (non-2049) port number with RFC 1738 URL syntax does not work. See https://datatracker.ietf.org/doc/html/rfc1738 , description of "hostport" (hostname:portnumber)

in this case I just use 2049, not it does not work with any number

$ nfs-ls nfs://derfwnb4966_ipv4:2049//bigdisk Failed to mount nfs share : nfs_mount_async failed

— Reply to this email directly, view it on GitHub https://github.com/sahlberg/libnfs/issues/447, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADY3ECM2WV2PGOR2FIPPTDYZQSWNAVCNFSM6AAAAABFDIZZ76VHI2DSMVQWIX3LMV43ASLTON2WKOZSGIYDENBTGQZTANA . You are receiving this because you are subscribed to this thread.Message ID: @.***>