* [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info
@ 2025-01-22 14:59 Jeff Layton
2025-01-22 15:03 ` Jeff Layton
2025-01-22 15:09 ` Chuck Lever
0 siblings, 2 replies; 3+ messages in thread
From: Jeff Layton @ 2025-01-22 14:59 UTC (permalink / raw)
To: Chuck Lever, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Trond Myklebust, Anna Schumaker, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: linux-nfs, netdev, linux-kernel, Jeff Layton
The output format should provide a value that matches the one in
the /proc/<pid>/ns/net symlink. This makes it simpler to match the
rpc_xprt and rpc_clnt to a particular container.
Also, when the xprt defines the get_srcaddr operation, use that to
display the source address as well.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
This is more client-side code, so I figure this should go in via the NFS
client tree, but if Chuck would rather pick it up, then that's fine too.
---
net/sunrpc/debugfs.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
index a176d5a0b0ee9a2c0ca1d1ed3131b67b782c3296..3b39493234d7079ff762a862bdd51725f36472dc 100644
--- a/net/sunrpc/debugfs.c
+++ b/net/sunrpc/debugfs.c
@@ -179,6 +179,22 @@ xprt_info_show(struct seq_file *f, void *v)
seq_printf(f, "addr: %s\n", xprt->address_strings[RPC_DISPLAY_ADDR]);
seq_printf(f, "port: %s\n", xprt->address_strings[RPC_DISPLAY_PORT]);
seq_printf(f, "state: 0x%lx\n", xprt->state);
+ seq_printf(f, "netns: %u\n", xprt->xprt_net->ns.inum);
+
+ if (xprt->ops->get_srcaddr) {
+ int ret, buflen;
+ char buf[INET6_ADDRSTRLEN];
+
+ buflen = ARRAY_SIZE(buf);
+ ret = xprt->ops->get_srcaddr(xprt, buf, buflen);
+ if (ret > 0) {
+ if (ret < buflen - 1)
+ buf[ret] = '\0';
+ } else {
+ ret = sprintf(buf, "<closed>");
+ }
+ seq_printf(f, "saddr: %s\n", buf);
+ }
return 0;
}
---
base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
change-id: 20250122-nfs-6-14-7f737deb6356
Best regards,
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info
2025-01-22 14:59 [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info Jeff Layton
@ 2025-01-22 15:03 ` Jeff Layton
2025-01-22 15:09 ` Chuck Lever
1 sibling, 0 replies; 3+ messages in thread
From: Jeff Layton @ 2025-01-22 15:03 UTC (permalink / raw)
To: Chuck Lever, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Trond Myklebust, Anna Schumaker, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: linux-nfs, netdev, linux-kernel
On Wed, 2025-01-22 at 09:59 -0500, Jeff Layton wrote:
> The output format should provide a value that matches the one in
> the /proc/<pid>/ns/net symlink. This makes it simpler to match the
> rpc_xprt and rpc_clnt to a particular container.
>
> Also, when the xprt defines the get_srcaddr operation, use that to
> display the source address as well.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> This is more client-side code, so I figure this should go in via the NFS
> client tree, but if Chuck would rather pick it up, then that's fine too.
> ---
> net/sunrpc/debugfs.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
> index a176d5a0b0ee9a2c0ca1d1ed3131b67b782c3296..3b39493234d7079ff762a862bdd51725f36472dc 100644
> --- a/net/sunrpc/debugfs.c
> +++ b/net/sunrpc/debugfs.c
> @@ -179,6 +179,22 @@ xprt_info_show(struct seq_file *f, void *v)
> seq_printf(f, "addr: %s\n", xprt->address_strings[RPC_DISPLAY_ADDR]);
> seq_printf(f, "port: %s\n", xprt->address_strings[RPC_DISPLAY_PORT]);
> seq_printf(f, "state: 0x%lx\n", xprt->state);
> + seq_printf(f, "netns: %u\n", xprt->xprt_net->ns.inum);
> +
> + if (xprt->ops->get_srcaddr) {
> + int ret, buflen;
> + char buf[INET6_ADDRSTRLEN];
> +
> + buflen = ARRAY_SIZE(buf);
> + ret = xprt->ops->get_srcaddr(xprt, buf, buflen);
> + if (ret > 0) {
> + if (ret < buflen - 1)
> + buf[ret] = '\0';
> + } else {
> + ret = sprintf(buf, "<closed>");
> + }
> + seq_printf(f, "saddr: %s\n", buf);
Now that I've sent this, I think we're better off using ret as a length
specifier for the %s argument. I'll send a v2 in a bit.
> + }
> return 0;
> }
>
>
> ---
> base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
> change-id: 20250122-nfs-6-14-7f737deb6356
>
> Best regards,
--
Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info
2025-01-22 14:59 [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info Jeff Layton
2025-01-22 15:03 ` Jeff Layton
@ 2025-01-22 15:09 ` Chuck Lever
1 sibling, 0 replies; 3+ messages in thread
From: Chuck Lever @ 2025-01-22 15:09 UTC (permalink / raw)
To: Jeff Layton, Neil Brown, Olga Kornievskaia, Dai Ngo, Tom Talpey,
Trond Myklebust, Anna Schumaker, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Simon Horman
Cc: linux-nfs, netdev, linux-kernel
On 1/22/25 9:59 AM, Jeff Layton wrote:
> The output format should provide a value that matches the one in
> the /proc/<pid>/ns/net symlink. This makes it simpler to match the
> rpc_xprt and rpc_clnt to a particular container.
>
> Also, when the xprt defines the get_srcaddr operation, use that to
> display the source address as well.
>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
> ---
> This is more client-side code, so I figure this should go in via the NFS
> client tree, but if Chuck would rather pick it up, then that's fine too.
Hi Jeff -
The change seems sensible to me, and it would be better for Anna or
Trond to handle it IMO.
> ---
> net/sunrpc/debugfs.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c
> index a176d5a0b0ee9a2c0ca1d1ed3131b67b782c3296..3b39493234d7079ff762a862bdd51725f36472dc 100644
> --- a/net/sunrpc/debugfs.c
> +++ b/net/sunrpc/debugfs.c
> @@ -179,6 +179,22 @@ xprt_info_show(struct seq_file *f, void *v)
> seq_printf(f, "addr: %s\n", xprt->address_strings[RPC_DISPLAY_ADDR]);
> seq_printf(f, "port: %s\n", xprt->address_strings[RPC_DISPLAY_PORT]);
> seq_printf(f, "state: 0x%lx\n", xprt->state);
> + seq_printf(f, "netns: %u\n", xprt->xprt_net->ns.inum);
IIRC, net->ns.inum is also what the trace points use for this purpose.
> +
> + if (xprt->ops->get_srcaddr) {
> + int ret, buflen;
> + char buf[INET6_ADDRSTRLEN];
> +
> + buflen = ARRAY_SIZE(buf);
> + ret = xprt->ops->get_srcaddr(xprt, buf, buflen);
> + if (ret > 0) {
> + if (ret < buflen - 1)
> + buf[ret] = '\0';
> + } else {
> + ret = sprintf(buf, "<closed>");
> + }
> + seq_printf(f, "saddr: %s\n", buf);
> + }
> return 0;
> }
>
>
> ---
> base-commit: ffd294d346d185b70e28b1a28abe367bbfe53c04
> change-id: 20250122-nfs-6-14-7f737deb6356
>
> Best regards,
--
Chuck Lever
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-01-22 15:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-01-22 14:59 [PATCH] sunrpc: add netns inum and srcaddr to debugfs rpc_xprt info Jeff Layton
2025-01-22 15:03 ` Jeff Layton
2025-01-22 15:09 ` Chuck Lever
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®