]>
Commit | Line | Data |
---|---|---|
17926a79 DH |
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 | ||
bba304db DH |
17 | static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = { |
18 | [RXRPC_CONN_UNUSED] = "Unused ", | |
19 | [RXRPC_CONN_CLIENT] = "Client ", | |
00e90712 | 20 | [RXRPC_CONN_SERVICE_PREALLOC] = "SvPrealc", |
bba304db DH |
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", | |
17926a79 DH |
26 | }; |
27 | ||
17926a79 DH |
28 | /* |
29 | * generate a list of extant and dead calls in /proc/net/rxrpc_calls | |
30 | */ | |
31 | static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos) | |
32 | { | |
2baec2c3 DH |
33 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
34 | ||
8d94aa38 | 35 | rcu_read_lock(); |
2baec2c3 DH |
36 | read_lock(&rxnet->call_lock); |
37 | return seq_list_start_head(&rxnet->calls, *_pos); | |
17926a79 DH |
38 | } |
39 | ||
40 | static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos) | |
41 | { | |
2baec2c3 DH |
42 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
43 | ||
44 | return seq_list_next(v, &rxnet->calls, pos); | |
17926a79 DH |
45 | } |
46 | ||
47 | static void rxrpc_call_seq_stop(struct seq_file *seq, void *v) | |
48 | { | |
2baec2c3 DH |
49 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
50 | ||
51 | read_unlock(&rxnet->call_lock); | |
8d94aa38 | 52 | rcu_read_unlock(); |
17926a79 DH |
53 | } |
54 | ||
55 | static int rxrpc_call_seq_show(struct seq_file *seq, void *v) | |
56 | { | |
df5d8bf7 DH |
57 | struct rxrpc_local *local; |
58 | struct rxrpc_sock *rx; | |
59 | struct rxrpc_peer *peer; | |
17926a79 | 60 | struct rxrpc_call *call; |
2baec2c3 | 61 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
3e018daf | 62 | rxrpc_seq_t tx_hard_ack, rx_hard_ack; |
75b54cb5 | 63 | char lbuff[50], rbuff[50]; |
17926a79 | 64 | |
2baec2c3 | 65 | if (v == &rxnet->calls) { |
17926a79 | 66 | seq_puts(seq, |
75b54cb5 DH |
67 | "Proto Local " |
68 | " Remote " | |
17926a79 DH |
69 | " SvID ConnID CallID End Use State Abort " |
70 | " UserID\n"); | |
71 | return 0; | |
72 | } | |
73 | ||
74 | call = list_entry(v, struct rxrpc_call, link); | |
17926a79 | 75 | |
8d94aa38 | 76 | rx = rcu_dereference(call->socket); |
df5d8bf7 DH |
77 | if (rx) { |
78 | local = READ_ONCE(rx->local); | |
79 | if (local) | |
75b54cb5 | 80 | sprintf(lbuff, "%pISpc", &local->srx.transport); |
df5d8bf7 DH |
81 | else |
82 | strcpy(lbuff, "no_local"); | |
83 | } else { | |
84 | strcpy(lbuff, "no_socket"); | |
85 | } | |
17926a79 | 86 | |
df5d8bf7 DH |
87 | peer = call->peer; |
88 | if (peer) | |
75b54cb5 | 89 | sprintf(rbuff, "%pISpc", &peer->srx.transport); |
f4e7da8c DH |
90 | else |
91 | strcpy(rbuff, "no_connection"); | |
17926a79 | 92 | |
3e018daf DH |
93 | tx_hard_ack = READ_ONCE(call->tx_hard_ack); |
94 | rx_hard_ack = READ_ONCE(call->rx_hard_ack); | |
17926a79 | 95 | seq_printf(seq, |
75b54cb5 | 96 | "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u" |
3e018daf | 97 | " %-8.8s %08x %lx %08x %02x %08x %02x\n", |
17926a79 DH |
98 | lbuff, |
99 | rbuff, | |
f4e7da8c | 100 | call->service_id, |
0d12f8a4 DH |
101 | call->cid, |
102 | call->call_id, | |
dabe5a79 | 103 | rxrpc_is_service_call(call) ? "Svc" : "Clt", |
17926a79 DH |
104 | atomic_read(&call->usage), |
105 | rxrpc_call_states[call->state], | |
f5c17aae | 106 | call->abort_code, |
3e018daf DH |
107 | call->user_call_ID, |
108 | tx_hard_ack, READ_ONCE(call->tx_top) - tx_hard_ack, | |
109 | rx_hard_ack, READ_ONCE(call->rx_top) - rx_hard_ack); | |
17926a79 DH |
110 | |
111 | return 0; | |
112 | } | |
113 | ||
56b3d975 | 114 | static const struct seq_operations rxrpc_call_seq_ops = { |
17926a79 DH |
115 | .start = rxrpc_call_seq_start, |
116 | .next = rxrpc_call_seq_next, | |
117 | .stop = rxrpc_call_seq_stop, | |
118 | .show = rxrpc_call_seq_show, | |
119 | }; | |
120 | ||
121 | static int rxrpc_call_seq_open(struct inode *inode, struct file *file) | |
122 | { | |
2baec2c3 DH |
123 | return seq_open_net(inode, file, &rxrpc_call_seq_ops, |
124 | sizeof(struct seq_net_private)); | |
17926a79 DH |
125 | } |
126 | ||
036c2e27 | 127 | const struct file_operations rxrpc_call_seq_fops = { |
17926a79 DH |
128 | .owner = THIS_MODULE, |
129 | .open = rxrpc_call_seq_open, | |
130 | .read = seq_read, | |
131 | .llseek = seq_lseek, | |
665bba10 | 132 | .release = seq_release, |
17926a79 DH |
133 | }; |
134 | ||
135 | /* | |
136 | * generate a list of extant virtual connections in /proc/net/rxrpc_conns | |
137 | */ | |
138 | static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos) | |
139 | { | |
2baec2c3 DH |
140 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
141 | ||
142 | read_lock(&rxnet->conn_lock); | |
143 | return seq_list_start_head(&rxnet->conn_proc_list, *_pos); | |
17926a79 DH |
144 | } |
145 | ||
146 | static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v, | |
147 | loff_t *pos) | |
148 | { | |
2baec2c3 DH |
149 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
150 | ||
151 | return seq_list_next(v, &rxnet->conn_proc_list, pos); | |
17926a79 DH |
152 | } |
153 | ||
154 | static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v) | |
155 | { | |
2baec2c3 DH |
156 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
157 | ||
158 | read_unlock(&rxnet->conn_lock); | |
17926a79 DH |
159 | } |
160 | ||
161 | static int rxrpc_connection_seq_show(struct seq_file *seq, void *v) | |
162 | { | |
163 | struct rxrpc_connection *conn; | |
2baec2c3 | 164 | struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq)); |
75b54cb5 | 165 | char lbuff[50], rbuff[50]; |
17926a79 | 166 | |
2baec2c3 | 167 | if (v == &rxnet->conn_proc_list) { |
17926a79 | 168 | seq_puts(seq, |
75b54cb5 DH |
169 | "Proto Local " |
170 | " Remote " | |
a1399f8b | 171 | " SvID ConnID End Use State Key " |
17926a79 DH |
172 | " Serial ISerial\n" |
173 | ); | |
174 | return 0; | |
175 | } | |
176 | ||
4d028b2c | 177 | conn = list_entry(v, struct rxrpc_connection, proc_link); |
00e90712 DH |
178 | if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) { |
179 | strcpy(lbuff, "no_local"); | |
180 | strcpy(rbuff, "no_connection"); | |
181 | goto print; | |
182 | } | |
17926a79 | 183 | |
75b54cb5 | 184 | sprintf(lbuff, "%pISpc", &conn->params.local->srx.transport); |
17926a79 | 185 | |
75b54cb5 | 186 | sprintf(rbuff, "%pISpc", &conn->params.peer->srx.transport); |
00e90712 | 187 | print: |
17926a79 | 188 | seq_printf(seq, |
75b54cb5 | 189 | "UDP %-47.47s %-47.47s %4x %08x %s %3u" |
17926a79 DH |
190 | " %s %08x %08x %08x\n", |
191 | lbuff, | |
192 | rbuff, | |
68d6d1ae | 193 | conn->service_id, |
19ffa01c | 194 | conn->proto.cid, |
19ffa01c | 195 | rxrpc_conn_is_service(conn) ? "Svc" : "Clt", |
17926a79 DH |
196 | atomic_read(&conn->usage), |
197 | rxrpc_conn_states[conn->state], | |
19ffa01c | 198 | key_serial(conn->params.key), |
17926a79 | 199 | atomic_read(&conn->serial), |
563ea7d5 | 200 | conn->hi_serial); |
17926a79 DH |
201 | |
202 | return 0; | |
203 | } | |
204 | ||
56b3d975 | 205 | static const struct seq_operations rxrpc_connection_seq_ops = { |
17926a79 DH |
206 | .start = rxrpc_connection_seq_start, |
207 | .next = rxrpc_connection_seq_next, | |
208 | .stop = rxrpc_connection_seq_stop, | |
209 | .show = rxrpc_connection_seq_show, | |
210 | }; | |
211 | ||
212 | ||
213 | static int rxrpc_connection_seq_open(struct inode *inode, struct file *file) | |
214 | { | |
2baec2c3 DH |
215 | return seq_open_net(inode, file, &rxrpc_connection_seq_ops, |
216 | sizeof(struct seq_net_private)); | |
17926a79 DH |
217 | } |
218 | ||
036c2e27 | 219 | const struct file_operations rxrpc_connection_seq_fops = { |
17926a79 DH |
220 | .owner = THIS_MODULE, |
221 | .open = rxrpc_connection_seq_open, | |
222 | .read = seq_read, | |
223 | .llseek = seq_lseek, | |
665bba10 | 224 | .release = seq_release, |
17926a79 | 225 | }; |