Commit 176e21ee authored by Chuck Lever's avatar Chuck Lever Committed by Trond Myklebust

SUNRPC: Support for RPC over AF_LOCAL transports

TI-RPC introduces the capability of performing RPC over AF_LOCAL
sockets.  It uses this mainly for registering and unregistering
local RPC services securely with the local rpcbind, but we could
also conceivably use it as a generic upcall mechanism.

This patch provides a client-side only implementation for the moment.
We might also consider a server-side implementation to provide
AF_LOCAL access to NLM (for statd downcalls, and such like).

Autobinding is not supported on kernel AF_LOCAL transports at this
time.  Kernel ULPs must specify the pathname of the remote endpoint
when an AF_LOCAL transport is created.  rpcbind supports registering
services available via AF_LOCAL, so the kernel could handle it with
some adjustment to ->rpcbind and ->set_port.  But we don't need this
feature for doing upcalls via well-known named sockets.

This has not been tested with ULPs that move a substantial amount of
data.  Thus, I can't attest to how robust the write_space and
congestion management logic is.
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 559649ef
...@@ -145,6 +145,7 @@ typedef __be32 rpc_fraghdr; ...@@ -145,6 +145,7 @@ typedef __be32 rpc_fraghdr;
#define RPCBIND_NETID_TCP "tcp" #define RPCBIND_NETID_TCP "tcp"
#define RPCBIND_NETID_UDP6 "udp6" #define RPCBIND_NETID_UDP6 "udp6"
#define RPCBIND_NETID_TCP6 "tcp6" #define RPCBIND_NETID_TCP6 "tcp6"
#define RPCBIND_NETID_LOCAL "local"
/* /*
* Note that RFC 1833 does not put any size restrictions on the * Note that RFC 1833 does not put any size restrictions on the
......
...@@ -141,7 +141,8 @@ enum xprt_transports { ...@@ -141,7 +141,8 @@ enum xprt_transports {
XPRT_TRANSPORT_UDP = IPPROTO_UDP, XPRT_TRANSPORT_UDP = IPPROTO_UDP,
XPRT_TRANSPORT_TCP = IPPROTO_TCP, XPRT_TRANSPORT_TCP = IPPROTO_TCP,
XPRT_TRANSPORT_BC_TCP = IPPROTO_TCP | XPRT_TRANSPORT_BC, XPRT_TRANSPORT_BC_TCP = IPPROTO_TCP | XPRT_TRANSPORT_BC,
XPRT_TRANSPORT_RDMA = 256 XPRT_TRANSPORT_RDMA = 256,
XPRT_TRANSPORT_LOCAL = 257,
}; };
struct rpc_xprt { struct rpc_xprt {
......
...@@ -28,7 +28,9 @@ ...@@ -28,7 +28,9 @@
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/utsname.h> #include <linux/utsname.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/in.h>
#include <linux/in6.h> #include <linux/in6.h>
#include <linux/un.h>
#include <linux/sunrpc/clnt.h> #include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/rpc_pipe_fs.h> #include <linux/sunrpc/rpc_pipe_fs.h>
...@@ -294,6 +296,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) ...@@ -294,6 +296,8 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
* up a string representation of the passed-in address. * up a string representation of the passed-in address.
*/ */
if (args->servername == NULL) { if (args->servername == NULL) {
struct sockaddr_un *sun =
(struct sockaddr_un *)args->address;
struct sockaddr_in *sin = struct sockaddr_in *sin =
(struct sockaddr_in *)args->address; (struct sockaddr_in *)args->address;
struct sockaddr_in6 *sin6 = struct sockaddr_in6 *sin6 =
...@@ -301,6 +305,10 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args) ...@@ -301,6 +305,10 @@ struct rpc_clnt *rpc_create(struct rpc_create_args *args)
servername[0] = '\0'; servername[0] = '\0';
switch (args->address->sa_family) { switch (args->address->sa_family) {
case AF_LOCAL:
snprintf(servername, sizeof(servername), "%s",
sun->sun_path);
break;
case AF_INET: case AF_INET:
snprintf(servername, sizeof(servername), "%pI4", snprintf(servername, sizeof(servername), "%pI4",
&sin->sin_addr.s_addr); &sin->sin_addr.s_addr);
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment