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 rxrpc_seq_t tx_hard_ack
, rx_hard_ack
;
56 char lbuff
[50], rbuff
[50];
58 if (v
== &rxrpc_calls
) {
62 " SvID ConnID CallID End Use State Abort "
67 call
= list_entry(v
, struct rxrpc_call
, link
);
69 rx
= rcu_dereference(call
->socket
);
71 local
= READ_ONCE(rx
->local
);
73 sprintf(lbuff
, "%pISpc", &local
->srx
.transport
);
75 strcpy(lbuff
, "no_local");
77 strcpy(lbuff
, "no_socket");
82 sprintf(rbuff
, "%pISpc", &peer
->srx
.transport
);
84 strcpy(rbuff
, "no_connection");
86 tx_hard_ack
= READ_ONCE(call
->tx_hard_ack
);
87 rx_hard_ack
= READ_ONCE(call
->rx_hard_ack
);
89 "UDP %-47.47s %-47.47s %4x %08x %08x %s %3u"
90 " %-8.8s %08x %lx %08x %02x %08x %02x\n",
96 rxrpc_is_service_call(call
) ? "Svc" : "Clt",
97 atomic_read(&call
->usage
),
98 rxrpc_call_states
[call
->state
],
101 tx_hard_ack
, READ_ONCE(call
->tx_top
) - tx_hard_ack
,
102 rx_hard_ack
, READ_ONCE(call
->rx_top
) - rx_hard_ack
);
107 static const struct seq_operations rxrpc_call_seq_ops
= {
108 .start
= rxrpc_call_seq_start
,
109 .next
= rxrpc_call_seq_next
,
110 .stop
= rxrpc_call_seq_stop
,
111 .show
= rxrpc_call_seq_show
,
114 static int rxrpc_call_seq_open(struct inode
*inode
, struct file
*file
)
116 return seq_open(file
, &rxrpc_call_seq_ops
);
119 const struct file_operations rxrpc_call_seq_fops
= {
120 .owner
= THIS_MODULE
,
121 .open
= rxrpc_call_seq_open
,
124 .release
= seq_release
,
128 * generate a list of extant virtual connections in /proc/net/rxrpc_conns
130 static void *rxrpc_connection_seq_start(struct seq_file
*seq
, loff_t
*_pos
)
132 read_lock(&rxrpc_connection_lock
);
133 return seq_list_start_head(&rxrpc_connection_proc_list
, *_pos
);
136 static void *rxrpc_connection_seq_next(struct seq_file
*seq
, void *v
,
139 return seq_list_next(v
, &rxrpc_connection_proc_list
, pos
);
142 static void rxrpc_connection_seq_stop(struct seq_file
*seq
, void *v
)
144 read_unlock(&rxrpc_connection_lock
);
147 static int rxrpc_connection_seq_show(struct seq_file
*seq
, void *v
)
149 struct rxrpc_connection
*conn
;
150 char lbuff
[50], rbuff
[50];
152 if (v
== &rxrpc_connection_proc_list
) {
156 " SvID ConnID End Use State Key "
162 conn
= list_entry(v
, struct rxrpc_connection
, proc_link
);
163 if (conn
->state
== RXRPC_CONN_SERVICE_PREALLOC
) {
164 strcpy(lbuff
, "no_local");
165 strcpy(rbuff
, "no_connection");
169 sprintf(lbuff
, "%pISpc", &conn
->params
.local
->srx
.transport
);
171 sprintf(rbuff
, "%pISpc", &conn
->params
.peer
->srx
.transport
);
174 "UDP %-47.47s %-47.47s %4x %08x %s %3u"
175 " %s %08x %08x %08x\n",
178 conn
->params
.service_id
,
180 rxrpc_conn_is_service(conn
) ? "Svc" : "Clt",
181 atomic_read(&conn
->usage
),
182 rxrpc_conn_states
[conn
->state
],
183 key_serial(conn
->params
.key
),
184 atomic_read(&conn
->serial
),
190 static const struct seq_operations rxrpc_connection_seq_ops
= {
191 .start
= rxrpc_connection_seq_start
,
192 .next
= rxrpc_connection_seq_next
,
193 .stop
= rxrpc_connection_seq_stop
,
194 .show
= rxrpc_connection_seq_show
,
198 static int rxrpc_connection_seq_open(struct inode
*inode
, struct file
*file
)
200 return seq_open(file
, &rxrpc_connection_seq_ops
);
203 const struct file_operations rxrpc_connection_seq_fops
= {
204 .owner
= THIS_MODULE
,
205 .open
= rxrpc_connection_seq_open
,
208 .release
= seq_release
,