nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #4)
Subsystems (2)
cover nfs-utils: convert gssd to TI-RPC and add IPv6 support (try #4)
This patchset is the fourth attempt at adding support for IPv6 to rpc.gssd. The main change from the last set is that this one now uses a rpcbind query to determine the server's port rather than doing a getaddrinfo call to query the local services db.
The series should be fully bisectable, but I've only really tested the end result for anything other than to see if it compiles. With these patches I've been able to mount an OpenSolaris server using NFSv3/4 + IPv6 + krb5 auth. I've also done testing with builds with only TIRPC enabled and with TIRPC and IPv6 both disabled and haven't seen any regressions.
List of changes since the last set:
- use rpcbind query to determine port for RPC client
- added comment explaining gssd doesn't deal with IPv6 scope_id's
- slight cleanups and clarifications to comments
- properly handle EAI_SYSTEM return code from getnameinfo() call
- changed autoconf check for getnameinfo to check whenever --enable-gss is set, not just when NFSv4 is also enabled.
Jeff Layton (5):
nfs-utils: make getnameinfo() required for --enable-gss
nfs-utils: store the address given in the upcall for later use
nfs-utils: query for remote port using rpcbind instead of getaddrinfo
nfs-utils: switch gssd to use standard function for getting an RPC
client
nfs-utils: add IPv6 code to gssd
configure.ac | 3 + utils/gssd/gssd.h | 2 +- utils/gssd/gssd_proc.c | 286 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 204 insertions(+), 87 deletions(-)
PATCH 1/5 nfs-utils: make getnameinfo() required for --enable-gss
Systems that are so old that they don't have getnameinfo() in glibc are probably also running kernels that are so old that they don't support gssapi upcalls anyway.
Make --enable-gss dependent on the presence of the getnameinfo() function. This allows us to reduce some conditional compilation.
--- configure.ac | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
configure.ac +3 -0
@@ -236,6 +236,9 @@ AC_SUBST(LIBBSD) AC_SUBST(LIBBLKID) if test "$enable_gss" = yes; then + dnl 'gss' requires getnameinfo - at least for gssd_proc.c + AC_CHECK_FUNC([getnameinfo], , [AC_MSG_ERROR([GSSAPI support requires 'getnameinfo' function])]) + dnl 'gss' also depends on nfsidmap.h - at least for svcgssd_proc.c AC_LIBNFSIDMAP
Signature · 1 line
1.6.0.6
PATCH 2/5 nfs-utils: store the address given in the upcall for later use
In reply to Jeff LaytonThe current upcall could be more efficient. We first convert the address to a hostname, and then later when we set up the RPC client, we do a hostname lookup to convert it back to an address.
Begin to change this by keeping the address in the clnt_info that we get out of the upcall. Since a sockaddr has a port field, we can also eliminate the port from the clnt_info.
Finally, switch to getnameinfo() instead of gethostbyaddr(). We'll need to use that call anyway when we add support for IPv6.
--- utils/gssd/gssd.h | 2 +- utils/gssd/gssd_proc.c | 93 +++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 78 insertions(+), 17 deletions(-)
utils/gssd/gssd.h +1 -1
@@ -83,7 +83,7 @@ struct clnt_info {int krb5_poll_index;int spkm3_fd;int spkm3_poll_index; -int port; +struct sockaddr_storage addr; };void init_client_list (void );
utils/gssd/gssd_proc.c +77 -16
133 lines not on this page · raw message
Signature · 1 line
1.6.0.6
PATCH 3/5 nfs-utils: query for remote port using rpcbind instead of getaddrinfo
In reply to Jeff LaytonWe already have the server's address from the upcall, so we don't really need to look it up again, and querying the local services DB for the port that the remote server is listening on is just plain wrong.
Use rpcbind to set the port for the program and version that we were given in the upcall. The exception here is NFSv4. Since NFSv4 mounts are supposed to use a well-defined port then skip the rpcbind query for that and just set the port to the standard one (2049).
--- utils/gssd/gssd_proc.c | 126 +++++++++++++++++++++++++++++------------------- 1 files changed, 76 insertions(+), 50 deletions(-)
utils/gssd/gssd_proc.c +76 -50
@@ -72,6 +72,7 @@#include "gss_util.h" #include "krb5_util.h" #include "context.h" +#include "nfsrpc.h" /* * pollarray:
@@ -541,6 +542,64 @@ out_err: }/* +* If the port isn't already set, do an rpcbind query to the remote server +* using the program and version and get the port. Newer kernels send the +* port in the upcall, so this is really only for compatibility with older +* ones. +*/ +static int +populate_port (struct sockaddr *sa,const socklen_t salen, +const rpcprog_t program,const rpcvers_t version, +const unsigned short protocol) +{ +struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +unsigned short port; + +/* +* Newer kernels send the port in the upcall. If we already have +* the port, there's no need to look it up. +*/ +switch (sa->sa_family) { +case AF_INET : +if (s4->sin_port !=0 ) { +printerr (2 ,"DEBUG: port already set to %d\n" , +ntohs (s4->sin_port)); +return 1 ; + } +break ; +default : +printerr (0 ,"ERROR: unsupported address family %d\n" , + sa->sa_family); +return 0 ; + } + +/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + } + + port =nfs_getport (sa, salen, program, version, protocol); +if (!port) { +printerr (0 ,"ERROR: unable to obtain port for prog %ld " +"vers %ld\n" , program, version); +return 0 ; + } + +set_port: +printerr (2 ,"DEBUG: setting port to %hu for prog %lu vers %lu\n" , port, + program, version); + +switch (sa->sa_family) { +case AF_INET : + s4->sin_port =htons (port); +break ; + } + +return 1 ; +} + +/* * Create an RPC connection and establish an authenticated * gss context with a server. */
@@ -555,14 +614,13 @@ int create_auth_rpc_client(struct clnt_info *clp,AUTH *auth =NULL ;uid_t save_uid =-1 ;int retval =-1 ; -int errcode;OM_uint32 min_stat;char rpc_errmsg[1024 ];int sockp =RPC_ANYSOCK ;int sendsz =32768 , recvsz =32768 ; -struct addrinfo ai_hints, *a =NULL ; -char service[64 ]; -char *at_sign; +int protocol; +struct sockaddr *addr = (struct sockaddr *) &clp->addr; +socklen_t salen;/* Create the context as the user (not as root) */ save_uid =geteuid ();
@@ -616,15 +674,10 @@ int create_auth_rpc_client(struct clnt_info *clp,printerr (2 ,"creating %s client for server %s\n" , clp->protocol, clp->servername); -memset (&ai_hints,'\0' ,sizeof (ai_hints)); - ai_hints.ai_family =PF_INET ; - ai_hints.ai_flags |=AI_CANONNAME ;if ((strcmp (clp->protocol,"tcp" )) ==0 ) { - ai_hints.ai_socktype =SOCK_STREAM ; - ai_hints.ai_protocol =IPPROTO_TCP ; + protocol =IPPROTO_TCP ; }else if ((strcmp (clp->protocol,"udp" )) ==0 ) { - ai_hints.ai_socktype =SOCK_DGRAM ; - ai_hints.ai_protocol =IPPROTO_UDP ; + protocol =IPPROTO_UDP ; }else { printerr(0, "WARNING: unrecognized protocol, '%s', requested " "for connection to server %s for user with uid %d\n",
@@ -632,39 +685,22 @@ int create_auth_rpc_client(struct clnt_info *clp, goto out_fail; } -/* extract the service name from clp->servicename */ -if ((at_sign =strchr (clp->servicename,'@' )) ==NULL ) { -printerr (0 ,"WARNING: servicename (%s) not formatted as " -"expected with service@host\n" , clp->servicename); - goto out_fail; - } -if ((at_sign - clp->servicename) >=sizeof (service)) { -printerr (0 ,"WARNING: service portion of servicename (%s) " -"is too long!\n" , clp->servicename); +switch (addr->sa_family) { +case AF_INET : + salen =sizeof (struct sockaddr_in ); +break ; +default : +printerr (1 ,"ERROR: Unknown address family %d\n" , + addr->sa_family); goto out_fail; } -strncpy (service, clp->servicename, at_sign - clp->servicename); - service[at_sign - clp->servicename] ='\0' ; - errcode =getaddrinfo (clp->servername, service, &ai_hints, &a); -if (errcode) { -printerr (0 ,"WARNING: Error from getaddrinfo for server " -"'%s': %s\n" , clp->servername,gai_strerror (errcode)); +if (!populate_port (addr, salen, clp->prog, clp->vers, protocol)) goto out_fail; - } -if (a ==NULL ) { -printerr (0 ,"WARNING: No address information found for " -"connection to server %s for user with uid %d\n" , - clp->servername, uid); - goto out_fail; - } -if (((struct sockaddr_in ) clp->addr).sin_port !=0 ) - ((struct sockaddr_in *) a->ai_addr)->sin_port = - ((struct sockaddr_in ) clp->addr).sin_port; -if (a->ai_protocol ==IPPROTO_TCP ) { +if (protocol ==IPPROTO_TCP ) {if ((rpc_clnt =clnttcp_create ( - (struct sockaddr_in *) a->ai_addr, + (struct sockaddr_in *) addr, clp->prog, clp->vers, &sockp, sendsz, recvsz)) ==NULL ) { snprintf(rpc_errmsg, sizeof(rpc_errmsg),
@@ -675,10 +711,10 @@ int create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } - }else if (a->ai_protocol ==IPPROTO_UDP ) { + }else if (protocol ==IPPROTO_UDP ) {const struct timeval timeout = {5 ,0 };if ((rpc_clnt =clntudp_bufcreate ( - (struct sockaddr_in *) a->ai_addr, + (struct sockaddr_in *) addr, clp->prog, clp->vers, timeout, &sockp, sendsz, recvsz)) ==NULL ) { snprintf(rpc_errmsg, sizeof(rpc_errmsg),
@@ -689,16 +725,7 @@ int create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } - }else { -/* Shouldn't happen! */ -printerr (0 ,"ERROR: requested protocol '%s', but " -"got addrinfo with protocol %d\n" , - clp->protocol, a->ai_protocol); - goto out_fail; } -/* We're done with this */ -freeaddrinfo (a); - a =NULL ;printerr (2 ,"creating context with server %s\n" , clp->servicename); auth =authgss_create_default (rpc_clnt, clp->servicename, &sec);
@@ -720,7 +747,6 @@ int create_auth_rpc_client(struct clnt_info *clp, out:if (sec.cred !=GSS_C_NO_CREDENTIAL )gss_release_cred (&min_stat, &sec.cred); -if (a !=NULL )freeaddrinfo (a);/* Restore euid to original value */ if ((save_uid !=-1 ) && (setfsuid (save_uid) != uid)) { printerr(0, "WARNING: Failed to restore fsuid"
Signature · 1 line
1.6.0.6
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 61 lines · Jeff Layton
We already have the server's address from the upcall, so we don't really
need to look it up again, and querying the local services DB for the port that the remote server is listening on is just plain wrong.Use rpcbind to set the port for the program and version that we were given in the upcall. The exception here is NFSv4. Since NFSv4 mounts are supposed to use a well-defined port then skip the rpcbind query for that and just set the port to the standard one (2049).
Signed-off-by Jeff Layton <[email protected]>---
utils/gssd/gssd_proc.c| 126 ++++++++++++++++++++++++++++
+-------------------1 files changed, 76 insertions(+), 50 deletions(-)utils/gssd/gssd_proc.c +2
-0@@ -72,6 +72,7 @@#include "gss_util.h" #include "krb5_util.h" #include "context.h" +#include "nfsrpc.h" /* * pollarray: @@ -541,6 +542,64 @@ out_err: }/* +* If the port isn't already set, do an rpcbind query to the remote server
+ * using the program and version and get the port. Newer kernels send the
+ * port in the upcall, so this is really only for compatibility with older
+ * ones.
+ */utils/gssd/gssd_proc.c +21
-0+static int +populate_port (struct sockaddr *sa,const socklen_t salen, +const rpcprog_t program,const rpcvers_t version, +const unsigned short protocol) +{ +struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +unsigned short port; + +/* +* Newer kernels send the port in the upcall. If we already have +* the port, there's no need to look it up. +*/ +switch (sa->sa_family) { +case AF_INET : +if (s4->sin_port !=0 ) { +printerr (2 ,"DEBUG: port already set to %d\n" , +ntohs (s4->sin_port)); +return 1 ; + } +break ; +default :
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 10 lines
utils/gssd/gssd_proc.c +10
-0+printerr (0 ,"ERROR: unsupported address family %d\n" , + sa->sa_family); +return 0 ; + } + +/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }
I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the kernel always passed up the value it is using for port= on this mount point.
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049
Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that value
If the kernel always passes the port= setting to gssd, then it can follow the "if port value is zero, rpcbind; otherwise use port value as is" rule, and be sure to get correct NFSv4 behavior, even without the special case you added for NFSv4.
Quoted 157 lines
utils/gssd/gssd_proc.c +10
-0+ + port =nfs_getport (sa, salen, program, version, protocol); +if (!port) { +printerr (0 ,"ERROR: unable to obtain port for prog %ld " +"vers %ld\n" , program, version); +return 0 ; + } + +set_port: + printerr(2, "DEBUG: setting port to %hu for prog %lu vers %lu\n",port,
utils/gssd/gssd_proc.c +15
-4+ program, version); + +switch (sa->sa_family) { +case AF_INET : + s4->sin_port =htons (port); +break ; + } + +return 1 ; +} + +/* * Create an RPC connection and establish an authenticated * gss context with a server. */ @@ -555,14 +614,13 @@ int create_auth_rpc_client(struct clnt_info *clp,AUTH *auth =NULL ;uid_t save_uid =-1 ;int retval =-1 ; -int errcode;OM_uint32 min_stat;char rpc_errmsg[1024 ];int sockp =RPC_ANYSOCK ;int sendsz =32768 , recvsz =32768 ; -struct addrinfo ai_hints, *a =NULL ; -char service[64 ]; -char *at_sign; +int protocol; +struct sockaddr *addr = (struct sockaddr *) &clp->addr; +socklen_t salen;/* Create the context as the user (not as root) */ save_uid = geteuid();utils/gssd/gssd_proc.c +2
-7@@ -616,15 +674,10 @@ int create_auth_rpc_client(struct clnt_info *clp,printerr (2 ,"creating %s client for server %s\n" , clp->protocol, clp->servername); -memset (&ai_hints,'\0' ,sizeof (ai_hints)); - ai_hints.ai_family =PF_INET ; - ai_hints.ai_flags |=AI_CANONNAME ;if ((strcmp (clp->protocol,"tcp" )) ==0 ) { - ai_hints.ai_socktype =SOCK_STREAM ; - ai_hints.ai_protocol =IPPROTO_TCP ; + protocol =IPPROTO_TCP ; }else if ((strcmp (clp->protocol,"udp" )) ==0 ) { - ai_hints.ai_socktype =SOCK_DGRAM ; - ai_hints.ai_protocol =IPPROTO_UDP ; + protocol =IPPROTO_UDP ; }else { printerr(0, "WARNING: unrecognized protocol, '%s', requested ""for connection to server %s for user with uid %d\n",
utils/gssd/gssd_proc.c +10
-27@@ -632,39 +685,22 @@ int create_auth_rpc_client(struct clnt_info *clp, goto out_fail; } -/* extract the service name from clp->servicename */ -if ((at_sign =strchr (clp->servicename,'@' )) ==NULL ) { -printerr (0 ,"WARNING: servicename (%s) not formatted as " -"expected with service@host\n" , clp->servicename); - goto out_fail; - } -if ((at_sign - clp->servicename) >=sizeof (service)) { -printerr (0 ,"WARNING: service portion of servicename (%s) " -"is too long!\n" , clp->servicename); +switch (addr->sa_family) { +case AF_INET : + salen =sizeof (struct sockaddr_in ); +break ; +default : +printerr (1 ,"ERROR: Unknown address family %d\n" , + addr->sa_family); goto out_fail; } -strncpy (service, clp->servicename, at_sign - clp->servicename); - service[at_sign - clp->servicename] ='\0' ; - errcode =getaddrinfo (clp->servername, service, &ai_hints, &a); -if (errcode) { -printerr (0 ,"WARNING: Error from getaddrinfo for server " -"'%s': %s\n" , clp->servername,gai_strerror (errcode)); +if (!populate_port (addr, salen, clp->prog, clp->vers, protocol)) goto out_fail; - } -if (a ==NULL ) { -printerr (0 ,"WARNING: No address information found for " -"connection to server %s for user with uid %d\n" , - clp->servername, uid); - goto out_fail; - } -if (((struct sockaddr_in ) clp->addr).sin_port !=0 ) - ((struct sockaddr_in *) a->ai_addr)->sin_port = - ((struct sockaddr_in ) clp->addr).sin_port; -if (a->ai_protocol ==IPPROTO_TCP ) { +if (protocol ==IPPROTO_TCP ) {if ((rpc_clnt =clnttcp_create ( - (struct sockaddr_in *) a->ai_addr, + (struct sockaddr_in *) addr, clp->prog, clp->vers, &sockp, sendsz, recvsz)) ==NULL ) {snprintf(rpc_errmsg,
sizeof(rpc_errmsg),utils/gssd/gssd_proc.c +2
-2@@ -675,10 +711,10 @@ int create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } - }else if (a->ai_protocol ==IPPROTO_UDP ) { + }else if (protocol ==IPPROTO_UDP ) {const struct timeval timeout = {5 ,0 };if ((rpc_clnt =clntudp_bufcreate ( - (struct sockaddr_in *) a->ai_addr, + (struct sockaddr_in *) addr, clp->prog, clp->vers, timeout, &sockp, sendsz, recvsz)) ==NULL ) {snprintf(rpc_errmsg,
sizeof(rpc_errmsg),utils/gssd/gssd_proc.c +0
-10@@ -689,16 +725,7 @@ int create_auth_rpc_client(struct clnt_info *clp, clnt_spcreateerror(rpc_errmsg)); goto out_fail; } - }else { -/* Shouldn't happen! */ -printerr (0 ,"ERROR: requested protocol '%s', but " -"got addrinfo with protocol %d\n" , - clp->protocol, a->ai_protocol); - goto out_fail; } -/* We're done with this */ -freeaddrinfo (a); - a =NULL ;printerr (2 ,"creating context with server %s\n" , clp->servicename); auth =authgss_create_default (rpc_clnt, clp->servicename, &sec);@@ -720,7 +747,6 @@ int create_auth_rpc_client(struct clnt_info *clp, out:if (sec.cred !=GSS_C_NO_CREDENTIAL )gss_release_cred (&min_stat, &sec.cred); -if (a !=NULL )freeaddrinfo (a);/* Restore euid to original value */ if ((save_uid !=-1 ) && (setfsuid (save_uid) != uid)) { printerr(0, "WARNING: Failed to restore fsuid"Signature · 1 line
1.6.0.6
Signature · 2 lines
Chuck Lever chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 90 lines · Chuck Lever
Quoted 61 lines · Jeff Layton
We already have the server's address from the upcall, so we don't really
need to look it up again, and querying the local services DB for the port that the remote server is listening on is just plain wrong.Use rpcbind to set the port for the program and version that we were given in the upcall. The exception here is NFSv4. Since NFSv4 mounts are supposed to use a well-defined port then skip the rpcbind query for that and just set the port to the standard one (2049).
Signed-off-by Jeff Layton <[email protected]>---
utils/gssd/gssd_proc.c| 126 ++++++++++++++++++++++++++++
+-------------------1 files changed, 76 insertions(+), 50 deletions(-)utils/gssd/gssd_proc.c +2
-0@@ -72,6 +72,7 @@#include "gss_util.h" #include "krb5_util.h" #include "context.h" +#include "nfsrpc.h" /* * pollarray: @@ -541,6 +542,64 @@ out_err: }/* +* If the port isn't already set, do an rpcbind query to the remote server
+ * using the program and version and get the port. Newer kernels send the
+ * port in the upcall, so this is really only for compatibility with older
+ * ones.
+ */utils/gssd/gssd_proc.c +21
-0+static int +populate_port (struct sockaddr *sa,const socklen_t salen, +const rpcprog_t program,const rpcvers_t version, +const unsigned short protocol) +{ +struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +unsigned short port; + +/* +* Newer kernels send the port in the upcall. If we already have +* the port, there's no need to look it up. +*/ +switch (sa->sa_family) { +case AF_INET : +if (s4->sin_port !=0 ) { +printerr (2 ,"DEBUG: port already set to %d\n" , +ntohs (s4->sin_port)); +return 1 ; + } +break ; +default :utils/gssd/gssd_proc.c out_err: · line 580
Quoted 10 lines
utils/gssd/gssd_proc.c +10
-0+printerr (0 ,"ERROR: unsupported address family %d\n" , + sa->sa_family); +return 0 ; + } + +/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the kernel always passed up the value it is using for port= on this mount point.
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049Then, when setting up a tranport:
Quoted 7 lines
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that valueIf the kernel always passes the port= setting to gssd, then it can follow the "if port value is zero, rpcbind; otherwise use port value as is" rule, and be sure to get correct NFSv4 behavior, even without the special case you added for NFSv4.
In recent kernels that information is in the "info" file for the given client in rpc_pipefs. Kevin and Olga have patches to support that in gssd, if they aren't already in upstream nfs-utils.
And of course it's important to use that when it's available, to avoid unnecessary rpcbind calls (in a pure nfsv4 environment the only firewall hole you should have to poke is for the nfsv4 port), to respect the port= mount option for people running a v4 server on an alternate port, and for authenticating the callback channel (which won't normally be to port 2049, and won't (I assume) normally be registered with the portmapper).
--b.
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 67 lines · J. Bruce Fields
Quoted 66 lines · Chuck Lever
Quoted 63 lines · Jeff Layton
We already have the server's address from the upcall, so we don't really
need to look it up again, and querying the local services DB for the port that the remote server is listening on is just plain wrong.Use rpcbind to set the port for the program and version that we were given in the upcall. The exception here is NFSv4. Since NFSv4 mounts are supposed to use a well-defined port then skip the rpcbind query for that and just set the port to the standard one (2049).
Signed-off-by Jeff Layton <[email protected]>---
utils/gssd/gssd_proc.c| 126 ++++++++++++++++++++++++++++
+-------------------1 files changed, 76 insertions(+), 50 deletions(-)utils/gssd/gssd_proc.c +2
-0@@ -72,6 +72,7 @@#include "gss_util.h" #include "krb5_util.h" #include "context.h" +#include "nfsrpc.h" /* * pollarray: @@ -541,6 +542,64 @@ out_err: }/* +* If the port isn't already set, do an rpcbind query to the remote server
+ * using the program and version and get the port. Newer kernels send the
+ * port in the upcall, so this is really only for compatibility with older
+ * ones.
+ */utils/gssd/gssd_proc.c +23
-0+static int +populate_port (struct sockaddr *sa,const socklen_t salen, +const rpcprog_t program,const rpcvers_t version, +const unsigned short protocol) +{ +struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +unsigned short port; + +/* +* Newer kernels send the port in the upcall. If we already have +* the port, there's no need to look it up. +*/ +switch (sa->sa_family) { +case AF_INET : +if (s4->sin_port !=0 ) { +printerr (2 ,"DEBUG: port already set to %d\n" , +ntohs (s4->sin_port)); +return 1 ; + } +break ; +default : +printerr (0 ,"ERROR: unsupported address family %d\n" , + sa->sa_family);
Quoted 8 lines
Quoted 8 lines
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 8 lines
utils/gssd/gssd_proc.c +8
-0+return 0 ; + } + +/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }
And actually, since this test is _after_ the check to see if zero was passed in, I think we probably get correct behavior here if the kernel passes a non-zero port value for an NFSv4 mount. My mistake.
Quoted 18 lines
Quoted 18 lines
I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the kernel always passed up the value it is using for port= on this mount point.
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that value
Quoted 8 lines
Quoted 4 lines
If the kernel always passes the port= setting to gssd, then it can follow the "if port value is zero, rpcbind; otherwise use port value as is" rule, and be sure to get correct NFSv4 behavior, even without the special case you added for NFSv4.
In recent kernels that information is in the "info" file for the given client in
rpc_pipefs. Kevin and Olga have patches to support that in gssd, if they aren't already in upstream nfs-utils.
The issue is we're not exactly sure what value the kernel is passing up in the info file. It seems to change over time.
Quoted 10 lines
And of course it's important to use that when it's available, to avoid unnecessary rpcbind calls (in a pure nfsv4 environment the only firewall
hole you should have to poke is for the nfsv4 port), to respect the port= mount option for people running a v4 server on an alternate port,
and for authenticating the callback channel (which won't normally be to
port 2049, and won't (I assume) normally be registered with the portmapper).
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 7 lines · Chuck Lever
Quoted 3 lines · J. Bruce Fields
In recent kernels that information is in the "info" file for the given client in
rpc_pipefs. Kevin and Olga have patches to support that in gssd, if they aren't already in upstream nfs-utils.The issue is we're not exactly sure what value the kernel is passing up in the info file. It seems to change over time.
I don't understand. How does it change over time?
--b.
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 8 lines · J. Bruce Fields
Quoted 7 lines · Chuck Lever
Quoted 5 lines · J. Bruce Fields
In recent kernels that information is in the "info" file for the given
client inrpc_pipefs. Kevin and Olga have patches to support that in
gssd, if they aren't already in upstream nfs-utils.
Quoted 5 lines
Quoted 3 lines
The issue is we're not exactly sure what value the kernel is passing up
in the info file. It seems to change over time.I don't understand. How does it change over time?
Jeff observed some strange behavior while testing yesterday, so I'll let him address this question.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 9 lines · On Tue, 7 Apr 2009 12:34:54 -0400 Chuck Lever <[email protected]> wrote:
Quoted 8 lines · J. Bruce Fields
Quoted 7 lines · Chuck Lever
Quoted 5 lines · J. Bruce Fields
In recent kernels that information is in the "info" file for the given
client inrpc_pipefs. Kevin and Olga have patches to support that in
gssd, if they aren't already in upstream nfs-utils.
Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
The issue is we're not exactly sure what value the kernel is passing up
in the info file. It seems to change over time.I don't understand. How does it change over time?
Jeff observed some strange behavior while testing yesterday, so I'll let him address this question.
I sort of had expected to see the "port" value in the info file change once the kernel had done the rpcbind query and set the port in the socket. It doesn't do this though. In hindsight I think the current behavior is actually correct. The port value here more or less represents the port that was given to the kernel at mount time.
Quoted 9 lines
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that value
I think this patchset provides the behavior you want. For recent kernels that provide the port: field in the "info" file:
nfsv4: port: 2049
nfsv2/3: port: 0
...if you set port= in the mount options, then the info file displays that port.
When we have an older kernel that does not display the port, then populate_port() will see that sin(6)_port is still 0. For nfsv2/3 it'll do an rpcbind query to get the port, but we don't want to do that for NFSv4, so I added this:
+ /* Use standard NFS port for NFSv4 */
+ if (program == 100003 && version == 4) {
+ port = 2049;
+ goto set_port;
+ }
The important bit is that the above chunk will only matter for kernels that don't have a port: field in the info file.
In short, I think the behavior with this set is what you've outlined above.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 59 lines · Jeff Layton
Quoted 9 lines · On Tue, 7 Apr 2009 12:34:54 -0400 Chuck Lever <[email protected]> wrote:
Quoted 8 lines · J. Bruce Fields
Quoted 7 lines · Chuck Lever
Quoted 5 lines · J. Bruce Fields
In recent kernels that information is in the "info" file for the given
client inrpc_pipefs. Kevin and Olga have patches to support that in
gssd, if they aren't already in upstream nfs-utils.Quoted 9 lines
Quoted 5 lines
Quoted 3 lines
The issue is we're not exactly sure what value the kernel is passing up
in the info file. It seems to change over time.I don't understand. How does it change over time?
Jeff observed some strange behavior while testing yesterday, so I'll let him address this question.
I sort of had expected to see the "port" value in the info file change once the kernel had done the rpcbind query and set the port in the socket. It doesn't do this though. In hindsight I think the current behavior is actually correct. The port value here more or less represents the port that was given to the kernel at mount time.
Quoted 9 lines
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that valueI think this patchset provides the behavior you want. For recent kernels that provide the port: field in the "info" file:
nfsv4: port: 2049
nfsv2/3: port: 0...if you set port= in the mount options, then the info file displays that port.
When we have an older kernel that does not display the port, then
populate_port()will see that sin(6)_port is still 0. For nfsv2/3 it'll
do an rpcbind query to get the port, but we don't want to do that for NFSv4, so I added this:(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }
Quoted 2 lines
The important bit is that the above chunk will only matter for kernels that don't have a port: field in the info file.
Ah. I think the comment should mention this is for supporting legacy kernels.
Quoted 2 lines
In short, I think the behavior with this set is what you've outlined above.
Good. Ship it ;-)
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
In reply to Chuck LeverQuoted 11 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 2 lines
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
Quoted 7 lines
kernel always passed up the value it is using for port= on this mount point.
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049
This is a tiny bit questionable, since 2049 is only defined for TCP. But, if port= can override, then that's a workaround, so OK.
Quoted 10 lines
Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that valueIf the kernel always passes the port= setting to gssd, then it can follow the "if port value is zero, rpcbind; otherwise use port value as is" rule, and be sure to get correct NFSv4 behavior, even without the special case you added for NFSv4.
Agree.
Tom.
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 22 lines · Tom Talpey
Quoted 11 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 2 lines
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
Quoted 3 lines
kernel always passed up the value it is using for port= on this mount point.
Quoted 7 lines
Quoted 4 lines
The rules for how the kernel uses the port= setting are:
+ if port= is not specified on NFSv2/v3, port= setting is zero
+ if port= is not specified on NFSv4, port= setting is 2049This is a tiny bit questionable, since 2049 is only defined for TCP. But, if port= can override, then that's a workaround, so OK.
Right. The above rule is done in the kernel's mount option parsing logic, so that can/should be changed to address this. If the kernel always passes the correct port up to gssd, then gssd doesn't need to worry about it.
Quoted 11 lines
Quoted 9 lines
Then, when setting up a tranport:
+ if the port= setting is zero, do an rpcbind
+ if the port= setting is not zero, use that valueIf the kernel always passes the port= setting to gssd, then it can follow the "if port value is zero, rpcbind; otherwise use port value as is" rule, and be sure to get correct NFSv4 behavior, even without the special case you added for NFSv4.
Agree.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
In reply to Tom TalpeyQuoted 12 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 7 lines
Quoted 2 lines
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Does libtirpc handle RDMA properly? If so, this might not be too hard to enable, but I'd probably rather see it in a follow on patchset (and maybe by someone with more of a clue about RDMA than I currently have).
Signature · 1 line
Jeff Layton <[email protected]>
A message that is not in the archive (sent off-list or not yet received): 20090407131151.69203e5e-RtJpwOs3+0O+kQycOl6kW4xkIHaj4LzF@public.gmane.org
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 18 lines · Jeff Layton
Quoted 15 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 13 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
Quoted 7 lines
Quoted 4 lines
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto set_port" skips over it)? Why not at least try the query first?
Quoted 3 lines
Does libtirpc handle RDMA properly? If so, this might not be too hard to enable, but I'd probably rather see it in a follow on patchset (and maybe by someone with more of a clue about RDMA than I currently have).
No, libtirpc doesn't have any RDMA support. But, there's no need for RDMA support in it - only NFS does RDMA, in practice, and currently that's just in-kernel.
My concern is simply that there be a way to specify, or discover a port that isn't 2049 here. If mount.nfs supports it, other nfs-utils should too.
Tom.
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 36 lines · On Tue, 07 Apr 2009 15:43:39 -0400 Tom Talpey <[email protected]> wrote:
Quoted 18 lines · Jeff Layton
Quoted 15 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 13 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
Quoted 7 lines
Quoted 4 lines
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?Quoted 3 lines
Does libtirpc handle RDMA properly? If so, this might not be too hard to enable, but I'd probably rather see it in a follow on patchset (and maybe by someone with more of a clue about RDMA than I currently have).
Quoted 7 lines
No, libtirpc doesn't have any RDMA support. But, there's no need for RDMA support in it - only NFS does RDMA, in practice, and currently that's just in-kernel.
My concern is simply that there be a way to specify, or discover a port that isn't 2049 here. If mount.nfs supports it, other nfs-utils should too.
I forget which version is the cutoff, but newer kernels tell gssd which port to use. That hardwiring is only for older kernels that don't send the port in the upcall.
Could we try a short-timeout rpcbind call for those older kernels that don't send the port? Sure. Is it worth it? I'm not as sure there.
I'd rather see these people just update their kernels so that this isn't needed...
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 43 lines · Jeff Layton
Quoted 40 lines · On Tue, 07 Apr 2009 15:43:39 -0400 Tom Talpey <[email protected]> wrote:
Quoted 18 lines · Jeff Layton
Quoted 15 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 13 lines · Chuck Lever
Review
Quoted 5 lines · Jeff Layton
(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
Quoted 7 lines
Quoted 4 lines
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?Quoted 3 lines
Does libtirpc handle RDMA properly? If so, this might not be too hard to enable, but I'd probably rather see it in a follow on patchset (and maybe by someone with more of a clue about RDMA than I currently have).
No, libtirpc doesn't have any RDMA support. But, there's no need for RDMA support in it - only NFS does RDMA, in practice, and currently that's just in-kernel.
Quoted 7 lines
Quoted 3 lines
My concern is simply that there be a way to specify, or discover a port that isn't 2049 here. If mount.nfs supports it, other nfs-utils should too.
I forget which version is the cutoff, but newer kernels tell gssd which port to use. That hardwiring is only for older kernels that don't send the port in the upcall.
Ah - well, if "older" is < 2.6.24, then no problem since those kernels don't support NFS/RDMA. There are some backports to earlier kernels, but they could address this as part of the backport.
Quoted 3 lines
Could we try a short-timeout rpcbind call for those older kernels that don't send the port? Sure. Is it worth it? I'm not as sure there.
I wouldn't recommend a short timeout, arbitrary numbers rarely work the way you might want them to. I guess my opinion is that in the absence of any information, a standard rpcbind call is best, before concluding a default 2049 is the only option.
Quoted 3 lines
I'd rather see these people just update their kernels so that this isn't needed...
Agreed. Would it make sense to log a message when the default 2049 is used? At least then, there's a chance an admin will know it's needed.
Tom.
A message that is not in the archive (sent off-list or not yet received): 49dbb129.02045a0a.023b.6bc7-ATjtLOhZ0NVl57MIdRCFDg@public.gmane.org
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 8 lines · On Tue, 07 Apr 2009 16:01:31 -0400 Tom Talpey <[email protected]> wrote:
Quoted 4 lines
I'd rather see these people just update their kernels so that this isn't needed...
Agreed. Would it make sense to log a message when the default 2049 is used? At least then, there's a chance an admin will know it's needed.
That's sounds reasonable. I've already asked Steve to commit the latest set, but we should be able to add something like this untested patch on top of it.
If it looks ok, I'll test it out and officially resend it...
Thoughts?
----------------[snip]--------------------
Quoted 1 line
From
7ac66dd50eafec3db3c816203fc24b9b72ff1f36Mon Sep 17 00:00:00 2001
From: Jeff Layton <[email protected]>
Date: Tue, 7 Apr 2009 16:27:13 -0400
Subject: [PATCH] nfs-utils: log warning when gssd detects an older kernel that doesn't send port in upcall
Older kernels don't send port information in the upcall. This could cause mounts to fail for mysterious reasons. Log a warning the first time that gssd encounters an upcall without any port information in it.
--- utils/gssd/gssd_proc.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)
utils/gssd/gssd_proc.c +11 -1
@@ -99,6 +99,8 @@* and rescan the whole {pipefs_nfsdir} when this happens. */ +static int warned_on_port_field; +struct pollfd * pollarray;int pollsize;/* the size of pollaray (in pollfd's) */
@@ -228,8 +230,16 @@ read_service_info(char *info_file_name, char **servicename, char **servername, } cb_port[0 ] ='\0' ; -if ((p =strstr (buf,"port" )) !=NULL ) +if ((p =strstr (buf,"port" )) !=NULL ) {sscanf (p,"port: %127s\n" , cb_port); + }else if (!warned_on_port_field) { + warned_on_port_field =1 ; +printerr (0 ,"WARNING: This kernel does not send port info " +"in the upcall. That support was added in " +"upstream kernel version 2.6.24. Using " +"non-standard ports may not work with this " +"kernel.\n" ); + }/* check service, program, and version */ if (memcmp (service,"nfs" ,3 ))return -1 ;
Signature · 1 line
1.6.0.6
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Tue, 07 Apr 2009 16:01:31 -0400 Tom Talpey <[email protected]> wrote:
Quoted 4 lines
I'd rather see these people just update their kernels so that this isn't needed...
Agreed. Would it make sense to log a message when the default 2049 is used? At least then, there's a chance an admin will know it's needed.
Quoted 7 lines
That's sounds reasonable. I've already asked Steve to commit the latest set, but we should be able to add something like this untested patch on top of it.
If it looks ok, I'll test it out and officially resend it...
Thoughts?
Would it work to do this in mount?--do the mount, then check any new info file in rpc_pipefs to see if there's a port field?
Then we could give the error to the user where it's actually useful (as output from the mount command). And also maybe only bother with it when port= was specified.
--b.
Quoted 54 lines
----------------[snip]--------------------
Quoted 1 line
From
7ac66dd50eafec3db3c816203fc24b9b72ff1f36Mon Sep 17 00:00:00 2001From: Jeff Layton <[email protected]>
Date: Tue, 7 Apr 2009 16:27:13 -0400
Subject: [PATCH] nfs-utils: log warning when gssd detects an older kernel that doesn't send port in upcallOlder kernels don't send port information in the upcall. This could cause mounts to fail for mysterious reasons. Log a warning the first time that gssd encounters an upcall without any port information in it.
Signed-off-by Jeff Layton <[email protected]>--- utils/gssd/gssd_proc.c | 12 +++++++++++- 1 files changed, 11 insertions(+), 1 deletions(-)utils/gssd/gssd_proc.c +11
-1@@ -99,6 +99,8 @@* and rescan the whole {pipefs_nfsdir} when this happens. */ +static int warned_on_port_field; +struct pollfd * pollarray;int pollsize;/* the size of pollaray (in pollfd's) */ @@ -228,8 +230,16 @@ read_service_info(char *info_file_name, char **servicename, char **servername, } cb_port[0 ] ='\0' ; -if ((p =strstr (buf,"port" )) !=NULL ) +if ((p =strstr (buf,"port" )) !=NULL ) {sscanf (p,"port: %127s\n" , cb_port); + }else if (!warned_on_port_field) { + warned_on_port_field =1 ; +printerr (0 ,"WARNING: This kernel does not send port info " +"in the upcall. That support was added in " +"upstream kernel version 2.6.24. Using " +"non-standard ports may not work with this " +"kernel.\n" ); + }/* check service, program, and version */ if (memcmp (service,"nfs" ,3 ))return -1 ;Signature · 5 lines
1.6.0.6 _______________________________________________ NFSv4 mailing list [email protected] http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 20 lines · On Tue, 7 Apr 2009 19:16:06 -0400 "J. Bruce Fields" <[email protected]>…
Quoted 11 lines · Jeff Layton
Quoted 8 lines · On Tue, 07 Apr 2009 16:01:31 -0400 Tom Talpey <[email protected]> wrote:
Quoted 4 lines
I'd rather see these people just update their kernels so that this isn't needed...
Agreed. Would it make sense to log a message when the default 2049 is used? At least then, there's a chance an admin will know it's needed.
Quoted 7 lines
That's sounds reasonable. I've already asked Steve to commit the latest set, but we should be able to add something like this untested patch on top of it.
If it looks ok, I'll test it out and officially resend it...
Thoughts?
Quoted 9 lines
Would it work to do this in mount?--do the mount, then check any new info file in
rpc_pipefsto see if there's a port field?Then we could give the error to the user where it's actually useful (as output from the mount command). And also maybe only bother with it when port= was specified.
--b.
It's not really an error per-se. Given that 99%+ NFS connections are done on standard ports, I consider this to just be a helpful warning that might point someone in the right direction when this does occur.
Adding code to mount for this seems like overkill, IMO...
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
In reply to Tom TalpeyQuoted 24 lines · Tom Talpey
Quoted 23 lines · Jeff Layton
Quoted 19 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
utils/gssd/gssd_proc.c out_err: · line 580
Quoted 5 lines · Jeff Layton
utils/gssd/gssd_proc.c +5
-0+/* Use standard NFS port for NFSv4 */ +if (program ==100003 && version ==4 ) { + port =2049 ; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 2 lines
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
Quoted 7 lines
Quoted 2 lines
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?
We're just doing the rpcsec_gss context initiation. Normally that would be done over an already-established connection--the only reason we don't is because our implementation is split between the client and the server, so it's more convenient for us to set up a new connection in rpc.gssd. But we really shouldn't be doing an entirely new rpcbind call--somebody else already did that for us and is telling us the results through the rpc_pipefs info file.
--b.
Quoted 18 lines
Quoted 4 lines
Does libtirpc handle RDMA properly? If so, this might not be too hard to enable, but I'd probably rather see it in a follow on patchset (and maybe by someone with more of a clue about RDMA than I currently have).
No, libtirpc doesn't have any RDMA support. But, there's no need for RDMA support in it - only NFS does RDMA, in practice, and currently that's just in-kernel.
My concern is simply that there be a way to specify, or discover a port that isn't 2049 here. If mount.nfs supports it, other nfs-utils should too.
Tom.
_______________________________________________
NFSv4 mailing list
[email protected]
http://linux-nfs.org/cgi-bin/mailman/listinfo/nfsv4
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 33 lines · On Tue, 7 Apr 2009 19:14:06 -0400 "J. Bruce Fields" <[email protected]>…
Quoted 24 lines · Tom Talpey
Quoted 23 lines · Jeff Layton
Quoted 19 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
Review
Quoted 5 lines · Jeff Layton
(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 2 lines
You can specify "port=" for nfs4 mounts, in which case we want to use that value here, too, I think. It would be simpler overall if the
*Must* use a port= specification. The 2049 definition is only true for NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.
Quoted 7 lines
Quoted 2 lines
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems to handle "tcp" and "udp" in the existing code.
Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?
Quoted 8 lines
We're just doing the
rpcsec_gsscontext initiation. Normally that would be done over an already-established connection--the only reason we don't is because our implementation is split between the client and the server, so it's more convenient for us to set up a new connection in rpc.gssd. But we really shouldn't be doing an entirely new rpcbind call--somebody else already did that for us and is telling us the results through therpc_pipefsinfo file.
Technically, the info file doesn't display the port from an rpcbind call. That field is populated before the kernel's rpcbind call is done. The contents will be one of:
- the value of the port= mount option if one was specified
- 2049 if it's an nfs4 mount and there is no port= option specified
- 0 if nfsv2/3 and no port= option was specified
...its real value is in allowing gssd to skip the rpcbind call if someone specified port= when doing the mount. This could probably be changed, but I'm not sure it's such a big deal. It only means an extra rpcbind call at mount time for NFSv2/3. Further upcalls for other creds by the same client don't incur extra rpcbind queries.
Signature · 1 line
Jeff Layton <[email protected]>
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
In reply to J. Bruce FieldsQuoted 36 lines · J. Bruce Fields
Quoted 26 lines · Tom Talpey
Quoted 25 lines · Jeff Layton
Quoted 21 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
Review
Quoted 5 lines · Jeff Layton
(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 3 lines
You can specify "port=" for nfs4 mounts, in which case we want to use
that value here, too, I think. It would be simpler overall if the*Must* use a port= specification. The 2049 definition is only true for
NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.Quoted 8 lines
Quoted 3 lines
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems
to handle "tcp" and "udp" in the existing code.Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?
Quoted 9 lines
We're just doing the
rpcsec_gsscontext initiation. Normally that would
be done over an already-established connection--the only reason we don't
is because our implementation is split between the client and the server, so it's more convenient for us to set up a new connection in rpc.gssd. But we really shouldn't be doing an entirely new rpcbind call--somebody else already did that for us and is telling us the results through therpc_pipefsinfo file.
This is an entirely separate RPC transport being set up for gssd, and there seem to be a lot of cases where the kernel (rightfully) passes a zero for the port number. In fact, even if the kernel did the rpcbind for gssd at some point in the past, gss doesn't have any information about how old that information is.
So, yes, we do want an rpcbind here.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Quoted 47 lines · Chuck Lever
Quoted 36 lines · J. Bruce Fields
Quoted 26 lines · Tom Talpey
Quoted 25 lines · Jeff Layton
Quoted 21 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
Review
Quoted 5 lines · Jeff Layton
(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 3 lines
You can specify "port=" for nfs4 mounts, in which case we want to use
that value here, too, I think. It would be simpler overall if the*Must* use a port= specification. The 2049 definition is only true for
NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.Quoted 8 lines
Quoted 3 lines
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems
to handle "tcp" and "udp" in the existing code.Fair enough. But hardwiring 2049 for all transports is going to very problematic. What's the motivation for bypassing the rpcbind query altogether (that "goto
set_port" skips over it)? Why not at least try the query first?Quoted 9 lines
We're just doing the
rpcsec_gsscontext initiation. Normally that would
be done over an already-established connection--the only reason we don't
is because our implementation is split between the client and the server, so it's more convenient for us to set up a new connection in rpc.gssd. But we really shouldn't be doing an entirely new rpcbind call--somebody else already did that for us and is telling us the results through therpc_pipefsinfo file.
Quoted 7 lines
This is an entirely separate RPC transport being set up for gssd, and there seem to be a lot of cases where the kernel (rightfully) passes a zero for the port number. In fact, even if the kernel did the rpcbind for gssd at some point in the past, gss doesn't have any information about how old that information is.
So, yes, we do want an rpcbind here.
As long as we don't do it in the NFSv4 case, I'm happy.
My only point is that the above argument is putting the cart before the horse a bit: the fact that there's an entirely separate RPC transport being set up is entirely an artifact of our implementation, and if it became a problem at some point, then we'd need to consider modifying the kernel/gssd interface to eliminate the need for that.
--b.
Re: [PATCH 3/5] nfs-utils: query for remote port using rpcbind instead of getaddrinfo
Hi Bruce-
Quoted 58 lines · J. Bruce Fields
Quoted 57 lines · Chuck Lever
Quoted 38 lines · J. Bruce Fields
Quoted 31 lines · Tom Talpey
Quoted 26 lines · Jeff Layton
Quoted 17 lines · On Tue, 07 Apr 2009 12:27:49 -0400 Tom Talpey <[email protected]> wrote:
Quoted 11 lines · Chuck Lever
Review
Quoted 5 lines · Jeff Layton
(quoted diff) +5
-0+ /* Use standard NFS port for NFSv4 */ + if (program == 100003 && version == 4) { + port = 2049; + goto set_port; + }I think this patch set looks pretty reasonable. Here's my one remaining quibble.
Quoted 4 lines
You can specify "port=" for nfs4 mounts, in which case we want to use
that value here, too, I think. It would be simpler overall if theQuoted 5 lines
*Must* use a port= specification. The 2049 definition is only true for
NFSv4/TCP, as a counterexample the NFSv4/RDMA IANA binding is port 20049. So slamming the port to 2049 would break NFSv4/RDMA.Quoted 3 lines
rpc.gssd doesn't seem to be rdma-enabled at this point. It only seems
to handle "tcp" and "udp" in the existing code.Quoted 5 lines
Fair enough. But hardwiring 2049 for all transports is going to very
problematic. What's the motivation for bypassing the rpcbind query altogether (that "gotoset_port" skips over it)? Why not at least try the query first?Quoted 9 lines
We're just doing the
rpcsec_gsscontext initiation. Normally that would
be done over an already-established connection--the only reason we don't
is because our implementation is split between the client and the server, so it's more convenient for us to set up a new connection in rpc.gssd. But we really shouldn't be doing an entirely new rpcbind call--somebody else already did that for us and is telling us the results through therpc_pipefsinfo file.This is an entirely separate RPC transport being set up for gssd, and there seem to be a lot of cases where the kernel (rightfully) passes a
zero for the port number. In fact, even if the kernel did the rpcbind
for gssd at some point in the past, gss doesn't have any information about how old that information is.
Quoted 3 lines
Quoted 1 line
So, yes, we do want an rpcbind here.
As long as we don't do it in the NFSv4 case, I'm happy.
As far as I understand it, the kernel won't send up a zero for NFSv4 unless the mount command line says "port=0" which forces an rpcbind for each transport we use to connect to that server.
For NFSv2/v3, however, not specifying port= on the mount command line means the kernel will send up zero in most common cases, I think. Using /etc/services on the client to discover the server's NFSD port means that if the server has registered the NFS service on some other port, specifying "port=" will be required on the mount command line for gssd to work, even though rpcbind on the server is advertising the correct port already.
Quoted 7 lines
My only point is that the above argument is putting the cart before the
horse a bit: the fact that there's an entirely separate RPC transport being set up is entirely an artifact of our implementation, and if it became a problem at some point, then we'd need to consider modifying the
kernel/gssd interface to eliminate the need for that.
port=0 has a specific well-defined meaning for RPC, which is "do an rpcbind". If you really think you need to distinguish between "use this port number," "do an rpcbind," "use the standard port for this transport," and "consult /etc/services" then I don't think port=0 is adequate.
Should we even bother to consult /etc/services for NFSv4, since that port value is required by standard? nfs4mount.c doesn't look at /etc/ services, for example. So today, gssd looks in /etc/services, nfs4mount.c and the kernel hard-code the port number.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
PATCH 4/5 nfs-utils: switch gssd to use standard function for getting an RPC client
In reply to Jeff LaytonWe already have a common function for setting up an RPC client. That function uses the tirpc API when tirpc is enabled and is also already IPv6 enabled. Switch gssd to use it.
--- utils/gssd/gssd_proc.c | 41 ++++++++++++----------------------------- 1 files changed, 12 insertions(+), 29 deletions(-)
utils/gssd/gssd_proc.c +12 -29
@@ -616,9 +616,8 @@ int create_auth_rpc_client(struct clnt_info *clp,int retval =-1 ;OM_uint32 min_stat;char rpc_errmsg[1024 ]; -int sockp =RPC_ANYSOCK ; -int sendsz =32768 , recvsz =32768 ;int protocol; +struct timeval timeout = {5 ,0 };struct sockaddr *addr = (struct sockaddr *) &clp->addr;socklen_t salen;
@@ -698,33 +697,17 @@ int create_auth_rpc_client(struct clnt_info *clp,if (!populate_port (addr, salen, clp->prog, clp->vers, protocol)) goto out_fail; -if (protocol ==IPPROTO_TCP ) { -if ((rpc_clnt =clnttcp_create ( - (struct sockaddr_in *) addr, - clp->prog, clp->vers, &sockp, - sendsz, recvsz)) ==NULL ) { -snprintf (rpc_errmsg,sizeof (rpc_errmsg), -"WARNING: can't create tcp rpc_clnt " -"for server %s for user with uid %d" , - clp->servername, uid); -printerr (0 ,"%s\n" , -clnt_spcreateerror (rpc_errmsg)); - goto out_fail; - } - }else if (protocol ==IPPROTO_UDP ) { -const struct timeval timeout = {5 ,0 }; -if ((rpc_clnt =clntudp_bufcreate ( - (struct sockaddr_in *) addr, - clp->prog, clp->vers, timeout, - &sockp, sendsz, recvsz)) ==NULL ) { -snprintf (rpc_errmsg,sizeof (rpc_errmsg), -"WARNING: can't create udp rpc_clnt " -"for server %s for user with uid %d" , - clp->servername, uid); -printerr (0 ,"%s\n" , -clnt_spcreateerror (rpc_errmsg)); - goto out_fail; - } + rpc_clnt =nfs_get_rpcclient (addr, salen, protocol, clp->prog, + clp->vers, &timeout); +if (!rpc_clnt) { +snprintf (rpc_errmsg,sizeof (rpc_errmsg), +"WARNING: can't create %s rpc_clnt to server %s for " +"user with uid %d" , + protocol ==IPPROTO_TCP ?"tcp" :"udp" , + clp->servername, uid); +printerr (0 ,"%s\n" , +clnt_spcreateerror (rpc_errmsg)); + goto out_fail; }printerr (2 ,"creating context with server %s\n" , clp->servicename);
Signature · 1 line
1.6.0.6
PATCH 5/5 nfs-utils: add IPv6 code to gssd
In reply to Jeff LaytonAll of the pieces to handle IPv6 are now in place. Add IPv6-specific code wrapped in the proper #ifdef's so that IPv6 support works when it's enabled at build-time.
--- utils/gssd/gssd_proc.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 44 insertions(+), 0 deletions(-)
utils/gssd/gssd_proc.c +44 -0
@@ -106,15 +106,32 @@ int pollsize; /* the size of pollaray (in pollfd's) *//* * convert a presentation address string to a sockaddr_storage struct. Returns * true on success and false on failure. +* +* Note that we do not populate the sin6_scope_id field here for IPv6 addrs. +* gssd nececessarily relies on hostname resolution and DNS AAAA records +* do not generally contain scope-id's. This means that GSSAPI auth really +* can't work with IPv6 link-local addresses. +* +* We *could* consider changing this if we did something like adopt the +* Microsoft "standard" of using the ipv6-literal.net domainname, but it's +* not really feasible at present. */ static int addrstr_to_sockaddr (struct sockaddr *sa,const char *addr,const int port) {struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +#ifdef IPV6_SUPPORTED +struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa; +#endif /* IPV6_SUPPORTED */ if (inet_pton (AF_INET , addr, &s4->sin_addr)) { s4->sin_family =AF_INET ; s4->sin_port =htons (port); +#ifdef IPV6_SUPPORTED + }else if (inet_pton (AF_INET6 , addr, &s6->sin6_addr)) { + s6->sin6_family =AF_INET6 ; + s6->sin6_port =htons (port); +#endif /* IPV6_SUPPORTED */ }else {printerr (0 ,"ERROR: unable to convert %s to address\n" , addr);return 0 ;
@@ -138,6 +155,11 @@ sockaddr_to_hostname(const struct sockaddr *sa, const char *addr)case AF_INET : addrlen =sizeof (struct sockaddr_in );break ; +#ifdef IPV6_SUPPORTED +case AF_INET6 : + addrlen =sizeof (struct sockaddr_in6 ); +break ; +#endif /* IPV6_SUPPORTED */ default :printerr (0 ,"ERROR: unrecognized addr family %d\n" , sa->sa_family);
@@ -553,6 +575,9 @@ populate_port(struct sockaddr *sa, const socklen_t salen, const unsigned short protocol) {struct sockaddr_in *s4 = (struct sockaddr_in *) sa; +#ifdef IPV6_SUPPORTED +struct sockaddr_in6 *s6 = (struct sockaddr_in6 *) sa; +#endif /* IPV6_SUPPORTED */ unsigned short port;/*
@@ -567,6 +592,15 @@ populate_port(struct sockaddr *sa, const socklen_t salen,return 1 ; }break ; +#ifdef IPV6_SUPPORTED +case AF_INET6 : +if (s6->sin6_port !=0 ) { +printerr (2 ,"DEBUG: port already set to %d\n" , +ntohs (s6->sin6_port)); +return 1 ; + } +break ; +#endif /* IPV6_SUPPORTED */ default :printerr (0 ,"ERROR: unsupported address family %d\n" , sa->sa_family);
@@ -594,6 +628,11 @@ set_port:case AF_INET : s4->sin_port =htons (port);break ; +#ifdef IPV6_SUPPORTED +case AF_INET6 : + s6->sin6_port =htons (port); +break ; +#endif /* IPV6_SUPPORTED */ }return 1 ;
@@ -688,6 +727,11 @@ int create_auth_rpc_client(struct clnt_info *clp,case AF_INET : salen =sizeof (struct sockaddr_in );break ; +#ifdef IPV6_SUPPORTED +case AF_INET6 : + salen =sizeof (struct sockaddr_in6 ); +break ; +#endif /* IPV6_SUPPORTED */ default :printerr (1 ,"ERROR: Unknown address family %d\n" , addr->sa_family);
Signature · 1 line
1.6.0.6
Quoted 28 lines · Jeff Layton
This patchset is the fourth attempt at adding support for IPv6 to rpc.gssd. The main change from the last set is that this one now uses a rpcbind query to determine the server's port rather than doing a getaddrinfo call to query the local services db.
The series should be fully bisectable, but I've only really tested the end result for anything other than to see if it compiles. With these patches I've been able to mount an OpenSolaris server using NFSv3/4 + IPv6 + krb5 auth. I've also done testing with builds with only TIRPC enabled and with TIRPC and IPv6 both disabled and haven't seen any regressions.
List of changes since the last set:
- use rpcbind query to determine port for RPC client
- added comment explaining gssd doesn't deal with IPv6 scope_id's
- slight cleanups and clarifications to comments
- properly handleEAI_SYSTEMreturn code fromgetnameinfo()call
- changed autoconf check for getnameinfo to check whenever --enable-gss is set, not just when NFSv4 is also enabled.Jeff Layton (5):
nfs-utils: makegetnameinfo()required for --enable-gss
nfs-utils: store the address given in the upcall for later use
nfs-utils: query for remote port using rpcbind instead of getaddrinfo
nfs-utils: switch gssd to use standard function for getting an RPC
client
nfs-utils: add IPv6 code to gssd
Quoted 5 lines
configure.ac | 3 + utils/gssd/gssd.h | 2 +- utils/gssd/gssd_proc.c | 286 +++++++++++++++++++++++++++++++++--------------- 3 files changed, 204 insertions(+), 87 deletions(-)
Committed....
steved.