From afba62a753549ae3c2a713b08163ab84bb622183 Mon Sep 17 00:00:00 2001 From: Jeff Layton Date: Wed, 15 Apr 2009 12:01:46 -0400 Subject: [PATCH] nfs-utils: switch gssd to use standard function for getting an RPC client We 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. Reviewed-by: Chuck Lever Signed-off-by: Jeff Layton Signed-off-by: Steve Dickson --- utils/gssd/gssd_proc.c | 41 ++++++++++++----------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/utils/gssd/gssd_proc.c b/utils/gssd/gssd_proc.c index 4efc088..1d55d8d 100644 --- a/utils/gssd/gssd_proc.c +++ b/utils/gssd/gssd_proc.c @@ -626,9 +626,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; @@ -708,33 +707,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); -- 2.39.5