2007-04-27 06:48:28 +08:00
|
|
|
/* /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"
|
|
|
|
|
2008-01-31 10:55:45 +08:00
|
|
|
static const char *const rxrpc_conn_states[] = {
|
2007-04-27 06:48:28 +08:00
|
|
|
[RXRPC_CONN_UNUSED] = "Unused ",
|
|
|
|
[RXRPC_CONN_CLIENT] = "Client ",
|
|
|
|
[RXRPC_CONN_SERVER_UNSECURED] = "SvUnsec ",
|
|
|
|
[RXRPC_CONN_SERVER_CHALLENGING] = "SvChall ",
|
|
|
|
[RXRPC_CONN_SERVER] = "SvSecure",
|
|
|
|
[RXRPC_CONN_REMOTELY_ABORTED] = "RmtAbort",
|
|
|
|
[RXRPC_CONN_LOCALLY_ABORTED] = "LocAbort",
|
|
|
|
[RXRPC_CONN_NETWORK_ERROR] = "NetError",
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
read_lock(&rxrpc_call_lock);
|
2007-07-10 04:15:14 +08:00
|
|
|
return seq_list_start_head(&rxrpc_calls, *_pos);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *rxrpc_call_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|
|
|
{
|
2007-07-10 04:15:14 +08:00
|
|
|
return seq_list_next(v, &rxrpc_calls, pos);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rxrpc_call_seq_stop(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
read_unlock(&rxrpc_call_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rxrpc_call_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct rxrpc_transport *trans;
|
|
|
|
struct rxrpc_call *call;
|
|
|
|
char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
|
|
|
|
|
2007-07-10 04:15:14 +08:00
|
|
|
if (v == &rxrpc_calls) {
|
2007-04-27 06:48:28 +08:00
|
|
|
seq_puts(seq,
|
|
|
|
"Proto Local Remote "
|
|
|
|
" SvID ConnID CallID End Use State Abort "
|
|
|
|
" UserID\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
call = list_entry(v, struct rxrpc_call, link);
|
|
|
|
trans = call->conn->trans;
|
|
|
|
|
2008-10-31 15:54:56 +08:00
|
|
|
sprintf(lbuff, "%pI4:%u",
|
|
|
|
&trans->local->srx.transport.sin.sin_addr,
|
2007-04-27 06:48:28 +08:00
|
|
|
ntohs(trans->local->srx.transport.sin.sin_port));
|
|
|
|
|
2008-10-31 15:54:56 +08:00
|
|
|
sprintf(rbuff, "%pI4:%u",
|
|
|
|
&trans->peer->srx.transport.sin.sin_addr,
|
2007-04-27 06:48:28 +08:00
|
|
|
ntohs(trans->peer->srx.transport.sin.sin_port));
|
|
|
|
|
|
|
|
seq_printf(seq,
|
|
|
|
"UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
|
|
|
|
" %-8.8s %08x %lx\n",
|
|
|
|
lbuff,
|
|
|
|
rbuff,
|
2016-03-04 23:53:46 +08:00
|
|
|
call->conn->service_id,
|
|
|
|
call->cid,
|
|
|
|
call->call_id,
|
2007-04-27 06:48:28 +08:00
|
|
|
call->conn->in_clientflag ? "Svc" : "Clt",
|
|
|
|
atomic_read(&call->usage),
|
|
|
|
rxrpc_call_states[call->state],
|
2016-04-08 00:23:30 +08:00
|
|
|
call->remote_abort ?: call->local_abort,
|
2007-04-27 06:48:28 +08:00
|
|
|
call->user_call_ID);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-11 14:07:31 +08:00
|
|
|
static const struct seq_operations rxrpc_call_seq_ops = {
|
2007-04-27 06:48:28 +08:00
|
|
|
.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)
|
|
|
|
{
|
|
|
|
return seq_open(file, &rxrpc_call_seq_ops);
|
|
|
|
}
|
|
|
|
|
2008-01-31 10:55:45 +08:00
|
|
|
const struct file_operations rxrpc_call_seq_fops = {
|
2007-04-27 06:48:28 +08:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = rxrpc_call_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2008-03-01 03:39:17 +08:00
|
|
|
.release = seq_release,
|
2007-04-27 06:48:28 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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)
|
|
|
|
{
|
|
|
|
read_lock(&rxrpc_connection_lock);
|
2007-07-10 04:15:14 +08:00
|
|
|
return seq_list_start_head(&rxrpc_connections, *_pos);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void *rxrpc_connection_seq_next(struct seq_file *seq, void *v,
|
|
|
|
loff_t *pos)
|
|
|
|
{
|
2007-07-10 04:15:14 +08:00
|
|
|
return seq_list_next(v, &rxrpc_connections, pos);
|
2007-04-27 06:48:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void rxrpc_connection_seq_stop(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
read_unlock(&rxrpc_connection_lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct rxrpc_connection *conn;
|
|
|
|
struct rxrpc_transport *trans;
|
|
|
|
char lbuff[4 + 4 + 4 + 4 + 5 + 1], rbuff[4 + 4 + 4 + 4 + 5 + 1];
|
|
|
|
|
2007-07-10 04:15:14 +08:00
|
|
|
if (v == &rxrpc_connections) {
|
2007-04-27 06:48:28 +08:00
|
|
|
seq_puts(seq,
|
|
|
|
"Proto Local Remote "
|
|
|
|
" SvID ConnID Calls End Use State Key "
|
|
|
|
" Serial ISerial\n"
|
|
|
|
);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
conn = list_entry(v, struct rxrpc_connection, link);
|
|
|
|
trans = conn->trans;
|
|
|
|
|
2008-10-31 15:54:56 +08:00
|
|
|
sprintf(lbuff, "%pI4:%u",
|
|
|
|
&trans->local->srx.transport.sin.sin_addr,
|
2007-04-27 06:48:28 +08:00
|
|
|
ntohs(trans->local->srx.transport.sin.sin_port));
|
|
|
|
|
2008-10-31 15:54:56 +08:00
|
|
|
sprintf(rbuff, "%pI4:%u",
|
|
|
|
&trans->peer->srx.transport.sin.sin_addr,
|
2007-04-27 06:48:28 +08:00
|
|
|
ntohs(trans->peer->srx.transport.sin.sin_port));
|
|
|
|
|
|
|
|
seq_printf(seq,
|
|
|
|
"UDP %-22.22s %-22.22s %4x %08x %08x %s %3u"
|
|
|
|
" %s %08x %08x %08x\n",
|
|
|
|
lbuff,
|
|
|
|
rbuff,
|
2016-03-04 23:53:46 +08:00
|
|
|
conn->service_id,
|
|
|
|
conn->cid,
|
2007-04-27 06:48:28 +08:00
|
|
|
conn->call_counter,
|
|
|
|
conn->in_clientflag ? "Svc" : "Clt",
|
|
|
|
atomic_read(&conn->usage),
|
|
|
|
rxrpc_conn_states[conn->state],
|
|
|
|
key_serial(conn->key),
|
|
|
|
atomic_read(&conn->serial),
|
|
|
|
atomic_read(&conn->hi_serial));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-11 14:07:31 +08:00
|
|
|
static const struct seq_operations rxrpc_connection_seq_ops = {
|
2007-04-27 06:48:28 +08:00
|
|
|
.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)
|
|
|
|
{
|
|
|
|
return seq_open(file, &rxrpc_connection_seq_ops);
|
|
|
|
}
|
|
|
|
|
2008-01-31 10:55:45 +08:00
|
|
|
const struct file_operations rxrpc_connection_seq_fops = {
|
2007-04-27 06:48:28 +08:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = rxrpc_connection_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2008-03-01 03:39:17 +08:00
|
|
|
.release = seq_release,
|
2007-04-27 06:48:28 +08:00
|
|
|
};
|