Skip to content

Commit 41cb320

Browse files
Anna SchumakerTrond Myklebust
authored andcommitted
sunrpc: Add a sysfs attr for xprtsec
This allows the admin to check the TLS configuration for each xprt. Reviewed-by: Benjamin Coddington <bcodding@redhat.com> Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com> Link: https://lore.kernel.org/r/20250207204225.594002-3-anna@kernel.org Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent e171b96 commit 41cb320

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

net/sunrpc/sysfs.c

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,31 @@ static ssize_t rpc_sysfs_xprt_srcaddr_show(struct kobject *kobj,
129129
return ret;
130130
}
131131

132+
static const char *xprtsec_strings[] = {
133+
[RPC_XPRTSEC_NONE] = "none",
134+
[RPC_XPRTSEC_TLS_ANON] = "tls-anon",
135+
[RPC_XPRTSEC_TLS_X509] = "tls-x509",
136+
};
137+
138+
static ssize_t rpc_sysfs_xprt_xprtsec_show(struct kobject *kobj,
139+
struct kobj_attribute *attr,
140+
char *buf)
141+
{
142+
struct rpc_xprt *xprt = rpc_sysfs_xprt_kobj_get_xprt(kobj);
143+
ssize_t ret;
144+
145+
if (!xprt) {
146+
ret = sprintf(buf, "<closed>\n");
147+
goto out;
148+
}
149+
150+
ret = sprintf(buf, "%s\n", xprtsec_strings[xprt->xprtsec.policy]);
151+
xprt_put(xprt);
152+
out:
153+
return ret;
154+
155+
}
156+
132157
static ssize_t rpc_sysfs_xprt_info_show(struct kobject *kobj,
133158
struct kobj_attribute *attr, char *buf)
134159
{
@@ -404,6 +429,9 @@ static struct kobj_attribute rpc_sysfs_xprt_dstaddr = __ATTR(dstaddr,
404429
static struct kobj_attribute rpc_sysfs_xprt_srcaddr = __ATTR(srcaddr,
405430
0644, rpc_sysfs_xprt_srcaddr_show, NULL);
406431

432+
static struct kobj_attribute rpc_sysfs_xprt_xprtsec = __ATTR(xprtsec,
433+
0644, rpc_sysfs_xprt_xprtsec_show, NULL);
434+
407435
static struct kobj_attribute rpc_sysfs_xprt_info = __ATTR(xprt_info,
408436
0444, rpc_sysfs_xprt_info_show, NULL);
409437

@@ -413,6 +441,7 @@ static struct kobj_attribute rpc_sysfs_xprt_change_state = __ATTR(xprt_state,
413441
static struct attribute *rpc_sysfs_xprt_attrs[] = {
414442
&rpc_sysfs_xprt_dstaddr.attr,
415443
&rpc_sysfs_xprt_srcaddr.attr,
444+
&rpc_sysfs_xprt_xprtsec.attr,
416445
&rpc_sysfs_xprt_info.attr,
417446
&rpc_sysfs_xprt_change_state.attr,
418447
NULL,

0 commit comments

Comments
 (0)