Skip to content

Commit

Permalink
SUNRPC: Add a TCP-with-TLS RPC transport class
Browse files Browse the repository at this point in the history
Use the new TLS handshake API to enable the SunRPC client code
to request a TLS handshake. This implements support for RFC 9289,
only on TCP sockets.

Upper layers such as NFS use RPC-with-TLS to protect in-transit
traffic.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
  • Loading branch information
chucklever authored and Trond Myklebust committed Jun 19, 2023
1 parent dea034b commit 75eb6af
Show file tree
Hide file tree
Showing 5 changed files with 418 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/sunrpc/xprt.h
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ enum xprt_transports {
XPRT_TRANSPORT_RDMA = 256,
XPRT_TRANSPORT_BC_RDMA = XPRT_TRANSPORT_RDMA | XPRT_TRANSPORT_BC,
XPRT_TRANSPORT_LOCAL = 257,
XPRT_TRANSPORT_TCP_TLS = 258,
};

struct rpc_sysfs_xprt;
Expand Down
2 changes: 2 additions & 0 deletions include/linux/sunrpc/xprtsock.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ struct sock_xprt {
struct work_struct error_worker;
struct work_struct recv_worker;
struct mutex recv_mutex;
struct completion handshake_done;
struct sockaddr_storage srcaddr;
unsigned short srcport;
int xprt_err;
struct rpc_clnt *clnt;

/*
* UDP socket buffer size parameters
Expand Down
44 changes: 44 additions & 0 deletions include/trace/events/sunrpc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1525,6 +1525,50 @@ TRACE_EVENT(rpcb_unregister,
)
);

/**
** RPC-over-TLS tracepoints
**/

DECLARE_EVENT_CLASS(rpc_tls_class,
TP_PROTO(
const struct rpc_clnt *clnt,
const struct rpc_xprt *xprt
),

TP_ARGS(clnt, xprt),

TP_STRUCT__entry(
__field(unsigned long, requested_policy)
__field(u32, version)
__string(servername, xprt->servername)
__string(progname, clnt->cl_program->name)
),

TP_fast_assign(
__entry->requested_policy = clnt->cl_xprtsec.policy;
__entry->version = clnt->cl_vers;
__assign_str(servername, xprt->servername);
__assign_str(progname, clnt->cl_program->name)
),

TP_printk("server=%s %sv%u requested_policy=%s",
__get_str(servername), __get_str(progname), __entry->version,
rpc_show_xprtsec_policy(__entry->requested_policy)
)
);

#define DEFINE_RPC_TLS_EVENT(name) \
DEFINE_EVENT(rpc_tls_class, rpc_tls_##name, \
TP_PROTO( \
const struct rpc_clnt *clnt, \
const struct rpc_xprt *xprt \
), \
TP_ARGS(clnt, xprt))

DEFINE_RPC_TLS_EVENT(unavailable);
DEFINE_RPC_TLS_EVENT(not_started);


/* Record an xdr_buf containing a fully-formed RPC message */
DECLARE_EVENT_CLASS(svc_xdr_msg_class,
TP_PROTO(
Expand Down
1 change: 1 addition & 0 deletions net/sunrpc/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ static ssize_t rpc_sysfs_xprt_dstaddr_store(struct kobject *kobj,
if (!xprt)
return 0;
if (!(xprt->xprt_class->ident == XPRT_TRANSPORT_TCP ||
xprt->xprt_class->ident == XPRT_TRANSPORT_TCP_TLS ||
xprt->xprt_class->ident == XPRT_TRANSPORT_RDMA)) {
xprt_put(xprt);
return -EOPNOTSUPP;
Expand Down
Loading

0 comments on commit 75eb6af

Please sign in to comment.