xref: /openbmc/linux/net/rxrpc/proc.c (revision 33912c26)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
28c3e34a4SDavid Howells /* /proc/net/ support for AF_RXRPC
38c3e34a4SDavid Howells  *
48c3e34a4SDavid Howells  * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
58c3e34a4SDavid Howells  * Written by David Howells (dhowells@redhat.com)
68c3e34a4SDavid Howells  */
78c3e34a4SDavid Howells 
88c3e34a4SDavid Howells #include <linux/module.h>
98c3e34a4SDavid Howells #include <net/sock.h>
108c3e34a4SDavid Howells #include <net/af_rxrpc.h>
118c3e34a4SDavid Howells #include "ar-internal.h"
128c3e34a4SDavid Howells 
13bba304dbSDavid Howells static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = {
148c3e34a4SDavid Howells 	[RXRPC_CONN_UNUSED]			= "Unused  ",
158c3e34a4SDavid Howells 	[RXRPC_CONN_CLIENT]			= "Client  ",
1600e90712SDavid Howells 	[RXRPC_CONN_SERVICE_PREALLOC]		= "SvPrealc",
17bba304dbSDavid Howells 	[RXRPC_CONN_SERVICE_UNSECURED]		= "SvUnsec ",
18bba304dbSDavid Howells 	[RXRPC_CONN_SERVICE_CHALLENGING]	= "SvChall ",
19bba304dbSDavid Howells 	[RXRPC_CONN_SERVICE]			= "SvSecure",
208c3e34a4SDavid Howells 	[RXRPC_CONN_REMOTELY_ABORTED]		= "RmtAbort",
218c3e34a4SDavid Howells 	[RXRPC_CONN_LOCALLY_ABORTED]		= "LocAbort",
228c3e34a4SDavid Howells };
238c3e34a4SDavid Howells 
248c3e34a4SDavid Howells /*
258c3e34a4SDavid Howells  * generate a list of extant and dead calls in /proc/net/rxrpc_calls
268c3e34a4SDavid Howells  */
278c3e34a4SDavid Howells static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
2888f2a825SDavid Howells 	__acquires(rcu)
2988f2a825SDavid Howells 	__acquires(rxnet->call_lock)
308c3e34a4SDavid Howells {
312baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
322baec2c3SDavid Howells 
338d94aa38SDavid Howells 	rcu_read_lock();
342baec2c3SDavid Howells 	read_lock(&rxnet->call_lock);
352baec2c3SDavid Howells 	return seq_list_start_head(&rxnet->calls, *_pos);
368c3e34a4SDavid Howells }
378c3e34a4SDavid Howells 
388c3e34a4SDavid Howells static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
398c3e34a4SDavid Howells {
402baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
412baec2c3SDavid Howells 
422baec2c3SDavid Howells 	return seq_list_next(v, &rxnet->calls, pos);
438c3e34a4SDavid Howells }
448c3e34a4SDavid Howells 
458c3e34a4SDavid Howells static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
4688f2a825SDavid Howells 	__releases(rxnet->call_lock)
4788f2a825SDavid Howells 	__releases(rcu)
488c3e34a4SDavid Howells {
492baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
502baec2c3SDavid Howells 
512baec2c3SDavid Howells 	read_unlock(&rxnet->call_lock);
528d94aa38SDavid Howells 	rcu_read_unlock();
538c3e34a4SDavid Howells }
548c3e34a4SDavid Howells 
558c3e34a4SDavid Howells static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
568c3e34a4SDavid Howells {
57df5d8bf7SDavid Howells 	struct rxrpc_local *local;
58df5d8bf7SDavid Howells 	struct rxrpc_sock *rx;
59df5d8bf7SDavid Howells 	struct rxrpc_peer *peer;
608c3e34a4SDavid Howells 	struct rxrpc_call *call;
612baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
62770b26deSWei Yongjun 	unsigned long timeout = 0;
633e018dafSDavid Howells 	rxrpc_seq_t tx_hard_ack, rx_hard_ack;
6475b54cb5SDavid Howells 	char lbuff[50], rbuff[50];
658c3e34a4SDavid Howells 
662baec2c3SDavid Howells 	if (v == &rxnet->calls) {
678c3e34a4SDavid Howells 		seq_puts(seq,
6875b54cb5SDavid Howells 			 "Proto Local                                          "
6975b54cb5SDavid Howells 			 " Remote                                         "
708c3e34a4SDavid Howells 			 " SvID ConnID   CallID   End Use State    Abort   "
7132f71aa4SDavid Howells 			 " DebugId  TxSeq    TW RxSeq    RW RxSerial RxTimo\n");
728c3e34a4SDavid Howells 		return 0;
738c3e34a4SDavid Howells 	}
748c3e34a4SDavid Howells 
758c3e34a4SDavid Howells 	call = list_entry(v, struct rxrpc_call, link);
768c3e34a4SDavid Howells 
778d94aa38SDavid Howells 	rx = rcu_dereference(call->socket);
78df5d8bf7SDavid Howells 	if (rx) {
79df5d8bf7SDavid Howells 		local = READ_ONCE(rx->local);
80df5d8bf7SDavid Howells 		if (local)
8175b54cb5SDavid Howells 			sprintf(lbuff, "%pISpc", &local->srx.transport);
82df5d8bf7SDavid Howells 		else
83df5d8bf7SDavid Howells 			strcpy(lbuff, "no_local");
84df5d8bf7SDavid Howells 	} else {
85df5d8bf7SDavid Howells 		strcpy(lbuff, "no_socket");
86df5d8bf7SDavid Howells 	}
878c3e34a4SDavid Howells 
88df5d8bf7SDavid Howells 	peer = call->peer;
89df5d8bf7SDavid Howells 	if (peer)
9075b54cb5SDavid Howells 		sprintf(rbuff, "%pISpc", &peer->srx.transport);
91f4e7da8cSDavid Howells 	else
92f4e7da8cSDavid Howells 		strcpy(rbuff, "no_connection");
938c3e34a4SDavid Howells 
94887763bbSDavid Howells 	if (call->state != RXRPC_CALL_SERVER_PREALLOC) {
95887763bbSDavid Howells 		timeout = READ_ONCE(call->expect_rx_by);
96887763bbSDavid Howells 		timeout -= jiffies;
97887763bbSDavid Howells 	}
98887763bbSDavid Howells 
993e018dafSDavid Howells 	tx_hard_ack = READ_ONCE(call->tx_hard_ack);
1003e018dafSDavid Howells 	rx_hard_ack = READ_ONCE(call->rx_hard_ack);
1018c3e34a4SDavid Howells 	seq_printf(seq,
10275b54cb5SDavid Howells 		   "UDP   %-47.47s %-47.47s %4x %08x %08x %s %3u"
10332f71aa4SDavid Howells 		   " %-8.8s %08x %08x %08x %02x %08x %02x %08x %06lx\n",
1048c3e34a4SDavid Howells 		   lbuff,
1058c3e34a4SDavid Howells 		   rbuff,
106f4e7da8cSDavid Howells 		   call->service_id,
1078c3e34a4SDavid Howells 		   call->cid,
1088c3e34a4SDavid Howells 		   call->call_id,
109dabe5a79SDavid Howells 		   rxrpc_is_service_call(call) ? "Svc" : "Clt",
1108c3e34a4SDavid Howells 		   atomic_read(&call->usage),
1118c3e34a4SDavid Howells 		   rxrpc_call_states[call->state],
112f5c17aaeSDavid Howells 		   call->abort_code,
11332f71aa4SDavid Howells 		   call->debug_id,
1143e018dafSDavid Howells 		   tx_hard_ack, READ_ONCE(call->tx_top) - tx_hard_ack,
115887763bbSDavid Howells 		   rx_hard_ack, READ_ONCE(call->rx_top) - rx_hard_ack,
1166b97bd7aSDavid Howells 		   call->rx_serial,
117887763bbSDavid Howells 		   timeout);
1188c3e34a4SDavid Howells 
1198c3e34a4SDavid Howells 	return 0;
1208c3e34a4SDavid Howells }
1218c3e34a4SDavid Howells 
122c3506372SChristoph Hellwig const struct seq_operations rxrpc_call_seq_ops = {
1238c3e34a4SDavid Howells 	.start  = rxrpc_call_seq_start,
1248c3e34a4SDavid Howells 	.next   = rxrpc_call_seq_next,
1258c3e34a4SDavid Howells 	.stop   = rxrpc_call_seq_stop,
1268c3e34a4SDavid Howells 	.show   = rxrpc_call_seq_show,
1278c3e34a4SDavid Howells };
1288c3e34a4SDavid Howells 
1298c3e34a4SDavid Howells /*
1308c3e34a4SDavid Howells  * generate a list of extant virtual connections in /proc/net/rxrpc_conns
1318c3e34a4SDavid Howells  */
1328c3e34a4SDavid Howells static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
13388f2a825SDavid Howells 	__acquires(rxnet->conn_lock)
1348c3e34a4SDavid Howells {
1352baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
1362baec2c3SDavid Howells 
1372baec2c3SDavid Howells 	read_lock(&rxnet->conn_lock);
1382baec2c3SDavid Howells 	return seq_list_start_head(&rxnet->conn_proc_list, *_pos);
1398c3e34a4SDavid Howells }
1408c3e34a4SDavid Howells 
1418c3e34a4SDavid Howells static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
1428c3e34a4SDavid Howells 				       loff_t *pos)
1438c3e34a4SDavid Howells {
1442baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
1452baec2c3SDavid Howells 
1462baec2c3SDavid Howells 	return seq_list_next(v, &rxnet->conn_proc_list, pos);
1478c3e34a4SDavid Howells }
1488c3e34a4SDavid Howells 
1498c3e34a4SDavid Howells static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
15088f2a825SDavid Howells 	__releases(rxnet->conn_lock)
1518c3e34a4SDavid Howells {
1522baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
1532baec2c3SDavid Howells 
1542baec2c3SDavid Howells 	read_unlock(&rxnet->conn_lock);
1558c3e34a4SDavid Howells }
1568c3e34a4SDavid Howells 
1578c3e34a4SDavid Howells static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
1588c3e34a4SDavid Howells {
1598c3e34a4SDavid Howells 	struct rxrpc_connection *conn;
1602baec2c3SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
16175b54cb5SDavid Howells 	char lbuff[50], rbuff[50];
1628c3e34a4SDavid Howells 
1632baec2c3SDavid Howells 	if (v == &rxnet->conn_proc_list) {
1648c3e34a4SDavid Howells 		seq_puts(seq,
16575b54cb5SDavid Howells 			 "Proto Local                                          "
16675b54cb5SDavid Howells 			 " Remote                                         "
167a1399f8bSDavid Howells 			 " SvID ConnID   End Use State    Key     "
168245500d8SDavid Howells 			 " Serial   ISerial  CallId0  CallId1  CallId2  CallId3\n"
1698c3e34a4SDavid Howells 			 );
1708c3e34a4SDavid Howells 		return 0;
1718c3e34a4SDavid Howells 	}
1728c3e34a4SDavid Howells 
1734d028b2cSDavid Howells 	conn = list_entry(v, struct rxrpc_connection, proc_link);
17400e90712SDavid Howells 	if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) {
17500e90712SDavid Howells 		strcpy(lbuff, "no_local");
17600e90712SDavid Howells 		strcpy(rbuff, "no_connection");
17700e90712SDavid Howells 		goto print;
17800e90712SDavid Howells 	}
1798c3e34a4SDavid Howells 
18075b54cb5SDavid Howells 	sprintf(lbuff, "%pISpc", &conn->params.local->srx.transport);
1818c3e34a4SDavid Howells 
18275b54cb5SDavid Howells 	sprintf(rbuff, "%pISpc", &conn->params.peer->srx.transport);
18300e90712SDavid Howells print:
1848c3e34a4SDavid Howells 	seq_printf(seq,
18575b54cb5SDavid Howells 		   "UDP   %-47.47s %-47.47s %4x %08x %s %3u"
1866b97bd7aSDavid Howells 		   " %s %08x %08x %08x %08x %08x %08x %08x\n",
1878c3e34a4SDavid Howells 		   lbuff,
1888c3e34a4SDavid Howells 		   rbuff,
18968d6d1aeSDavid Howells 		   conn->service_id,
19019ffa01cSDavid Howells 		   conn->proto.cid,
19119ffa01cSDavid Howells 		   rxrpc_conn_is_service(conn) ? "Svc" : "Clt",
1928c3e34a4SDavid Howells 		   atomic_read(&conn->usage),
1938c3e34a4SDavid Howells 		   rxrpc_conn_states[conn->state],
19419ffa01cSDavid Howells 		   key_serial(conn->params.key),
1958c3e34a4SDavid Howells 		   atomic_read(&conn->serial),
1966b97bd7aSDavid Howells 		   conn->hi_serial,
1976b97bd7aSDavid Howells 		   conn->channels[0].call_id,
1986b97bd7aSDavid Howells 		   conn->channels[1].call_id,
1996b97bd7aSDavid Howells 		   conn->channels[2].call_id,
2006b97bd7aSDavid Howells 		   conn->channels[3].call_id);
2018c3e34a4SDavid Howells 
2028c3e34a4SDavid Howells 	return 0;
2038c3e34a4SDavid Howells }
2048c3e34a4SDavid Howells 
205c3506372SChristoph Hellwig const struct seq_operations rxrpc_connection_seq_ops = {
2068c3e34a4SDavid Howells 	.start  = rxrpc_connection_seq_start,
2078c3e34a4SDavid Howells 	.next   = rxrpc_connection_seq_next,
2088c3e34a4SDavid Howells 	.stop   = rxrpc_connection_seq_stop,
2098c3e34a4SDavid Howells 	.show   = rxrpc_connection_seq_show,
2108c3e34a4SDavid Howells };
211bc0e7cf4SDavid Howells 
212bc0e7cf4SDavid Howells /*
213bc0e7cf4SDavid Howells  * generate a list of extant virtual peers in /proc/net/rxrpc/peers
214bc0e7cf4SDavid Howells  */
215bc0e7cf4SDavid Howells static int rxrpc_peer_seq_show(struct seq_file *seq, void *v)
216bc0e7cf4SDavid Howells {
217bc0e7cf4SDavid Howells 	struct rxrpc_peer *peer;
218bc0e7cf4SDavid Howells 	time64_t now;
219bc0e7cf4SDavid Howells 	char lbuff[50], rbuff[50];
220bc0e7cf4SDavid Howells 
221bc0e7cf4SDavid Howells 	if (v == SEQ_START_TOKEN) {
222bc0e7cf4SDavid Howells 		seq_puts(seq,
223bc0e7cf4SDavid Howells 			 "Proto Local                                          "
224bc0e7cf4SDavid Howells 			 " Remote                                         "
225c410bf01SDavid Howells 			 " Use  CW   MTU LastUse      RTT      RTO\n"
226bc0e7cf4SDavid Howells 			 );
227bc0e7cf4SDavid Howells 		return 0;
228bc0e7cf4SDavid Howells 	}
229bc0e7cf4SDavid Howells 
230bc0e7cf4SDavid Howells 	peer = list_entry(v, struct rxrpc_peer, hash_link);
231bc0e7cf4SDavid Howells 
232bc0e7cf4SDavid Howells 	sprintf(lbuff, "%pISpc", &peer->local->srx.transport);
233bc0e7cf4SDavid Howells 
234bc0e7cf4SDavid Howells 	sprintf(rbuff, "%pISpc", &peer->srx.transport);
235bc0e7cf4SDavid Howells 
236bc0e7cf4SDavid Howells 	now = ktime_get_seconds();
237bc0e7cf4SDavid Howells 	seq_printf(seq,
238bc0e7cf4SDavid Howells 		   "UDP   %-47.47s %-47.47s %3u"
239c410bf01SDavid Howells 		   " %3u %5u %6llus %8u %8u\n",
240bc0e7cf4SDavid Howells 		   lbuff,
241bc0e7cf4SDavid Howells 		   rbuff,
242bc0e7cf4SDavid Howells 		   atomic_read(&peer->usage),
243bc0e7cf4SDavid Howells 		   peer->cong_cwnd,
244bc0e7cf4SDavid Howells 		   peer->mtu,
245bc0e7cf4SDavid Howells 		   now - peer->last_tx_at,
246c410bf01SDavid Howells 		   peer->srtt_us >> 3,
247c410bf01SDavid Howells 		   jiffies_to_usecs(peer->rto_j));
248bc0e7cf4SDavid Howells 
249bc0e7cf4SDavid Howells 	return 0;
250bc0e7cf4SDavid Howells }
251bc0e7cf4SDavid Howells 
252bc0e7cf4SDavid Howells static void *rxrpc_peer_seq_start(struct seq_file *seq, loff_t *_pos)
253bc0e7cf4SDavid Howells 	__acquires(rcu)
254bc0e7cf4SDavid Howells {
255bc0e7cf4SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
256bc0e7cf4SDavid Howells 	unsigned int bucket, n;
257bc0e7cf4SDavid Howells 	unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash);
258bc0e7cf4SDavid Howells 	void *p;
259bc0e7cf4SDavid Howells 
260bc0e7cf4SDavid Howells 	rcu_read_lock();
261bc0e7cf4SDavid Howells 
262bc0e7cf4SDavid Howells 	if (*_pos >= UINT_MAX)
263bc0e7cf4SDavid Howells 		return NULL;
264bc0e7cf4SDavid Howells 
265bc0e7cf4SDavid Howells 	n = *_pos & ((1U << shift) - 1);
266bc0e7cf4SDavid Howells 	bucket = *_pos >> shift;
267bc0e7cf4SDavid Howells 	for (;;) {
268bc0e7cf4SDavid Howells 		if (bucket >= HASH_SIZE(rxnet->peer_hash)) {
269bc0e7cf4SDavid Howells 			*_pos = UINT_MAX;
270bc0e7cf4SDavid Howells 			return NULL;
271bc0e7cf4SDavid Howells 		}
272bc0e7cf4SDavid Howells 		if (n == 0) {
273bc0e7cf4SDavid Howells 			if (bucket == 0)
274bc0e7cf4SDavid Howells 				return SEQ_START_TOKEN;
275bc0e7cf4SDavid Howells 			*_pos += 1;
276bc0e7cf4SDavid Howells 			n++;
277bc0e7cf4SDavid Howells 		}
278bc0e7cf4SDavid Howells 
279bc0e7cf4SDavid Howells 		p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1);
280bc0e7cf4SDavid Howells 		if (p)
281bc0e7cf4SDavid Howells 			return p;
282bc0e7cf4SDavid Howells 		bucket++;
283bc0e7cf4SDavid Howells 		n = 1;
284bc0e7cf4SDavid Howells 		*_pos = (bucket << shift) | n;
285bc0e7cf4SDavid Howells 	}
286bc0e7cf4SDavid Howells }
287bc0e7cf4SDavid Howells 
288bc0e7cf4SDavid Howells static void *rxrpc_peer_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
289bc0e7cf4SDavid Howells {
290bc0e7cf4SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
291bc0e7cf4SDavid Howells 	unsigned int bucket, n;
292bc0e7cf4SDavid Howells 	unsigned int shift = 32 - HASH_BITS(rxnet->peer_hash);
293bc0e7cf4SDavid Howells 	void *p;
294bc0e7cf4SDavid Howells 
295bc0e7cf4SDavid Howells 	if (*_pos >= UINT_MAX)
296bc0e7cf4SDavid Howells 		return NULL;
297bc0e7cf4SDavid Howells 
298bc0e7cf4SDavid Howells 	bucket = *_pos >> shift;
299bc0e7cf4SDavid Howells 
300bc0e7cf4SDavid Howells 	p = seq_hlist_next_rcu(v, &rxnet->peer_hash[bucket], _pos);
301bc0e7cf4SDavid Howells 	if (p)
302bc0e7cf4SDavid Howells 		return p;
303bc0e7cf4SDavid Howells 
304bc0e7cf4SDavid Howells 	for (;;) {
305bc0e7cf4SDavid Howells 		bucket++;
306bc0e7cf4SDavid Howells 		n = 1;
307bc0e7cf4SDavid Howells 		*_pos = (bucket << shift) | n;
308bc0e7cf4SDavid Howells 
309bc0e7cf4SDavid Howells 		if (bucket >= HASH_SIZE(rxnet->peer_hash)) {
310bc0e7cf4SDavid Howells 			*_pos = UINT_MAX;
311bc0e7cf4SDavid Howells 			return NULL;
312bc0e7cf4SDavid Howells 		}
313bc0e7cf4SDavid Howells 		if (n == 0) {
314bc0e7cf4SDavid Howells 			*_pos += 1;
315bc0e7cf4SDavid Howells 			n++;
316bc0e7cf4SDavid Howells 		}
317bc0e7cf4SDavid Howells 
318bc0e7cf4SDavid Howells 		p = seq_hlist_start_rcu(&rxnet->peer_hash[bucket], n - 1);
319bc0e7cf4SDavid Howells 		if (p)
320bc0e7cf4SDavid Howells 			return p;
321bc0e7cf4SDavid Howells 	}
322bc0e7cf4SDavid Howells }
323bc0e7cf4SDavid Howells 
324bc0e7cf4SDavid Howells static void rxrpc_peer_seq_stop(struct seq_file *seq, void *v)
325bc0e7cf4SDavid Howells 	__releases(rcu)
326bc0e7cf4SDavid Howells {
327bc0e7cf4SDavid Howells 	rcu_read_unlock();
328bc0e7cf4SDavid Howells }
329bc0e7cf4SDavid Howells 
330bc0e7cf4SDavid Howells 
331bc0e7cf4SDavid Howells const struct seq_operations rxrpc_peer_seq_ops = {
332bc0e7cf4SDavid Howells 	.start  = rxrpc_peer_seq_start,
333bc0e7cf4SDavid Howells 	.next   = rxrpc_peer_seq_next,
334bc0e7cf4SDavid Howells 	.stop   = rxrpc_peer_seq_stop,
335bc0e7cf4SDavid Howells 	.show   = rxrpc_peer_seq_show,
336bc0e7cf4SDavid Howells };
337*33912c26SDavid Howells 
338*33912c26SDavid Howells /*
339*33912c26SDavid Howells  * Generate a list of extant virtual local endpoints in /proc/net/rxrpc/locals
340*33912c26SDavid Howells  */
341*33912c26SDavid Howells static int rxrpc_local_seq_show(struct seq_file *seq, void *v)
342*33912c26SDavid Howells {
343*33912c26SDavid Howells 	struct rxrpc_local *local;
344*33912c26SDavid Howells 	char lbuff[50];
345*33912c26SDavid Howells 
346*33912c26SDavid Howells 	if (v == SEQ_START_TOKEN) {
347*33912c26SDavid Howells 		seq_puts(seq,
348*33912c26SDavid Howells 			 "Proto Local                                          "
349*33912c26SDavid Howells 			 " Use Act\n");
350*33912c26SDavid Howells 		return 0;
351*33912c26SDavid Howells 	}
352*33912c26SDavid Howells 
353*33912c26SDavid Howells 	local = hlist_entry(v, struct rxrpc_local, link);
354*33912c26SDavid Howells 
355*33912c26SDavid Howells 	sprintf(lbuff, "%pISpc", &local->srx.transport);
356*33912c26SDavid Howells 
357*33912c26SDavid Howells 	seq_printf(seq,
358*33912c26SDavid Howells 		   "UDP   %-47.47s %3u %3u\n",
359*33912c26SDavid Howells 		   lbuff,
360*33912c26SDavid Howells 		   atomic_read(&local->usage),
361*33912c26SDavid Howells 		   atomic_read(&local->active_users));
362*33912c26SDavid Howells 
363*33912c26SDavid Howells 	return 0;
364*33912c26SDavid Howells }
365*33912c26SDavid Howells 
366*33912c26SDavid Howells static void *rxrpc_local_seq_start(struct seq_file *seq, loff_t *_pos)
367*33912c26SDavid Howells 	__acquires(rcu)
368*33912c26SDavid Howells {
369*33912c26SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
370*33912c26SDavid Howells 	unsigned int n;
371*33912c26SDavid Howells 
372*33912c26SDavid Howells 	rcu_read_lock();
373*33912c26SDavid Howells 
374*33912c26SDavid Howells 	if (*_pos >= UINT_MAX)
375*33912c26SDavid Howells 		return NULL;
376*33912c26SDavid Howells 
377*33912c26SDavid Howells 	n = *_pos;
378*33912c26SDavid Howells 	if (n == 0)
379*33912c26SDavid Howells 		return SEQ_START_TOKEN;
380*33912c26SDavid Howells 
381*33912c26SDavid Howells 	return seq_hlist_start_rcu(&rxnet->local_endpoints, n - 1);
382*33912c26SDavid Howells }
383*33912c26SDavid Howells 
384*33912c26SDavid Howells static void *rxrpc_local_seq_next(struct seq_file *seq, void *v, loff_t *_pos)
385*33912c26SDavid Howells {
386*33912c26SDavid Howells 	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
387*33912c26SDavid Howells 
388*33912c26SDavid Howells 	if (*_pos >= UINT_MAX)
389*33912c26SDavid Howells 		return NULL;
390*33912c26SDavid Howells 
391*33912c26SDavid Howells 	return seq_hlist_next_rcu(v, &rxnet->local_endpoints, _pos);
392*33912c26SDavid Howells }
393*33912c26SDavid Howells 
394*33912c26SDavid Howells static void rxrpc_local_seq_stop(struct seq_file *seq, void *v)
395*33912c26SDavid Howells 	__releases(rcu)
396*33912c26SDavid Howells {
397*33912c26SDavid Howells 	rcu_read_unlock();
398*33912c26SDavid Howells }
399*33912c26SDavid Howells 
400*33912c26SDavid Howells const struct seq_operations rxrpc_local_seq_ops = {
401*33912c26SDavid Howells 	.start  = rxrpc_local_seq_start,
402*33912c26SDavid Howells 	.next   = rxrpc_local_seq_next,
403*33912c26SDavid Howells 	.stop   = rxrpc_local_seq_stop,
404*33912c26SDavid Howells 	.show   = rxrpc_local_seq_show,
405*33912c26SDavid Howells };
406