diff options
Diffstat (limited to 'net/rxrpc/ar-proc.c')
-rw-r--r-- | net/rxrpc/ar-proc.c | 247 |
1 files changed, 247 insertions, 0 deletions
diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c new file mode 100644 index 000000000000..58f4b4e5cece --- /dev/null +++ b/net/rxrpc/ar-proc.c | |||
@@ -0,0 +1,247 @@ | |||
1 | /* /proc/net/ support for AF_RXRPC | ||
2 | * | ||
3 | * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. | ||
4 | * Written by David Howells (dhowells@redhat.com) | ||
5 | * | ||
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. | ||
10 | */ | ||
11 | |||
12 | #include <linux/module.h> | ||
13 | #include <net/sock.h> | ||
14 | #include <net/af_rxrpc.h> | ||
15 | #include "ar-internal.h" | ||
16 | |||
17 | static const char *rxrpc_conn_states[] = { | ||
18 | [RXRPC_CONN_UNUSED] = "Unused ", | ||
19 | [RXRPC_CONN_CLIENT] = "Client ", | ||
20 | [RXRPC_CONN_SERVER_UNSECURED] = "SvUnsec ", | ||
21 | [RXRPC_CONN_SERVER_CHALLENGING] = "SvChall ", | ||
22 | [RXRPC_CONN_SERVER] = "SvSecure", | ||
23 | [RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort", | ||
24 | [RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort", | ||
25 | [RXRPC_CONN_NETWORK_ERROR] = "NetError", | ||
26 | }; | ||
27 | |||
28 | const char *rxrpc_call_states[] = { | ||
29 | [RXRPC_CALL_CLIENT_SEND_REQUEST] = "ClSndReq", | ||
30 | [RXRPC_CALL_CLIENT_AWAIT_REPLY] = "ClAwtRpl", | ||
31 | [RXRPC_CALL_CLIENT_RECV_REPLY] = "ClRcvRpl", | ||
32 | [RXRPC_CALL_CLIENT_FINAL_ACK] = "ClFnlACK", | ||
33 | [RXRPC_CALL_SERVER_SECURING] = "SvSecure", | ||
34 | [RXRPC_CALL_SERVER_ACCEPTING] = "SvAccept", | ||
35 | [RXRPC_CALL_SERVER_RECV_REQUEST] = "SvRcvReq", | ||
36 | [RXRPC_CALL_SERVER_ACK_REQUEST] = "SvAckReq", | ||
37 | [RXRPC_CALL_SERVER_SEND_REPLY] = "SvSndRpl", | ||
38 | [RXRPC_CALL_SERVER_AWAIT_ACK] = "SvAwtACK", | ||
39 | [RXRPC_CALL_COMPLETE] = "Complete", | ||
40 | [RXRPC_CALL_SERVER_BUSY] = "SvBusy ", | ||
41 | [RXRPC_CALL_REMOTELY_ABORTED] = "RmtAbort", | ||
42 | [RXRPC_CALL_LOCALLY_ABORTED] = "LocAbort", | ||
43 | [RXRPC_CALL_NETWORK_ERROR] = "NetError", | ||
44 | [RXRPC_CALL_DEAD] = "Dead ", | ||
45 | }; | ||
46 | |||
47 | /* | ||
48 | * generate a list of extant and dead calls in /proc/net/rxrpc_calls | ||
49 | */ | ||
50 | static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos) | ||
51 | { | ||
52 | struct list_head *_p; | ||
53 | loff_t pos = *_pos; | ||
54 | |||
55 | read_lock(&rxrpc_call_lock); | ||
56 | if (!pos) | ||
57 | return SEQ_START_TOKEN; | ||
58 | pos--; | ||
59 | |||
60 | list_for_each(_p, &rxrpc_calls) | ||
61 | if (!pos--) | ||
62 | break; | ||
63 | |||
64 | return _p != &rxrpc_calls ? _p : NULL; | ||
65 | } | ||
66 | |||
67 | static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos) | ||
68 | { | ||
69 | struct list_head *_p; | ||
70 | |||
71 | (*pos)++; | ||
72 | |||
73 | _p = v; | ||
74 | _p = (v == SEQ_START_TOKEN) ? rxrpc_calls.next : _p->next; | ||
75 | |||
76 | return _p != &rxrpc_calls ? _p : NULL; | ||
77 | } | ||
78 | |||
79 | static void rxrpc_call_seq_stop(struct seq_file *seq, void *v) | ||
80 | { | ||
81 | read_unlock(&rxrpc_call_lock); | ||
82 | } | ||
83 | |||
84 | static int rxrpc_call_seq_show(struct seq_file *seq, void *v) | ||
85 | { | ||
86 | struct rxrpc_transport *trans; | ||
87 | struct rxrpc_call *call; | ||
88 | char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1]; | ||
89 | |||
90 | if (v == SEQ_START_TOKEN) { | ||
91 | seq_puts(seq, | ||
92 | "Proto Local Remote " | ||
93 | " SvID ConnID CallID End Use State Abort " | ||
94 | " UserID\n"); | ||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | call = list_entry(v, struct rxrpc_call, link); | ||
99 | trans = call->conn->trans; | ||
100 | |||
101 | sprintf(lbuff, NIPQUAD_FMT":%u", | ||
102 | NIPQUAD(trans->local->srx.transport.sin.sin_addr), | ||
103 | ntohs(trans->local->srx.transport.sin.sin_port)); | ||
104 | |||
105 | sprintf(rbuff, NIPQUAD_FMT":%u", | ||
106 | NIPQUAD(trans->peer->srx.transport.sin.sin_addr), | ||
107 | ntohs(trans->peer->srx.transport.sin.sin_port)); | ||
108 | |||
109 | seq_printf(seq, | ||
110 | "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u" | ||
111 | " %-8.8s %08x %lx\n", | ||
112 | lbuff, | ||
113 | rbuff, | ||
114 | ntohs(call->conn->service_id), | ||
115 | ntohl(call->conn->cid), | ||
116 | ntohl(call->call_id), | ||
117 | call->conn->in_clientflag ? "Svc" : "Clt", | ||
118 | atomic_read(&call->usage), | ||
119 | rxrpc_call_states[call->state], | ||
120 | call->abort_code, | ||
121 | call->user_call_ID); | ||
122 | |||
123 | return 0; | ||
124 | } | ||
125 | |||
126 | static struct seq_operations rxrpc_call_seq_ops = { | ||
127 | .start = rxrpc_call_seq_start, | ||
128 | .next = rxrpc_call_seq_next, | ||
129 | .stop = rxrpc_call_seq_stop, | ||
130 | .show = rxrpc_call_seq_show, | ||
131 | }; | ||
132 | |||
133 | static int rxrpc_call_seq_open(struct inode *inode, struct file *file) | ||
134 | { | ||
135 | return seq_open(file, &rxrpc_call_seq_ops); | ||
136 | } | ||
137 | |||
138 | struct file_operations rxrpc_call_seq_fops = { | ||
139 | .owner = THIS_MODULE, | ||
140 | .open = rxrpc_call_seq_open, | ||
141 | .read = seq_read, | ||
142 | .llseek = seq_lseek, | ||
143 | .release = seq_release_private, | ||
144 | }; | ||
145 | |||
146 | /* | ||
147 | * generate a list of extant virtual connections in /proc/net/rxrpc_conns | ||
148 | */ | ||
149 | static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos) | ||
150 | { | ||
151 | struct list_head *_p; | ||
152 | loff_t pos = *_pos; | ||
153 | |||
154 | read_lock(&rxrpc_connection_lock); | ||
155 | if (!pos) | ||
156 | return SEQ_START_TOKEN; | ||
157 | pos--; | ||
158 | |||
159 | list_for_each(_p, &rxrpc_connections) | ||
160 | if (!pos--) | ||
161 | break; | ||
162 | |||
163 | return _p != &rxrpc_connections ? _p : NULL; | ||
164 | } | ||
165 | |||
166 | static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v, | ||
167 | loff_t *pos) | ||
168 | { | ||
169 | struct list_head *_p; | ||
170 | |||
171 | (*pos)++; | ||
172 | |||
173 | _p = v; | ||
174 | _p = (v == SEQ_START_TOKEN) ? rxrpc_connections.next : _p->next; | ||
175 | |||
176 | return _p != &rxrpc_connections ? _p : NULL; | ||
177 | } | ||
178 | |||
179 | static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v) | ||
180 | { | ||
181 | read_unlock(&rxrpc_connection_lock); | ||
182 | } | ||
183 | |||
184 | static int rxrpc_connection_seq_show(struct seq_file *seq, void *v) | ||
185 | { | ||
186 | struct rxrpc_connection *conn; | ||
187 | struct rxrpc_transport *trans; | ||
188 | char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1]; | ||
189 | |||
190 | if (v == SEQ_START_TOKEN) { | ||
191 | seq_puts(seq, | ||
192 | "Proto Local Remote " | ||
193 | " SvID ConnID Calls End Use State Key " | ||
194 | " Serial ISerial\n" | ||
195 | ); | ||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | conn = list_entry(v, struct rxrpc_connection, link); | ||
200 | trans = conn->trans; | ||
201 | |||
202 | sprintf(lbuff, NIPQUAD_FMT":%u", | ||
203 | NIPQUAD(trans->local->srx.transport.sin.sin_addr), | ||
204 | ntohs(trans->local->srx.transport.sin.sin_port)); | ||
205 | |||
206 | sprintf(rbuff, NIPQUAD_FMT":%u", | ||
207 | NIPQUAD(trans->peer->srx.transport.sin.sin_addr), | ||
208 | ntohs(trans->peer->srx.transport.sin.sin_port)); | ||
209 | |||
210 | seq_printf(seq, | ||
211 | "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u" | ||
212 | " %s %08x %08x %08x\n", | ||
213 | lbuff, | ||
214 | rbuff, | ||
215 | ntohs(conn->service_id), | ||
216 | ntohl(conn->cid), | ||
217 | conn->call_counter, | ||
218 | conn->in_clientflag ? "Svc" : "Clt", | ||
219 | atomic_read(&conn->usage), | ||
220 | rxrpc_conn_states[conn->state], | ||
221 | key_serial(conn->key), | ||
222 | atomic_read(&conn->serial), | ||
223 | atomic_read(&conn->hi_serial)); | ||
224 | |||
225 | return 0; | ||
226 | } | ||
227 | |||
228 | static struct seq_operations rxrpc_connection_seq_ops = { | ||
229 | .start = rxrpc_connection_seq_start, | ||
230 | .next = rxrpc_connection_seq_next, | ||
231 | .stop = rxrpc_connection_seq_stop, | ||
232 | .show = rxrpc_connection_seq_show, | ||
233 | }; | ||
234 | |||
235 | |||
236 | static int rxrpc_connection_seq_open(struct inode *inode, struct file *file) | ||
237 | { | ||
238 | return seq_open(file, &rxrpc_connection_seq_ops); | ||
239 | } | ||
240 | |||
241 | struct file_operations rxrpc_connection_seq_fops = { | ||
242 | .owner = THIS_MODULE, | ||
243 | .open = rxrpc_connection_seq_open, | ||
244 | .read = seq_read, | ||
245 | .llseek = seq_lseek, | ||
246 | .release = seq_release_private, | ||
247 | }; | ||