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 *rxrpc_conn_states
[] = {
18 [RXRPC_CONN_UNUSED
] = "Unused ",
19 [RXRPC_CONN_CLIENT
] = "Client ",
20 [RXRPC_CONN_SERVER_UNSECURED
] = "SvUnsec ",
21 [RXRPC_CONN_SERVER_CHALLENGING
] = "SvChall ",
22 [RXRPC_CONN_SERVER
] = "SvSecure",
23 [RXRPC_CONN_REMOTELY_ABORTED
] = "RmtAbort",
24 [RXRPC_CONN_LOCALLY_ABORTED
] = "LocAbort",
25 [RXRPC_CONN_NETWORK_ERROR
] = "NetError",
28 const char *rxrpc_call_states
[] = {
29 [RXRPC_CALL_CLIENT_SEND_REQUEST
] = "ClSndReq",
30 [RXRPC_CALL_CLIENT_AWAIT_REPLY
] = "ClAwtRpl",
31 [RXRPC_CALL_CLIENT_RECV_REPLY
] = "ClRcvRpl",
32 [RXRPC_CALL_CLIENT_FINAL_ACK
] = "ClFnlACK",
33 [RXRPC_CALL_SERVER_SECURING
] = "SvSecure",
34 [RXRPC_CALL_SERVER_ACCEPTING
] = "SvAccept",
35 [RXRPC_CALL_SERVER_RECV_REQUEST
] = "SvRcvReq",
36 [RXRPC_CALL_SERVER_ACK_REQUEST
] = "SvAckReq",
37 [RXRPC_CALL_SERVER_SEND_REPLY
] = "SvSndRpl",
38 [RXRPC_CALL_SERVER_AWAIT_ACK
] = "SvAwtACK",
39 [RXRPC_CALL_COMPLETE
] = "Complete",
40 [RXRPC_CALL_SERVER_BUSY
] = "SvBusy ",
41 [RXRPC_CALL_REMOTELY_ABORTED
] = "RmtAbort",
42 [RXRPC_CALL_LOCALLY_ABORTED
] = "LocAbort",
43 [RXRPC_CALL_NETWORK_ERROR
] = "NetError",
44 [RXRPC_CALL_DEAD
] = "Dead ",
48 * generate a list of extant and dead calls in /proc/net/rxrpc_calls
50 static void *rxrpc_call_seq_start(struct seq_file
*seq
, loff_t
*_pos
)
55 read_lock(&rxrpc_call_lock
);
57 return SEQ_START_TOKEN
;
60 list_for_each(_p
, &rxrpc_calls
)
64 return _p
!= &rxrpc_calls
? _p
: NULL
;
67 static void *rxrpc_call_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
74 _p
= (v
== SEQ_START_TOKEN
) ? rxrpc_calls
.next
: _p
->next
;
76 return _p
!= &rxrpc_calls
? _p
: NULL
;
79 static void rxrpc_call_seq_stop(struct seq_file
*seq
, void *v
)
81 read_unlock(&rxrpc_call_lock
);
84 static int rxrpc_call_seq_show(struct seq_file
*seq
, void *v
)
86 struct rxrpc_transport
*trans
;
87 struct rxrpc_call
*call
;
88 char lbuff
[4 + 4 + 4 + 4 + 5 + 1], rbuff
[4 + 4 + 4 + 4 + 5 + 1];
90 if (v
== SEQ_START_TOKEN
) {
93 " SvID ConnID CallID End Use State Abort "
98 call
= list_entry(v
, struct rxrpc_call
, link
);
99 trans
= call
->conn
->trans
;
101 sprintf(lbuff
, NIPQUAD_FMT
":%u",
102 NIPQUAD(trans
->local
->srx
.transport
.sin
.sin_addr
),
103 ntohs(trans
->local
->srx
.transport
.sin
.sin_port
));
105 sprintf(rbuff
, NIPQUAD_FMT
":%u",
106 NIPQUAD(trans
->peer
->srx
.transport
.sin
.sin_addr
),
107 ntohs(trans
->peer
->srx
.transport
.sin
.sin_port
));
110 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
111 " %-8.8s %08x %lx\n",
114 ntohs(call
->conn
->service_id
),
115 ntohl(call
->conn
->cid
),
116 ntohl(call
->call_id
),
117 call
->conn
->in_clientflag
? "Svc" : "Clt",
118 atomic_read(&call
->usage
),
119 rxrpc_call_states
[call
->state
],
126 static struct seq_operations rxrpc_call_seq_ops
= {
127 .start
= rxrpc_call_seq_start
,
128 .next
= rxrpc_call_seq_next
,
129 .stop
= rxrpc_call_seq_stop
,
130 .show
= rxrpc_call_seq_show
,
133 static int rxrpc_call_seq_open(struct inode
*inode
, struct file
*file
)
135 return seq_open(file
, &rxrpc_call_seq_ops
);
138 struct file_operations rxrpc_call_seq_fops
= {
139 .owner
= THIS_MODULE
,
140 .open
= rxrpc_call_seq_open
,
143 .release
= seq_release_private
,
147 * generate a list of extant virtual connections in /proc/net/rxrpc_conns
149 static void *rxrpc_connection_seq_start(struct seq_file
*seq
, loff_t
*_pos
)
151 struct list_head
*_p
;
154 read_lock(&rxrpc_connection_lock
);
156 return SEQ_START_TOKEN
;
159 list_for_each(_p
, &rxrpc_connections
)
163 return _p
!= &rxrpc_connections
? _p
: NULL
;
166 static void *rxrpc_connection_seq_next(struct seq_file
*seq
, void *v
,
169 struct list_head
*_p
;
174 _p
= (v
== SEQ_START_TOKEN
) ? rxrpc_connections
.next
: _p
->next
;
176 return _p
!= &rxrpc_connections
? _p
: NULL
;
179 static void rxrpc_connection_seq_stop(struct seq_file
*seq
, void *v
)
181 read_unlock(&rxrpc_connection_lock
);
184 static int rxrpc_connection_seq_show(struct seq_file
*seq
, void *v
)
186 struct rxrpc_connection
*conn
;
187 struct rxrpc_transport
*trans
;
188 char lbuff
[4 + 4 + 4 + 4 + 5 + 1], rbuff
[4 + 4 + 4 + 4 + 5 + 1];
190 if (v
== SEQ_START_TOKEN
) {
192 "Proto Local Remote "
193 " SvID ConnID Calls End Use State Key "
199 conn
= list_entry(v
, struct rxrpc_connection
, link
);
202 sprintf(lbuff
, NIPQUAD_FMT
":%u",
203 NIPQUAD(trans
->local
->srx
.transport
.sin
.sin_addr
),
204 ntohs(trans
->local
->srx
.transport
.sin
.sin_port
));
206 sprintf(rbuff
, NIPQUAD_FMT
":%u",
207 NIPQUAD(trans
->peer
->srx
.transport
.sin
.sin_addr
),
208 ntohs(trans
->peer
->srx
.transport
.sin
.sin_port
));
211 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
212 " %s %08x %08x %08x\n",
215 ntohs(conn
->service_id
),
218 conn
->in_clientflag
? "Svc" : "Clt",
219 atomic_read(&conn
->usage
),
220 rxrpc_conn_states
[conn
->state
],
221 key_serial(conn
->key
),
222 atomic_read(&conn
->serial
),
223 atomic_read(&conn
->hi_serial
));
228 static struct seq_operations rxrpc_connection_seq_ops
= {
229 .start
= rxrpc_connection_seq_start
,
230 .next
= rxrpc_connection_seq_next
,
231 .stop
= rxrpc_connection_seq_stop
,
232 .show
= rxrpc_connection_seq_show
,
236 static int rxrpc_connection_seq_open(struct inode
*inode
, struct file
*file
)
238 return seq_open(file
, &rxrpc_connection_seq_ops
);
241 struct file_operations rxrpc_connection_seq_fops
= {
242 .owner
= THIS_MODULE
,
243 .open
= rxrpc_connection_seq_open
,
246 .release
= seq_release_private
,