Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 252791
b: refs/heads/master
c: 7402ab1
h: refs/heads/master
i:
  252789: 5e2a80f
  252787: 3c2b654
  252783: dff1232
v: v3
  • Loading branch information
Chuck Lever authored and Trond Myklebust committed May 27, 2011
1 parent fd6d1a8 commit 814af63
Show file tree
Hide file tree
Showing 3 changed files with 86 additions and 15 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da09eb93033e7204cb3e3f3140b46cf108c42c8f
refs/heads/master: 7402ab19cdd5943c7dd4f3399afe3abda8077ef5
97 changes: 83 additions & 14 deletions trunk/net/sunrpc/rpcb_clnt.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <linux/types.h>
#include <linux/socket.h>
#include <linux/un.h>
#include <linux/in.h>
#include <linux/in6.h>
#include <linux/kernel.h>
Expand All @@ -32,6 +33,8 @@
# define RPCDBG_FACILITY RPCDBG_BIND
#endif

#define RPCBIND_SOCK_PATHNAME "/var/run/rpcbind.sock"

#define RPCBIND_PROGRAM (100000u)
#define RPCBIND_PORT (111u)

Expand Down Expand Up @@ -158,20 +161,69 @@ static void rpcb_map_release(void *data)
kfree(map);
}

static const struct sockaddr_in rpcb_inaddr_loopback = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = htons(RPCBIND_PORT),
};
/*
* Returns zero on success, otherwise a negative errno value
* is returned.
*/
static int rpcb_create_local_unix(void)
{
static const struct sockaddr_un rpcb_localaddr_rpcbind = {
.sun_family = AF_LOCAL,
.sun_path = RPCBIND_SOCK_PATHNAME,
};
struct rpc_create_args args = {
.net = &init_net,
.protocol = XPRT_TRANSPORT_LOCAL,
.address = (struct sockaddr *)&rpcb_localaddr_rpcbind,
.addrsize = sizeof(rpcb_localaddr_rpcbind),
.servername = "localhost",
.program = &rpcb_program,
.version = RPCBVERS_2,
.authflavor = RPC_AUTH_NULL,
};
struct rpc_clnt *clnt, *clnt4;
int result = 0;

/*
* Because we requested an RPC PING at transport creation time,
* this works only if the user space portmapper is rpcbind, and
* it's listening on AF_LOCAL on the named socket.
*/
clnt = rpc_create(&args);
if (IS_ERR(clnt)) {
dprintk("RPC: failed to create AF_LOCAL rpcbind "
"client (errno %ld).\n", PTR_ERR(clnt));
result = -PTR_ERR(clnt);
goto out;
}

clnt4 = rpc_bind_new_program(clnt, &rpcb_program, RPCBVERS_4);
if (IS_ERR(clnt4)) {
dprintk("RPC: failed to bind second program to "
"rpcbind v4 client (errno %ld).\n",
PTR_ERR(clnt4));
clnt4 = NULL;
}

/* Protected by rpcb_create_local_mutex */
rpcb_local_clnt = clnt;
rpcb_local_clnt4 = clnt4;

static DEFINE_MUTEX(rpcb_create_local_mutex);
out:
return result;
}

/*
* Returns zero on success, otherwise a negative errno value
* is returned.
*/
static int rpcb_create_local(void)
static int rpcb_create_local_net(void)
{
static const struct sockaddr_in rpcb_inaddr_loopback = {
.sin_family = AF_INET,
.sin_addr.s_addr = htonl(INADDR_LOOPBACK),
.sin_port = htons(RPCBIND_PORT),
};
struct rpc_create_args args = {
.net = &init_net,
.protocol = XPRT_TRANSPORT_TCP,
Expand All @@ -186,13 +238,6 @@ static int rpcb_create_local(void)
struct rpc_clnt *clnt, *clnt4;
int result = 0;

if (rpcb_local_clnt)
return result;

mutex_lock(&rpcb_create_local_mutex);
if (rpcb_local_clnt)
goto out;

clnt = rpc_create(&args);
if (IS_ERR(clnt)) {
dprintk("RPC: failed to create local rpcbind "
Expand All @@ -214,9 +259,33 @@ static int rpcb_create_local(void)
clnt4 = NULL;
}

/* Protected by rpcb_create_local_mutex */
rpcb_local_clnt = clnt;
rpcb_local_clnt4 = clnt4;

out:
return result;
}

/*
* Returns zero on success, otherwise a negative errno value
* is returned.
*/
static int rpcb_create_local(void)
{
static DEFINE_MUTEX(rpcb_create_local_mutex);
int result = 0;

if (rpcb_local_clnt)
return result;

mutex_lock(&rpcb_create_local_mutex);
if (rpcb_local_clnt)
goto out;

if (rpcb_create_local_unix() != 0)
result = rpcb_create_local_net();

out:
mutex_unlock(&rpcb_create_local_mutex);
return result;
Expand Down
2 changes: 2 additions & 0 deletions trunk/net/sunrpc/svc.c
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,8 @@ static void svc_unregister(const struct svc_serv *serv)
if (progp->pg_vers[i]->vs_hidden)
continue;

dprintk("svc: attempting to unregister %sv%u\n",
progp->pg_name, i);
__svc_unregister(progp->pg_prog, i, progp->pg_name);
}
}
Expand Down

0 comments on commit 814af63

Please sign in to comment.