First subset of nfs-utils IPv6 support
Subsystems (2)
cover First subset of nfs-utils IPv6 support
Hi Steve-
I sent these out yesterday, but I haven't seen them on the list or in mail archives. Ah. It's because I didn't copy the list! So, here goes.
These two patches introduce a set of library functions that replace the separate AF_INET-only implementations in each component of nfs-utils (mount.nfs, showmount, sm-notify, etc) of GETPORT with a common shared implementation that supports both PMAP_GETPORT and RPCB_GETADDR, and both AF_INET and AF_INET6. Subsequent patches will convert each component to use these.
These should build and operate correctly on systems without any trace of libtirpc libraries or headers. On such systems, only PMAP_GETPORT and AF_INET is supported.
I think these are ready to be included in nfs-utils, so let's start the review process.
---
Chuck Lever (2):
nfs-utils: Introduce rpcbind client utility functions
nfs-utils: Add AF_INET6-capable API to acquire an RPC CLIENT *
configure.ac | 6 support/include/nfsrpc.h | 141 +++++++ support/nfs/Makefile.am | 2 support/nfs/getport.c | 965 ++++++++++++++++++++++++++++++++++++++++++++++ support/nfs/rpc_socket.c | 528 +++++++++++++++++++++++++ 5 files changed, 1641 insertions(+), 1 deletions(-) create mode 100644 support/include/nfsrpc.h create mode 100644 support/nfs/getport.c create mode 100644 support/nfs/rpc_socket.c
Signature · 1 line
Chuck Lever
A message that is not in the archive (sent off-list or not yet received): 20081029172134.19663.13493.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org
PATCH 1/2 nfs-utils: Add AF_INET6-capable API to acquire an RPC CLIENT *
Provide a simple interface that any component of nfs-utils can use to acquire an RPC CLIENT *. This is an AF_INET6-enabled API, and can also handle PF_LOCAL sockets if libtirpc is present on the system.
When libtirpc is not available, legacy RPC services will be used instead, and an attempt to connect to an AF_INET6 address will fail.
---
configure.ac | 6 + support/include/nfsrpc.h | 70 ++++++ support/nfs/Makefile.am | 2 support/nfs/rpc_socket.c | 528 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 605 insertions(+), 1 deletions(-) create mode 100644 support/include/nfsrpc.h create mode 100644 support/nfs/rpc_socket.c
configure.ac +6 -0
@@ -178,6 +178,12 @@ AC_CHECK_FUNC(connect, , AC_CHECK_FUNC(getaddrinfo, , , AC_MSG_ERROR(Function 'getaddrinfo' not found.)) +AC_CHECK_FUNC(getrpcbynumber, , , + AC_MSG_ERROR(Function 'getrpcbynumber' not found.)) + +AC_CHECK_FUNC(getservbyname, , , + AC_MSG_ERROR(Function 'getservbyname' not found.)) + AC_CHECK_LIB(crypt, crypt, [LIBCRYPT="-lcrypt"]) if test "$enable_nfsv4" = yes; then AC_CHECK_LIB(event, event_dispatch, [libevent=1], AC_MSG_ERROR([libevent needed for nfsv4 support]))
support/include/nfsrpc.h new file +70 -0
70 lines not on this page · raw message
support/nfs/Makefile.am +1 -1
@@ -3,7 +3,7 @@ noinst_LIBRARIES = libnfs.a libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ xlog.c xcommon.c wildmat.c nfssvc.c nfsclient.c \ - nfsexport.c getfh.c nfsctl.c \ + nfsexport.c getfh.c nfsctl.c rpc_socket.c \ svc_socket.c cacheio.c closeall.c nfs_mntent.c MAINTAINERCLEANFILES = Makefile.in
support/nfs/rpc_socket.c new file +528 -0
528 lines not on this page · raw message
PATCH 2/2 nfs-utils: Introduce rpcbind client utility functions
In reply to a message not in the archiveIt turns out that at least the mount command and the showmount command need to query a server's rpcbind daemon. They need to query over AF_INET6 as well as AF_INET.
libtirpc provides an rpcbind query capability with the rpcb_getaddr(3) interface, but it takes a hostname and netconfig entry rather than a sockaddr and a protocol type, and always uses a lengthy timeout. The former is important to the mount command because it sometimes must operate using a specific port and IP address rather than depending on rpcbind and DNS to convert a [hostname, RPC program, netconfig] tuple to a [socket address, port number, transport protocol] tuple.
The rpcb_getaddr(3) API also always uses a privileged port (at least for setuid root executables like mount.nfs), which is not required for an rpcbind query. This can exhaust the local system's reserved port space quickly.
This patch provides a reserved-port-friendly AF_INET6-capable rpcbind query C API that can be shared among commands and tools in nfs-utils, and allows a query to a specified socket address and port rather than a hostname.
In addition to an rpcbind query interface, this patch also provides a facility to ping the remote RPC service to ensure that it is operating as advertised by rpcbind. It's useful to combine an RPC ping with an rpcbind query because in many cases, components of nfs-utils already ping an RPC service immediately after receiving a successful GETPORT result.
There are also a handful of utility routines provided, such as a functions that can map between [sockaddr, port] and a universal address.
I've made an attempt to make these new functions build and operate on systems that do not have libtirpc.
---
support/include/nfsrpc.h | 71 +++ support/nfs/Makefile.am | 2 support/nfs/getport.c | 965 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1037 insertions(+), 1 deletions(-) create mode 100644 support/nfs/getport.c
support/include/nfsrpc.h +71 -0
@@ -67,4 +67,75 @@ extern CLIENT *nfs_get_rpcclient(const struct sockaddr *, const rpcprog_t, const rpcvers_t, struct timeval *); +/* +* Convert a socket address to a universal address +*/ +extern char *nfs_sockaddr2universal (const struct sockaddr *, +const socklen_t ); + +/* +* Extract port number from a universal address +*/ +extern int nfs_universal2port (const char *); + +/* +* Generic function that maps an RPC service tuple to an IP port +* number of the service on a remote post, and sends a NULL +* request to determine if the service is responding to requests +*/ +extern int nfs_getport_ping (struct sockaddr *sap, +const socklen_t salen, +const rpcprog_t program, +const rpcvers_t version, +const unsigned short protocol); + +/* +* Generic function that maps an RPC service tuple to an IP port +* number of the service on a remote host +*/ +extern unsigned short nfs_getport (const struct sockaddr *, +const socklen_t ,const rpcprog_t , +const rpcvers_t ,const unsigned short ); + +/* +* Generic function that maps an RPC service tuple to an IP port +* number of the service on the local host +*/ +extern unsigned short nfs_getlocalport (const rpcprot_t , +const rpcvers_t ,const unsigned short ); + +/* +* Function to invoke an rpcbind v3/v4 GETADDR request +*/ +extern unsigned short nfs_rpcb_getaddr (const struct sockaddr *, +const socklen_t , +const unsigned short , +const struct sockaddr *, +const socklen_t , +const rpcprog_t , +const rpcvers_t , +const unsigned short , +const struct timeval *); + +/* +* Function to invoke a portmap GETPORT request +*/ +extern unsigned long nfs_pmap_getport (const struct sockaddr_in *, +const unsigned short , +const unsigned long , +const unsigned long , +const unsigned long , +const struct timeval *); + +/* +* Contact a remote RPC service to discover whether it is responding +* to requests. +*/ +extern int nfs_rpc_ping (const struct sockaddr *sap, +const socklen_t salen, +const rpcprog_t program, +const rpcvers_t version, +const unsigned short protocol, +const struct timeval *timeout); +#endif /* __NFS_UTILS_NFSRPC_H */
support/nfs/Makefile.am +1 -1
@@ -3,7 +3,7 @@ noinst_LIBRARIES = libnfs.a libnfs_a_SOURCES = exports.c rmtab.c xio.c rpcmisc.c rpcdispatch.c \ xlog.c xcommon.c wildmat.c nfssvc.c nfsclient.c \ - nfsexport.c getfh.c nfsctl.c rpc_socket.c \ + nfsexport.c getfh.c nfsctl.c rpc_socket.c getport.c \ svc_socket.c cacheio.c closeall.c nfs_mntent.c MAINTAINERCLEANFILES = Makefile.in
support/nfs/getport.c new file +965 -0
965 lines not on this page · raw message
Quoted 17 lines · Chuck Lever
Hi Steve-
I sent these out yesterday, but I haven't seen them on the list or in mail archives. Ah. It's because I didn't copy the list! So, here goes.
These two patches introduce a set of library functions that replace the separate AF_INET-only implementations in each component of nfs-utils (mount.nfs, showmount, sm-notify, etc) of GETPORT with a common shared implementation that supports both
PMAP_GETPORTandRPCB_GETADDR, and bothAF_INETandAF_INET6. Subsequent patches will convert each component to use these.These should build and operate correctly on systems without any trace of libtirpc libraries or headers. On such systems, only
PMAP_GETPORTandAF_INETis supported.
Quoted 8 lines
I think these are ready to be included in nfs-utils, so let's start the review process.
---
Chuck Lever (2):
nfs-utils: Introduce rpcbind client utility functions
nfs-utils: Add AF_INET6-capable API to acquire an RPC CLIENT *
I apologize for the delay... Both committed..
steved.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Steve Dickson
Quoted 20 lines · Chuck Lever
Hi Steve-
I sent these out yesterday, but I haven't seen them on the list or in mail archives. Ah. It's because I didn't copy the list! So, here goes.
These two patches introduce a set of library functions that replace the separate AF_INET-only implementations in each component of nfs-utils (mount.nfs, showmount, sm-notify, etc) of GETPORT with a common shared implementation that supports both
PMAP_GETPORTandRPCB_GETADDR, and bothAF_INETandAF_INET6. Subsequent patches will convert each component to use these.These should build and operate correctly on systems without any trace of libtirpc libraries or headers. On such systems, only
PMAP_GETPORTandAF_INETis supported.I think these are ready to be included in nfs-utils, so let's start the review process.
Quoted 6 lines
Quoted 5 lines
---
Chuck Lever (2):
nfs-utils: Introduce rpcbind client utility functions
nfs-utils: Add AF_INET6-capable API to acquire an RPC CLIENT *I apologize for the delay... Both committed..
Hi Steve-
I don't see the new file support/nfs/getport.c in your tree. This should have been added by commit 541bf913.
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Quoted 27 lines · Chuck Lever
Quoted 26 lines · Steve Dickson
Quoted 25 lines · Chuck Lever
Hi Steve-
I sent these out yesterday, but I haven't seen them on the list or in mail archives. Ah. It's because I didn't copy the list! So, here goes.
These two patches introduce a set of library functions that replace the separate AF_INET-only implementations in each component of nfs-utils (mount.nfs, showmount, sm-notify, etc) of GETPORT with a common shared implementation that supports both
PMAP_GETPORTandRPCB_GETADDR, and bothAF_INETandAF_INET6. Subsequent patches will convert each component to use these.These should build and operate correctly on systems without any trace of libtirpc libraries or headers. On such systems, only
PMAP_GETPORTandAF_INETis supported.I think these are ready to be included in nfs-utils, so let's start the review process.
---
Chuck Lever (2):
nfs-utils: Introduce rpcbind client utility functions
nfs-utils: Add AF_INET6-capable API to acquire an RPC CLIENT *
Quoted 6 lines
Quoted 1 line
I apologize for the delay... Both committed..
Hi Steve-
I don't see the new file
support/nfs/getport.cin your tree. This should have been added by commit541bf913.
Its there now... Sorry about that...
steved.