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