* [PATCH 0/4] Support for IPv6 in the showmount command
@ 2008-11-18 19:29 Chuck Lever
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
0 siblings, 1 reply; 8+ messages in thread
From: Chuck Lever @ 2008-11-18 19:29 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Hi Steve-
These patches implement support for rpcbind v3/v4 queries and IPv6 NFS
servers in the showmount command. Please consider these for the next
release of nfs-utils.
Thanks!
---
Chuck Lever (4):
showmount command: support querying IPv6 servers
showmount command: move logic to acquire RPC client handle out of main()
showmount command: Remove unused local getport() implementation
showmount command: call nfs_getport instead of local getport
utils/showmount/showmount.c | 237 +++++++++++++++++--------------------------
1 files changed, 91 insertions(+), 146 deletions(-)
--
Chuck Lever
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/4] showmount command: call nfs_getport instead of local getport
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
@ 2008-11-18 19:29 ` Chuck Lever
2008-11-18 19:29 ` [PATCH 2/4] showmount command: Remove unused local getport() implementation Chuck Lever
` (3 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Chuck Lever @ 2008-11-18 19:29 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Have the showmount command invoke the shared nfs_getport() function
instead of its own local version. This gives the showmount command
immediate support for querying via rpcbindv3/v4 in addition to
portmapper, and sets the stage for AF_INET6 support in showmount.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/showmount/showmount.c | 14 ++++++++------
1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 959229a..cbc8f1a 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -37,6 +37,8 @@
#include <mount.h>
#include <unistd.h>
+#include "nfsrpc.h"
+
#define TIMEOUT_UDP 3
#define TIMEOUT_TCP 10
#define TOTAL_TIMEOUT 20
@@ -352,9 +354,9 @@ int main(int argc, char **argv)
mclient = NULL;
msock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (msock != -1) {
- server_addr.sin_port = getport(&server_addr,
- MOUNTPROG, MOUNTVERS, IPPROTO_TCP);
- if (server_addr.sin_port) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_TCP)) {
ret = connect_nb(msock, &server_addr, 0);
if (ret == 0) /* success */
mclient = clnttcp_create(&server_addr,
@@ -367,9 +369,9 @@ int main(int argc, char **argv)
}
if (!mclient) {
- server_addr.sin_port = getport(&server_addr,
- MOUNTPROG, MOUNTVERS, IPPROTO_UDP);
- if (!server_addr.sin_port) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_UDP)) {
clnt_pcreateerror("showmount");
exit(1);
}
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/4] showmount command: Remove unused local getport() implementation
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-18 19:29 ` [PATCH 1/4] showmount command: call nfs_getport instead of local getport Chuck Lever
@ 2008-11-18 19:29 ` Chuck Lever
2008-11-18 19:29 ` [PATCH 3/4] showmount command: move logic to acquire RPC client handle out of main() Chuck Lever
` (2 subsequent siblings)
4 siblings, 0 replies; 8+ messages in thread
From: Chuck Lever @ 2008-11-18 19:29 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Clean up: remove showmount.c's local getport() implementation, now that
the showmount command uses the shared one.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/showmount/showmount.c | 105 -------------------------------------------
1 files changed, 0 insertions(+), 105 deletions(-)
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index cbc8f1a..5951033 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -40,7 +40,6 @@
#include "nfsrpc.h"
#define TIMEOUT_UDP 3
-#define TIMEOUT_TCP 10
#define TOTAL_TIMEOUT 20
static char * version = "showmount for " VERSION;
@@ -151,110 +150,6 @@ done:
return ret;
}
-static unsigned short getport(struct sockaddr_in *addr,
- unsigned long prog, unsigned long vers, int prot)
-{
- CLIENT *client;
- enum clnt_stat status;
- struct pmap parms;
- int ret, sock;
- struct sockaddr_in laddr, saddr;
- struct timeval tout = {0, 0};
- socklen_t len;
- unsigned int send_sz = 0;
- unsigned int recv_sz = 0;
- unsigned short port;
-
- memset(&laddr, 0, sizeof(laddr));
- memset(&saddr, 0, sizeof(saddr));
- memset(&parms, 0, sizeof(parms));
-
- memcpy(&saddr, addr, sizeof(saddr));
- saddr.sin_port = htons(PMAPPORT);
-
- if (prot == IPPROTO_TCP) {
- sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (sock == -1) {
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = errno;
- return 0;
- }
-
- tout.tv_sec = TIMEOUT_TCP;
-
- ret = connect_nb(sock, &saddr, &tout);
- if (ret != 0) {
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = errno;
- close(sock);
- return 0;
- }
- client = clnttcp_create(&saddr,
- PMAPPROG, PMAPVERS, &sock,
- 0, 0);
- } else {
- /*
- * bind to any unused port. If we left this up to the rpc
- * layer, it would bind to a reserved port, which has been shown
- * to exhaust the reserved port range in some situations.
- */
- sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
- if (sock == -1) {
- rpc_createerr.cf_stat = RPC_SYSTEMERROR;
- rpc_createerr.cf_error.re_errno = errno;
- return 0;
- }
-
- laddr.sin_family = AF_INET;
- laddr.sin_port = 0;
- laddr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- tout.tv_sec = TIMEOUT_UDP;
-
- send_sz = RPCSMALLMSGSIZE;
- recv_sz = RPCSMALLMSGSIZE;
-
- len = sizeof(struct sockaddr_in);
- if (bind(sock, (struct sockaddr *)&laddr, len) < 0) {
- close(sock);
- sock = RPC_ANYSOCK;
- /* FALLTHROUGH */
- }
- client = clntudp_bufcreate(&saddr, PMAPPROG, PMAPVERS,
- tout, &sock, send_sz, recv_sz);
- }
-
- if (!client) {
- close(sock);
- rpc_createerr.cf_stat = RPC_RPCBFAILURE;
- return 0;
- }
-
- clnt_control(client, CLSET_FD_CLOSE, NULL);
-
- parms.pm_prog = prog;
- parms.pm_vers = vers;
- parms.pm_prot = prot;
-
- status = clnt_call(client, PMAPPROC_GETPORT,
- (xdrproc_t) xdr_pmap, (caddr_t) &parms,
- (xdrproc_t) xdr_u_short, (caddr_t) &port,
- tout);
-
- if (status != RPC_SUCCESS) {
- clnt_geterr(client, &rpc_createerr.cf_error);
- rpc_createerr.cf_stat = status;
- clnt_destroy(client);
- return 0;
- } else if (port == 0) {
- rpc_createerr.cf_stat = RPC_PROGNOTREGISTERED;
- }
-
- clnt_destroy(client);
-
- return htons(port);
-}
-
int main(int argc, char **argv)
{
char hostname_buf[MAXHOSTLEN];
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/4] showmount command: move logic to acquire RPC client handle out of main()
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-18 19:29 ` [PATCH 1/4] showmount command: call nfs_getport instead of local getport Chuck Lever
2008-11-18 19:29 ` [PATCH 2/4] showmount command: Remove unused local getport() implementation Chuck Lever
@ 2008-11-18 19:29 ` Chuck Lever
2008-11-18 19:29 ` [PATCH 4/4] showmount command: support querying IPv6 servers Chuck Lever
2008-11-25 14:27 ` [PATCH 0/4] Support for IPv6 in the showmount command Steve Dickson
4 siblings, 0 replies; 8+ messages in thread
From: Chuck Lever @ 2008-11-18 19:29 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
In preparation to support IPv6 in the showmount command, extract the logic
that parses/acquires the target hostname and converts it into an RPC
client handle to contact the remote mountd service, and move it into its
own function.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/showmount/showmount.c | 116 ++++++++++++++++++++++++-------------------
1 files changed, 64 insertions(+), 52 deletions(-)
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 5951033..7f5ad3a 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -150,16 +150,75 @@ done:
return ret;
}
+/*
+ * Generate an RPC client handle connected to the mountd service
+ * at @hostname, or die trying.
+ *
+ * Supports only AF_INET server addresses.
+ */
+static CLIENT *nfs_get_mount_client(const char *hostname)
+{
+ struct hostent *hp;
+ struct sockaddr_in server_addr;
+ struct timeval pertry_timeout;
+ CLIENT *mclient = NULL;
+ int ret, msock;
+
+ if (inet_aton(hostname, &server_addr.sin_addr)) {
+ server_addr.sin_family = AF_INET;
+ }
+ else {
+ if ((hp = gethostbyname(hostname)) == NULL) {
+ fprintf(stderr, "%s: can't get address for %s\n",
+ program_name, hostname);
+ exit(1);
+ }
+ server_addr.sin_family = AF_INET;
+ memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
+ }
+
+ msock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (msock != -1) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_TCP)) {
+ ret = connect_nb(msock, &server_addr, 0);
+ if (ret == 0)
+ mclient = clnttcp_create(&server_addr,
+ MOUNTPROG, MOUNTVERS, &msock,
+ 0, 0);
+ else
+ close(msock);
+ } else
+ close(msock);
+ }
+
+ if (!mclient) {
+ if (nfs_getport_ping((struct sockaddr *)&server_addr,
+ sizeof(server_addr), MOUNTPROG,
+ MOUNTVERS, IPPROTO_UDP)) {
+ clnt_pcreateerror("showmount");
+ exit(1);
+ }
+ msock = RPC_ANYSOCK;
+ pertry_timeout.tv_sec = TIMEOUT_UDP;
+ pertry_timeout.tv_usec = 0;
+ if ((mclient = clntudp_create(&server_addr,
+ MOUNTPROG, MOUNTVERS, pertry_timeout, &msock)) == NULL) {
+ clnt_pcreateerror("mount clntudp_create");
+ exit(1);
+ }
+ }
+
+ return mclient;
+}
+
int main(int argc, char **argv)
{
char hostname_buf[MAXHOSTLEN];
char *hostname;
enum clnt_stat clnt_stat;
- struct hostent *hp;
- struct sockaddr_in server_addr;
- int ret, msock;
struct timeval total_timeout;
- struct timeval pertry_timeout;
int c;
CLIENT *mclient;
groups grouplist;
@@ -231,54 +290,7 @@ int main(int argc, char **argv)
break;
}
- if (inet_aton(hostname, &server_addr.sin_addr)) {
- server_addr.sin_family = AF_INET;
- }
- else {
- if ((hp = gethostbyname(hostname)) == NULL) {
- fprintf(stderr, "%s: can't get address for %s\n",
- program_name, hostname);
- exit(1);
- }
- server_addr.sin_family = AF_INET;
- memcpy(&server_addr.sin_addr, hp->h_addr, hp->h_length);
- }
-
- /* create mount deamon client */
-
- mclient = NULL;
- msock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (msock != -1) {
- if (nfs_getport_ping((struct sockaddr *)&server_addr,
- sizeof(server_addr), MOUNTPROG,
- MOUNTVERS, IPPROTO_TCP)) {
- ret = connect_nb(msock, &server_addr, 0);
- if (ret == 0) /* success */
- mclient = clnttcp_create(&server_addr,
- MOUNTPROG, MOUNTVERS, &msock,
- 0, 0);
- else
- close(msock);
- } else
- close(msock);
- }
-
- if (!mclient) {
- if (nfs_getport_ping((struct sockaddr *)&server_addr,
- sizeof(server_addr), MOUNTPROG,
- MOUNTVERS, IPPROTO_UDP)) {
- clnt_pcreateerror("showmount");
- exit(1);
- }
- msock = RPC_ANYSOCK;
- pertry_timeout.tv_sec = TIMEOUT_UDP;
- pertry_timeout.tv_usec = 0;
- if ((mclient = clntudp_create(&server_addr,
- MOUNTPROG, MOUNTVERS, pertry_timeout, &msock)) == NULL) {
- clnt_pcreateerror("mount clntudp_create");
- exit(1);
- }
- }
+ mclient = nfs_get_mount_client(hostname);
mclient->cl_auth = authunix_create_default();
total_timeout.tv_sec = TOTAL_TIMEOUT;
total_timeout.tv_usec = 0;
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/4] showmount command: support querying IPv6 servers
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (2 preceding siblings ...)
2008-11-18 19:29 ` [PATCH 3/4] showmount command: move logic to acquire RPC client handle out of main() Chuck Lever
@ 2008-11-18 19:29 ` Chuck Lever
2008-11-25 14:27 ` [PATCH 0/4] Support for IPv6 in the showmount command Steve Dickson
4 siblings, 0 replies; 8+ messages in thread
From: Chuck Lever @ 2008-11-18 19:29 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Introduce a version of nfs_get_mount_client() that supports AF_INET6 and
AF_INET server addresses. If the TI-RPC library is not available when
the showmount command is built, fall back to the legacy RPC user-space
API.
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
utils/showmount/showmount.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)
diff --git a/utils/showmount/showmount.c b/utils/showmount/showmount.c
index 7f5ad3a..17f7d87 100644
--- a/utils/showmount/showmount.c
+++ b/utils/showmount/showmount.c
@@ -50,6 +50,13 @@ static int aflag = 0;
static int dflag = 0;
static int eflag = 0;
+static const char *nfs_sm_pgmtbl[] = {
+ "showmount",
+ "mount",
+ "mountd",
+ NULL,
+};
+
static struct option longopts[] =
{
{ "all", 0, 0, 'a' },
@@ -78,6 +85,33 @@ static void usage(FILE *fp, int n)
exit(n);
}
+#ifdef HAVE_CLNT_CREATE
+
+/*
+ * Generate an RPC client handle connected to the mountd service
+ * at @hostname, or die trying.
+ *
+ * Supports both AF_INET and AF_INET6 server addresses.
+ */
+static CLIENT *nfs_get_mount_client(const char *hostname)
+{
+ rpcprog_t program = nfs_getrpcbyname(MOUNTPROG, nfs_sm_pgmtbl);
+ CLIENT *client;
+
+ client = clnt_create(hostname, program, MOUNTVERS, "tcp");
+ if (client)
+ return client;
+
+ client = clnt_create(hostname, program, MOUNTVERS, "udp");
+ if (client)
+ return client;
+
+ clnt_pcreateerror("clnt_create");
+ exit(1);
+}
+
+#else /* HAVE_CLNT_CREATE */
+
/*
* Perform a non-blocking connect on the socket fd.
*
@@ -213,6 +247,8 @@ static CLIENT *nfs_get_mount_client(const char *hostname)
return mclient;
}
+#endif /* HAVE_CLNT_CREATE */
+
int main(int argc, char **argv)
{
char hostname_buf[MAXHOSTLEN];
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] Support for IPv6 in the showmount command
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
` (3 preceding siblings ...)
2008-11-18 19:29 ` [PATCH 4/4] showmount command: support querying IPv6 servers Chuck Lever
@ 2008-11-25 14:27 ` Steve Dickson
[not found] ` <492C0B6C.7070104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
4 siblings, 1 reply; 8+ messages in thread
From: Steve Dickson @ 2008-11-25 14:27 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
Chuck Lever wrote:
> Hi Steve-
>
> These patches implement support for rpcbind v3/v4 queries and IPv6 NFS
> servers in the showmount command. Please consider these for the next
> release of nfs-utils.
>
> Thanks!
>
> ---
>
> Chuck Lever (4):
> showmount command: support querying IPv6 servers
> showmount command: move logic to acquire RPC client handle out of main()
> showmount command: Remove unused local getport() implementation
> showmount command: call nfs_getport instead of local getport
>
>
> utils/showmount/showmount.c | 237 +++++++++++++++++--------------------------
> 1 files changed, 91 insertions(+), 146 deletions(-)
All four patch have been committed and regression tested...
steved.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] Support for IPv6 in the showmount command
[not found] ` <492C0B6C.7070104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
@ 2008-11-25 18:36 ` Chuck Lever
2008-12-01 19:30 ` Steve Dickson
0 siblings, 1 reply; 8+ messages in thread
From: Chuck Lever @ 2008-11-25 18:36 UTC (permalink / raw)
To: Steve Dickson; +Cc: linux-nfs
On Nov 25, 2008, at Nov 25, 2008, 9:27 AM, Steve Dickson wrote:
> Chuck Lever wrote:
>> Hi Steve-
>>
>> These patches implement support for rpcbind v3/v4 queries and IPv6
>> NFS
>> servers in the showmount command. Please consider these for the next
>> release of nfs-utils.
>>
>> Thanks!
>>
>> ---
>>
>> Chuck Lever (4):
>> showmount command: support querying IPv6 servers
>> showmount command: move logic to acquire RPC client handle out
>> of main()
>> showmount command: Remove unused local getport() implementation
>> showmount command: call nfs_getport instead of local getport
>>
>>
>> utils/showmount/showmount.c | 237 ++++++++++++++++
>> +--------------------------
>> 1 files changed, 91 insertions(+), 146 deletions(-)
> All four patch have been committed and regression tested...
Thanks.
Neil posted a patch around start_statd earlier this week. My next set
of patches touches this part of mount.nfs. Are you planning to apply
his patch? I can wait for that and rework my patches when you're ready.
--
Chuck Lever
chuck[dot]lever[at]oracle[dot]com
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/4] Support for IPv6 in the showmount command
2008-11-25 18:36 ` Chuck Lever
@ 2008-12-01 19:30 ` Steve Dickson
0 siblings, 0 replies; 8+ messages in thread
From: Steve Dickson @ 2008-12-01 19:30 UTC (permalink / raw)
To: Chuck Lever; +Cc: linux-nfs
Chuck Lever wrote:
> On Nov 25, 2008, at Nov 25, 2008, 9:27 AM, Steve Dickson wrote:
>> Chuck Lever wrote:
>>> Hi Steve-
>>>
>>> These patches implement support for rpcbind v3/v4 queries and IPv6 NFS
>>> servers in the showmount command. Please consider these for the next
>>> release of nfs-utils.
>>>
>>> Thanks!
>>>
>>> ---
>>>
>>> Chuck Lever (4):
>>> showmount command: support querying IPv6 servers
>>> showmount command: move logic to acquire RPC client handle out
>>> of main()
>>> showmount command: Remove unused local getport() implementation
>>> showmount command: call nfs_getport instead of local getport
>>>
>>>
>>> utils/showmount/showmount.c | 237
>>> +++++++++++++++++--------------------------
>>> 1 files changed, 91 insertions(+), 146 deletions(-)
>> All four patch have been committed and regression tested...
>
> Thanks.
>
> Neil posted a patch around start_statd earlier this week. My next set
> of patches touches this part of mount.nfs. Are you planning to apply his
> patch? I can wait for that and rework my patches when you're ready.
I believe everything that's needed should be there... let me know if something
is missing...
steved.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2008-12-01 19:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-18 19:29 [PATCH 0/4] Support for IPv6 in the showmount command Chuck Lever
[not found] ` <20081118192711.22516.2801.stgit-07a7zB5ZJzbwdl/1UfZZQIVfYA8g3rJ/@public.gmane.org>
2008-11-18 19:29 ` [PATCH 1/4] showmount command: call nfs_getport instead of local getport Chuck Lever
2008-11-18 19:29 ` [PATCH 2/4] showmount command: Remove unused local getport() implementation Chuck Lever
2008-11-18 19:29 ` [PATCH 3/4] showmount command: move logic to acquire RPC client handle out of main() Chuck Lever
2008-11-18 19:29 ` [PATCH 4/4] showmount command: support querying IPv6 servers Chuck Lever
2008-11-25 14:27 ` [PATCH 0/4] Support for IPv6 in the showmount command Steve Dickson
[not found] ` <492C0B6C.7070104-AfCzQyP5zfLQT0dZR+AlfA@public.gmane.org>
2008-11-25 18:36 ` Chuck Lever
2008-12-01 19:30 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox