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",
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
)
36 read_lock(&rxrpc_call_lock
);
38 return SEQ_START_TOKEN
;
41 list_for_each(_p
, &rxrpc_calls
)
45 return _p
!= &rxrpc_calls
? _p
: NULL
;
48 static void *rxrpc_call_seq_next(struct seq_file
*seq
, void *v
, loff_t
*pos
)
55 _p
= (v
== SEQ_START_TOKEN
) ? rxrpc_calls
.next
: _p
->next
;
57 return _p
!= &rxrpc_calls
? _p
: NULL
;
60 static void rxrpc_call_seq_stop(struct seq_file
*seq
, void *v
)
62 read_unlock(&rxrpc_call_lock
);
65 static int rxrpc_call_seq_show(struct seq_file
*seq
, void *v
)
67 struct rxrpc_transport
*trans
;
68 struct rxrpc_call
*call
;
69 char lbuff
[4 + 4 + 4 + 4 + 5 + 1], rbuff
[4 + 4 + 4 + 4 + 5 + 1];
71 if (v
== SEQ_START_TOKEN
) {
74 " SvID ConnID CallID End Use State Abort "
79 call
= list_entry(v
, struct rxrpc_call
, link
);
80 trans
= call
->conn
->trans
;
82 sprintf(lbuff
, NIPQUAD_FMT
":%u",
83 NIPQUAD(trans
->local
->srx
.transport
.sin
.sin_addr
),
84 ntohs(trans
->local
->srx
.transport
.sin
.sin_port
));
86 sprintf(rbuff
, NIPQUAD_FMT
":%u",
87 NIPQUAD(trans
->peer
->srx
.transport
.sin
.sin_addr
),
88 ntohs(trans
->peer
->srx
.transport
.sin
.sin_port
));
91 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
95 ntohs(call
->conn
->service_id
),
96 ntohl(call
->conn
->cid
),
98 call
->conn
->in_clientflag
? "Svc" : "Clt",
99 atomic_read(&call
->usage
),
100 rxrpc_call_states
[call
->state
],
107 static 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 struct file_operations rxrpc_call_seq_fops
= {
120 .owner
= THIS_MODULE
,
121 .open
= rxrpc_call_seq_open
,
124 .release
= seq_release_private
,
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 struct list_head
*_p
;
135 read_lock(&rxrpc_connection_lock
);
137 return SEQ_START_TOKEN
;
140 list_for_each(_p
, &rxrpc_connections
)
144 return _p
!= &rxrpc_connections
? _p
: NULL
;
147 static void *rxrpc_connection_seq_next(struct seq_file
*seq
, void *v
,
150 struct list_head
*_p
;
155 _p
= (v
== SEQ_START_TOKEN
) ? rxrpc_connections
.next
: _p
->next
;
157 return _p
!= &rxrpc_connections
? _p
: NULL
;
160 static void rxrpc_connection_seq_stop(struct seq_file
*seq
, void *v
)
162 read_unlock(&rxrpc_connection_lock
);
165 static int rxrpc_connection_seq_show(struct seq_file
*seq
, void *v
)
167 struct rxrpc_connection
*conn
;
168 struct rxrpc_transport
*trans
;
169 char lbuff
[4 + 4 + 4 + 4 + 5 + 1], rbuff
[4 + 4 + 4 + 4 + 5 + 1];
171 if (v
== SEQ_START_TOKEN
) {
173 "Proto Local Remote "
174 " SvID ConnID Calls End Use State Key "
180 conn
= list_entry(v
, struct rxrpc_connection
, link
);
183 sprintf(lbuff
, NIPQUAD_FMT
":%u",
184 NIPQUAD(trans
->local
->srx
.transport
.sin
.sin_addr
),
185 ntohs(trans
->local
->srx
.transport
.sin
.sin_port
));
187 sprintf(rbuff
, NIPQUAD_FMT
":%u",
188 NIPQUAD(trans
->peer
->srx
.transport
.sin
.sin_addr
),
189 ntohs(trans
->peer
->srx
.transport
.sin
.sin_port
));
192 "UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
193 " %s %08x %08x %08x\n",
196 ntohs(conn
->service_id
),
199 conn
->in_clientflag
? "Svc" : "Clt",
200 atomic_read(&conn
->usage
),
201 rxrpc_conn_states
[conn
->state
],
202 key_serial(conn
->key
),
203 atomic_read(&conn
->serial
),
204 atomic_read(&conn
->hi_serial
));
209 static struct seq_operations rxrpc_connection_seq_ops
= {
210 .start
= rxrpc_connection_seq_start
,
211 .next
= rxrpc_connection_seq_next
,
212 .stop
= rxrpc_connection_seq_stop
,
213 .show
= rxrpc_connection_seq_show
,
217 static int rxrpc_connection_seq_open(struct inode
*inode
, struct file
*file
)
219 return seq_open(file
, &rxrpc_connection_seq_ops
);
222 struct file_operations rxrpc_connection_seq_fops
= {
223 .owner
= THIS_MODULE
,
224 .open
= rxrpc_connection_seq_open
,
227 .release
= seq_release_private
,