1 /* /proc/net/ support for AF_RXRPC
3 * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
4 * Written by David Howells (dhowells@redhat.com)
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
12 #include <linux/module.h>
14 #include <net/af_rxrpc.h>
15 #include "ar-internal.h"
17 static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = {
18 [RXRPC_CONN_UNUSED] = "Unused ",
19 [RXRPC_CONN_CLIENT] = "Client ",
20 [RXRPC_CONN_SERVICE_PREALLOC] = "SvPrealc",
21 [RXRPC_CONN_SERVICE_UNSECURED] = "SvUnsec ",
22 [RXRPC_CONN_SERVICE_CHALLENGING] = "SvChall ",
23 [RXRPC_CONN_SERVICE] = "SvSecure",
24 [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort",
25 [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort",
29 * generate a list of extant and dead calls in /proc/net/rxrpc_calls
31 static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
34 read_lock(&rxrpc_call_lock);
35 return seq_list_start_head(&rxrpc_calls, *_pos);
38 static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
40 return seq_list_next(v, &rxrpc_calls, pos);
43 static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
45 read_unlock(&rxrpc_call_lock);
49 static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
51 struct rxrpc_local *local;
52 struct rxrpc_sock *rx;
53 struct rxrpc_peer *peer;
54 struct rxrpc_call *call;
55 char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
57 if (v == &rxrpc_calls) {
60 " SvID ConnID CallID End Use State Abort "
65 call = list_entry(v, struct rxrpc_call, link);
67 rx = rcu_dereference(call->socket);
69 local = READ_ONCE(rx->local);
71 sprintf(lbuff, "%pI4:%u",
72 &local->srx.transport.sin.sin_addr,
73 ntohs(local->srx.transport.sin.sin_port));
75 strcpy(lbuff, "no_local");
77 strcpy(lbuff, "no_socket");
82 sprintf(rbuff, "%pI4:%u",
83 &peer->srx.transport.sin.sin_addr,
84 ntohs(peer->srx.transport.sin.sin_port));
86 strcpy(rbuff, "no_connection");
89 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
96 rxrpc_is_service_call(call) ? "Svc" : "Clt",
97 atomic_read(&call->usage),
98 rxrpc_call_states[call->state],
105 static const struct seq_operations rxrpc_call_seq_ops = {
106 .start = rxrpc_call_seq_start,
107 .next = rxrpc_call_seq_next,
108 .stop = rxrpc_call_seq_stop,
109 .show = rxrpc_call_seq_show,
112 static int rxrpc_call_seq_open(struct inode *inode, struct file *file)
114 return seq_open(file, &rxrpc_call_seq_ops);
117 const struct file_operations rxrpc_call_seq_fops = {
118 .owner = THIS_MODULE,
119 .open = rxrpc_call_seq_open,
122 .release = seq_release,
126 * generate a list of extant virtual connections in /proc/net/rxrpc_conns
128 static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
130 read_lock(&rxrpc_connection_lock);
131 return seq_list_start_head(&rxrpc_connection_proc_list, *_pos);
134 static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
137 return seq_list_next(v, &rxrpc_connection_proc_list, pos);
140 static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
142 read_unlock(&rxrpc_connection_lock);
145 static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
147 struct rxrpc_connection *conn;
148 char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
150 if (v == &rxrpc_connection_proc_list) {
152 "Proto Local Remote "
153 " SvID ConnID End Use State Key "
159 conn = list_entry(v, struct rxrpc_connection, proc_link);
160 if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) {
161 strcpy(lbuff, "no_local");
162 strcpy(rbuff, "no_connection");
166 sprintf(lbuff, "%pI4:%u",
167 &conn->params.local->srx.transport.sin.sin_addr,
168 ntohs(conn->params.local->srx.transport.sin.sin_port));
170 sprintf(rbuff, "%pI4:%u",
171 &conn->params.peer->srx.transport.sin.sin_addr,
172 ntohs(conn->params.peer->srx.transport.sin.sin_port));
175 "UDP %-22.22s %-22.22s %4x %08x %s %3u"
176 " %s %08x %08x %08x\n",
179 conn->params.service_id,
181 rxrpc_conn_is_service(conn) ? "Svc" : "Clt",
182 atomic_read(&conn->usage),
183 rxrpc_conn_states[conn->state],
184 key_serial(conn->params.key),
185 atomic_read(&conn->serial),
191 static const struct seq_operations rxrpc_connection_seq_ops = {
192 .start = rxrpc_connection_seq_start,
193 .next = rxrpc_connection_seq_next,
194 .stop = rxrpc_connection_seq_stop,
195 .show = rxrpc_connection_seq_show,
199 static int rxrpc_connection_seq_open(struct inode *inode, struct file *file)
201 return seq_open(file, &rxrpc_connection_seq_ops);
204 const struct file_operations rxrpc_connection_seq_fops = {
205 .owner = THIS_MODULE,
206 .open = rxrpc_connection_seq_open,
209 .release = seq_release,