Commit d5e30025 authored by David Howells's avatar David Howells

rxrpc: procfs file to list local endpoints

Add a proc file to list local rxrpc endpoints using the object cache
facility to do much of the work.
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
parent b2347cb5
......@@ -842,6 +842,8 @@ static int __init af_rxrpc_init(void)
proc_create("rxrpc_calls", 0, init_net.proc_net, &rxrpc_call_seq_fops);
proc_create("rxrpc_conns", 0, init_net.proc_net,
&rxrpc_connection_seq_fops);
proc_create_data("rxrpc_locals", 0, init_net.proc_net,
&objcache_seq_fops, &rxrpc_local_cache);
#endif
return 0;
......@@ -883,6 +885,7 @@ static void __exit af_rxrpc_exit(void)
_debug("flush scheduled work");
flush_workqueue(rxrpc_workqueue);
remove_proc_entry("rxrpc_locals", init_net.proc_net);
remove_proc_entry("rxrpc_conns", init_net.proc_net);
remove_proc_entry("rxrpc_calls", init_net.proc_net);
destroy_workqueue(rxrpc_workqueue);
......
......@@ -19,6 +19,7 @@
#include <net/af_rxrpc.h>
#include "ar-internal.h"
static int rxrpc_local_seq_show(struct seq_file *, void *);
static void rxrpc_local_prepare_for_gc(struct obj_node *);
static void rxrpc_local_gc_rcu(struct rcu_head *);
static unsigned long rxrpc_local_hash_key(const void *);
......@@ -29,6 +30,7 @@ static struct hlist_head rxrpc_local_cache_hash[16];
struct objcache rxrpc_local_cache = {
.name = "locals",
.seq_show = rxrpc_local_seq_show,
.prepare_for_gc = rxrpc_local_prepare_for_gc,
.gc_rcu = rxrpc_local_gc_rcu,
.hash_key = rxrpc_local_hash_key,
......@@ -309,3 +311,30 @@ static void rxrpc_local_gc_rcu(struct rcu_head *rcu)
objcache_obj_rcu_done(&rxrpc_local_cache);
_leave("");
}
/*
* Display a local endpoint in /proc/net/rxrpc_locals.
*/
static int rxrpc_local_seq_show(struct seq_file *seq, void *v)
{
struct rxrpc_local *local;
if (v == SEQ_START_TOKEN) {
seq_puts(seq, "Use Proto LPort Local\n");
return 0;
}
local = hlist_entry(v, struct rxrpc_local, obj.link);
switch (local->srx.transport.family) {
case AF_INET:
seq_printf(seq,
"%3d UDP %5hu %pI4\n",
atomic_read(&local->obj.usage),
ntohs(local->srx.transport.sin.sin_port),
&local->srx.transport.sin.sin_addr);
break;
}
return 0;
}
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