Blame view

net/rxrpc/proc.c 5.97 KB
17926a793   David Howells   [AF_RXRPC]: Provi...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
  /* /proc/net/ support for AF_RXRPC
   *
   * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved.
   * Written by David Howells (dhowells@redhat.com)
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version
   * 2 of the License, or (at your option) any later version.
   */
  
  #include <linux/module.h>
  #include <net/sock.h>
  #include <net/af_rxrpc.h>
  #include "ar-internal.h"
bba304db3   David Howells   rxrpc: Turn conne...
16
17
18
  static const char *const rxrpc_conn_states[RXRPC_CONN__NR_STATES] = {
  	[RXRPC_CONN_UNUSED]			= "Unused  ",
  	[RXRPC_CONN_CLIENT]			= "Client  ",
00e907127   David Howells   rxrpc: Preallocat...
19
  	[RXRPC_CONN_SERVICE_PREALLOC]		= "SvPrealc",
bba304db3   David Howells   rxrpc: Turn conne...
20
21
22
23
24
  	[RXRPC_CONN_SERVICE_UNSECURED]		= "SvUnsec ",
  	[RXRPC_CONN_SERVICE_CHALLENGING]	= "SvChall ",
  	[RXRPC_CONN_SERVICE]			= "SvSecure",
  	[RXRPC_CONN_REMOTELY_ABORTED]		= "RmtAbort",
  	[RXRPC_CONN_LOCALLY_ABORTED]		= "LocAbort",
17926a793   David Howells   [AF_RXRPC]: Provi...
25
  };
17926a793   David Howells   [AF_RXRPC]: Provi...
26
27
28
29
30
  /*
   * generate a list of extant and dead calls in /proc/net/rxrpc_calls
   */
  static void *rxrpc_call_seq_start(struct seq_file *seq, loff_t *_pos)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
31
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
8d94aa381   David Howells   rxrpc: Calls shou...
32
  	rcu_read_lock();
2baec2c3f   David Howells   rxrpc: Support ne...
33
34
  	read_lock(&rxnet->call_lock);
  	return seq_list_start_head(&rxnet->calls, *_pos);
17926a793   David Howells   [AF_RXRPC]: Provi...
35
36
37
38
  }
  
  static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
39
40
41
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
  
  	return seq_list_next(v, &rxnet->calls, pos);
17926a793   David Howells   [AF_RXRPC]: Provi...
42
43
44
45
  }
  
  static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
46
47
48
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
  
  	read_unlock(&rxnet->call_lock);
8d94aa381   David Howells   rxrpc: Calls shou...
49
  	rcu_read_unlock();
17926a793   David Howells   [AF_RXRPC]: Provi...
50
51
52
53
  }
  
  static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
  {
df5d8bf70   David Howells   rxrpc: Make /proc...
54
55
56
  	struct rxrpc_local *local;
  	struct rxrpc_sock *rx;
  	struct rxrpc_peer *peer;
17926a793   David Howells   [AF_RXRPC]: Provi...
57
  	struct rxrpc_call *call;
2baec2c3f   David Howells   rxrpc: Support ne...
58
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
3e018daf0   David Howells   rxrpc: Show a cal...
59
  	rxrpc_seq_t tx_hard_ack, rx_hard_ack;
75b54cb57   David Howells   rxrpc: Add IPv6 s...
60
  	char lbuff[50], rbuff[50];
17926a793   David Howells   [AF_RXRPC]: Provi...
61

2baec2c3f   David Howells   rxrpc: Support ne...
62
  	if (v == &rxnet->calls) {
17926a793   David Howells   [AF_RXRPC]: Provi...
63
  		seq_puts(seq,
75b54cb57   David Howells   rxrpc: Add IPv6 s...
64
65
  			 "Proto Local                                          "
  			 " Remote                                         "
17926a793   David Howells   [AF_RXRPC]: Provi...
66
67
68
69
70
71
72
  			 " SvID ConnID   CallID   End Use State    Abort   "
  			 " UserID
  ");
  		return 0;
  	}
  
  	call = list_entry(v, struct rxrpc_call, link);
17926a793   David Howells   [AF_RXRPC]: Provi...
73

8d94aa381   David Howells   rxrpc: Calls shou...
74
  	rx = rcu_dereference(call->socket);
df5d8bf70   David Howells   rxrpc: Make /proc...
75
76
77
  	if (rx) {
  		local = READ_ONCE(rx->local);
  		if (local)
75b54cb57   David Howells   rxrpc: Add IPv6 s...
78
  			sprintf(lbuff, "%pISpc", &local->srx.transport);
df5d8bf70   David Howells   rxrpc: Make /proc...
79
80
81
82
83
  		else
  			strcpy(lbuff, "no_local");
  	} else {
  		strcpy(lbuff, "no_socket");
  	}
17926a793   David Howells   [AF_RXRPC]: Provi...
84

df5d8bf70   David Howells   rxrpc: Make /proc...
85
86
  	peer = call->peer;
  	if (peer)
75b54cb57   David Howells   rxrpc: Add IPv6 s...
87
  		sprintf(rbuff, "%pISpc", &peer->srx.transport);
f4e7da8cd   David Howells   rxrpc: Calls disp...
88
89
  	else
  		strcpy(rbuff, "no_connection");
17926a793   David Howells   [AF_RXRPC]: Provi...
90

3e018daf0   David Howells   rxrpc: Show a cal...
91
92
  	tx_hard_ack = READ_ONCE(call->tx_hard_ack);
  	rx_hard_ack = READ_ONCE(call->rx_hard_ack);
17926a793   David Howells   [AF_RXRPC]: Provi...
93
  	seq_printf(seq,
75b54cb57   David Howells   rxrpc: Add IPv6 s...
94
  		   "UDP   %-47.47s %-47.47s %4x %08x %08x %s %3u"
3e018daf0   David Howells   rxrpc: Show a cal...
95
96
  		   " %-8.8s %08x %lx %08x %02x %08x %02x
  ",
17926a793   David Howells   [AF_RXRPC]: Provi...
97
98
  		   lbuff,
  		   rbuff,
f4e7da8cd   David Howells   rxrpc: Calls disp...
99
  		   call->service_id,
0d12f8a40   David Howells   rxrpc: Keep the s...
100
101
  		   call->cid,
  		   call->call_id,
dabe5a790   David Howells   rxrpc: Tidy up th...
102
  		   rxrpc_is_service_call(call) ? "Svc" : "Clt",
17926a793   David Howells   [AF_RXRPC]: Provi...
103
104
  		   atomic_read(&call->usage),
  		   rxrpc_call_states[call->state],
f5c17aaeb   David Howells   rxrpc: Calls shou...
105
  		   call->abort_code,
3e018daf0   David Howells   rxrpc: Show a cal...
106
107
108
  		   call->user_call_ID,
  		   tx_hard_ack, READ_ONCE(call->tx_top) - tx_hard_ack,
  		   rx_hard_ack, READ_ONCE(call->rx_top) - rx_hard_ack);
17926a793   David Howells   [AF_RXRPC]: Provi...
109
110
111
  
  	return 0;
  }
56b3d975b   Philippe De Muyter   [NET]: Make all i...
112
  static const struct seq_operations rxrpc_call_seq_ops = {
17926a793   David Howells   [AF_RXRPC]: Provi...
113
114
115
116
117
118
119
120
  	.start  = rxrpc_call_seq_start,
  	.next   = rxrpc_call_seq_next,
  	.stop   = rxrpc_call_seq_stop,
  	.show   = rxrpc_call_seq_show,
  };
  
  static int rxrpc_call_seq_open(struct inode *inode, struct file *file)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
121
122
  	return seq_open_net(inode, file, &rxrpc_call_seq_ops,
  			    sizeof(struct seq_net_private));
17926a793   David Howells   [AF_RXRPC]: Provi...
123
  }
036c2e27b   Jan Engelhardt   [AF_RXRPC]: const...
124
  const struct file_operations rxrpc_call_seq_fops = {
17926a793   David Howells   [AF_RXRPC]: Provi...
125
126
127
128
  	.owner		= THIS_MODULE,
  	.open		= rxrpc_call_seq_open,
  	.read		= seq_read,
  	.llseek		= seq_lseek,
665bba108   Pavel Emelyanov   [NETFILTER/RXRPC]...
129
  	.release	= seq_release,
17926a793   David Howells   [AF_RXRPC]: Provi...
130
131
132
133
134
135
136
  };
  
  /*
   * generate a list of extant virtual connections in /proc/net/rxrpc_conns
   */
  static void *rxrpc_connection_seq_start(struct seq_file *seq, loff_t *_pos)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
137
138
139
140
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
  
  	read_lock(&rxnet->conn_lock);
  	return seq_list_start_head(&rxnet->conn_proc_list, *_pos);
17926a793   David Howells   [AF_RXRPC]: Provi...
141
142
143
144
145
  }
  
  static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
  				       loff_t *pos)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
146
147
148
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
  
  	return seq_list_next(v, &rxnet->conn_proc_list, pos);
17926a793   David Howells   [AF_RXRPC]: Provi...
149
150
151
152
  }
  
  static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
153
154
155
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
  
  	read_unlock(&rxnet->conn_lock);
17926a793   David Howells   [AF_RXRPC]: Provi...
156
157
158
159
160
  }
  
  static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
  {
  	struct rxrpc_connection *conn;
2baec2c3f   David Howells   rxrpc: Support ne...
161
  	struct rxrpc_net *rxnet = rxrpc_net(seq_file_net(seq));
75b54cb57   David Howells   rxrpc: Add IPv6 s...
162
  	char lbuff[50], rbuff[50];
17926a793   David Howells   [AF_RXRPC]: Provi...
163

2baec2c3f   David Howells   rxrpc: Support ne...
164
  	if (v == &rxnet->conn_proc_list) {
17926a793   David Howells   [AF_RXRPC]: Provi...
165
  		seq_puts(seq,
75b54cb57   David Howells   rxrpc: Add IPv6 s...
166
167
  			 "Proto Local                                          "
  			 " Remote                                         "
a1399f8bb   David Howells   rxrpc: Call chann...
168
  			 " SvID ConnID   End Use State    Key     "
17926a793   David Howells   [AF_RXRPC]: Provi...
169
170
171
172
173
  			 " Serial   ISerial
  "
  			 );
  		return 0;
  	}
4d028b2c8   David Howells   rxrpc: Dup the ma...
174
  	conn = list_entry(v, struct rxrpc_connection, proc_link);
00e907127   David Howells   rxrpc: Preallocat...
175
176
177
178
179
  	if (conn->state == RXRPC_CONN_SERVICE_PREALLOC) {
  		strcpy(lbuff, "no_local");
  		strcpy(rbuff, "no_connection");
  		goto print;
  	}
17926a793   David Howells   [AF_RXRPC]: Provi...
180

75b54cb57   David Howells   rxrpc: Add IPv6 s...
181
  	sprintf(lbuff, "%pISpc", &conn->params.local->srx.transport);
17926a793   David Howells   [AF_RXRPC]: Provi...
182

75b54cb57   David Howells   rxrpc: Add IPv6 s...
183
  	sprintf(rbuff, "%pISpc", &conn->params.peer->srx.transport);
00e907127   David Howells   rxrpc: Preallocat...
184
  print:
17926a793   David Howells   [AF_RXRPC]: Provi...
185
  	seq_printf(seq,
75b54cb57   David Howells   rxrpc: Add IPv6 s...
186
  		   "UDP   %-47.47s %-47.47s %4x %08x %s %3u"
17926a793   David Howells   [AF_RXRPC]: Provi...
187
188
189
190
  		   " %s %08x %08x %08x
  ",
  		   lbuff,
  		   rbuff,
68d6d1ae5   David Howells   rxrpc: Separate t...
191
  		   conn->service_id,
19ffa01c9   David Howells   rxrpc: Use struct...
192
  		   conn->proto.cid,
19ffa01c9   David Howells   rxrpc: Use struct...
193
  		   rxrpc_conn_is_service(conn) ? "Svc" : "Clt",
17926a793   David Howells   [AF_RXRPC]: Provi...
194
195
  		   atomic_read(&conn->usage),
  		   rxrpc_conn_states[conn->state],
19ffa01c9   David Howells   rxrpc: Use struct...
196
  		   key_serial(conn->params.key),
17926a793   David Howells   [AF_RXRPC]: Provi...
197
  		   atomic_read(&conn->serial),
563ea7d5d   David Howells   rxrpc: Calculate ...
198
  		   conn->hi_serial);
17926a793   David Howells   [AF_RXRPC]: Provi...
199
200
201
  
  	return 0;
  }
56b3d975b   Philippe De Muyter   [NET]: Make all i...
202
  static const struct seq_operations rxrpc_connection_seq_ops = {
17926a793   David Howells   [AF_RXRPC]: Provi...
203
204
205
206
207
208
209
210
211
  	.start  = rxrpc_connection_seq_start,
  	.next   = rxrpc_connection_seq_next,
  	.stop   = rxrpc_connection_seq_stop,
  	.show   = rxrpc_connection_seq_show,
  };
  
  
  static int rxrpc_connection_seq_open(struct inode *inode, struct file *file)
  {
2baec2c3f   David Howells   rxrpc: Support ne...
212
213
  	return seq_open_net(inode, file, &rxrpc_connection_seq_ops,
  			    sizeof(struct seq_net_private));
17926a793   David Howells   [AF_RXRPC]: Provi...
214
  }
036c2e27b   Jan Engelhardt   [AF_RXRPC]: const...
215
  const struct file_operations rxrpc_connection_seq_fops = {
17926a793   David Howells   [AF_RXRPC]: Provi...
216
217
218
219
  	.owner		= THIS_MODULE,
  	.open		= rxrpc_connection_seq_open,
  	.read		= seq_read,
  	.llseek		= seq_lseek,
665bba108   Pavel Emelyanov   [NETFILTER/RXRPC]...
220
  	.release	= seq_release,
17926a793   David Howells   [AF_RXRPC]: Provi...
221
  };