Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 23 Jan 2019 16:34:54 +0700
From:      Alexey Dokuchaev <danfe@nsu.ru>
To:        net@freebsd.org
Subject:   Why rpcb_getaddr(3) uses UDP even for TCP NFS mounts?
Message-ID:  <20190123093454.GA87168@regency.nsu.ru>

next in thread | raw e-mail | index | archive | help
Hi there,

I've recently encountered a problem that my NFS box was not directly
accessible to one of its clients.  I've forwarded TCP ports for the
rpcbind(8), mountd(8), and nfsd(8) with ssh(1), but mount_nfs(8) did
not work, that is, with -o tcp,proto=tcp.

Running it under truss(1) revealed something odd:

    socket(PF_INET,SOCK_DGRAM,IPPROTO_UDP) = 3 (0x3)
    ...
    sendto(3,"blah-blah"...,56,0,{ AF_INET <ip-address>:111 },16) = 56 (0x38)
    <hangs here>

Only after I've forwarded port 111 via UDP, it worked as expected.
Apparently, this happens inside rpcb_getaddr(3), and there is no easy
way to create SOCK_STREAM/IPPROTO_TCP socket, which kind of prevents
working with NFSv3 in a pure TCP environment, as forcing TCP mounts via
-o tcp,proto=tcp is useless, per /usr/src/lib/libc/rpc/rpcb_clnt.c:

...
#ifdef PORTMAP
	...
	/*
	 * Try UDP only - there are some portmappers out
	 * there that use UDP only.
	 */

Is there a reason for this behavior (apart from what the comment says,
ignoring the fact that it is 2019 now), and more importantly, correct
way to avoid talking to the rpcbind(8) via UDP?

./danfe



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20190123093454.GA87168>