2008-01-11 14:57:09 +00:00
|
|
|
/* SCTP kernel implementation
|
2005-04-16 22:20:36 +00:00
|
|
|
* Copyright (c) 2003 International Business Machines, Corp.
|
|
|
|
*
|
2008-01-11 14:57:09 +00:00
|
|
|
* This file is part of the SCTP kernel implementation
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
2008-01-11 14:57:09 +00:00
|
|
|
* This SCTP implementation is free software;
|
2005-04-16 22:20:36 +00:00
|
|
|
* 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, or (at your option)
|
|
|
|
* any later version.
|
|
|
|
*
|
2008-01-11 14:57:09 +00:00
|
|
|
* This SCTP implementation is distributed in the hope that it
|
2005-04-16 22:20:36 +00:00
|
|
|
* will be useful, but WITHOUT ANY WARRANTY; without even the implied
|
|
|
|
* ************************
|
|
|
|
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
* See the GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2013-12-06 14:28:48 +00:00
|
|
|
* along with GNU CC; see the file COPYING. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Please send any bug reports or fixes you make to the
|
|
|
|
* email address(es):
|
2013-07-23 12:51:47 +00:00
|
|
|
* lksctp developers <linux-sctp@vger.kernel.org>
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Written or modified by:
|
|
|
|
* Sridhar Samudrala <sri@us.ibm.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/seq_file.h>
|
|
|
|
#include <linux/init.h>
|
2011-07-15 15:47:34 +00:00
|
|
|
#include <linux/export.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <net/sctp/sctp.h>
|
2008-02-10 07:23:44 +00:00
|
|
|
#include <net/ip.h> /* for snmp_fold_field */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-01-22 10:17:26 +00:00
|
|
|
static const struct snmp_mib sctp_snmp_list[] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
SNMP_MIB_ITEM("SctpCurrEstab", SCTP_MIB_CURRESTAB),
|
|
|
|
SNMP_MIB_ITEM("SctpActiveEstabs", SCTP_MIB_ACTIVEESTABS),
|
|
|
|
SNMP_MIB_ITEM("SctpPassiveEstabs", SCTP_MIB_PASSIVEESTABS),
|
|
|
|
SNMP_MIB_ITEM("SctpAborteds", SCTP_MIB_ABORTEDS),
|
|
|
|
SNMP_MIB_ITEM("SctpShutdowns", SCTP_MIB_SHUTDOWNS),
|
|
|
|
SNMP_MIB_ITEM("SctpOutOfBlues", SCTP_MIB_OUTOFBLUES),
|
|
|
|
SNMP_MIB_ITEM("SctpChecksumErrors", SCTP_MIB_CHECKSUMERRORS),
|
|
|
|
SNMP_MIB_ITEM("SctpOutCtrlChunks", SCTP_MIB_OUTCTRLCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpOutOrderChunks", SCTP_MIB_OUTORDERCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpOutUnorderChunks", SCTP_MIB_OUTUNORDERCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpInCtrlChunks", SCTP_MIB_INCTRLCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpInOrderChunks", SCTP_MIB_INORDERCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpInUnorderChunks", SCTP_MIB_INUNORDERCHUNKS),
|
|
|
|
SNMP_MIB_ITEM("SctpFragUsrMsgs", SCTP_MIB_FRAGUSRMSGS),
|
|
|
|
SNMP_MIB_ITEM("SctpReasmUsrMsgs", SCTP_MIB_REASMUSRMSGS),
|
|
|
|
SNMP_MIB_ITEM("SctpOutSCTPPacks", SCTP_MIB_OUTSCTPPACKS),
|
|
|
|
SNMP_MIB_ITEM("SctpInSCTPPacks", SCTP_MIB_INSCTPPACKS),
|
2006-08-22 07:15:33 +00:00
|
|
|
SNMP_MIB_ITEM("SctpT1InitExpireds", SCTP_MIB_T1_INIT_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT1CookieExpireds", SCTP_MIB_T1_COOKIE_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT2ShutdownExpireds", SCTP_MIB_T2_SHUTDOWN_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT3RtxExpireds", SCTP_MIB_T3_RTX_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT4RtoExpireds", SCTP_MIB_T4_RTO_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT5ShutdownGuardExpireds", SCTP_MIB_T5_SHUTDOWN_GUARD_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpDelaySackExpireds", SCTP_MIB_DELAY_SACK_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpAutocloseExpireds", SCTP_MIB_AUTOCLOSE_EXPIREDS),
|
|
|
|
SNMP_MIB_ITEM("SctpT3Retransmits", SCTP_MIB_T3_RETRANSMITS),
|
|
|
|
SNMP_MIB_ITEM("SctpPmtudRetransmits", SCTP_MIB_PMTUD_RETRANSMITS),
|
|
|
|
SNMP_MIB_ITEM("SctpFastRetransmits", SCTP_MIB_FAST_RETRANSMITS),
|
|
|
|
SNMP_MIB_ITEM("SctpInPktSoftirq", SCTP_MIB_IN_PKT_SOFTIRQ),
|
|
|
|
SNMP_MIB_ITEM("SctpInPktBacklog", SCTP_MIB_IN_PKT_BACKLOG),
|
|
|
|
SNMP_MIB_ITEM("SctpInPktDiscards", SCTP_MIB_IN_PKT_DISCARDS),
|
|
|
|
SNMP_MIB_ITEM("SctpInDataChunkDiscards", SCTP_MIB_IN_DATA_CHUNK_DISCARDS),
|
2005-08-23 17:12:04 +00:00
|
|
|
SNMP_MIB_SENTINEL
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */
|
|
|
|
static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
struct net *net = seq->private;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; sctp_snmp_list[i].name != NULL; i++)
|
|
|
|
seq_printf(seq, "%-32s\t%ld\n", sctp_snmp_list[i].name,
|
2014-05-12 23:52:02 +00:00
|
|
|
snmp_fold_field(net->sctp.sctp_statistics,
|
2005-04-16 22:20:36 +00:00
|
|
|
sctp_snmp_list[i].entry));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the seq file operations for 'snmp' object. */
|
|
|
|
static int sctp_snmp_seq_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
return single_open_net(inode, file, sctp_snmp_seq_show);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:36 +00:00
|
|
|
static const struct file_operations sctp_snmp_seq_fops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = sctp_snmp_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2012-11-15 03:49:05 +00:00
|
|
|
.release = single_release_net,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Set up the proc fs entry for 'snmp' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
int __net_init sctp_snmp_proc_init(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
2012-08-06 08:45:15 +00:00
|
|
|
p = proc_create("snmp", S_IRUGO, net->sctp.proc_net_sctp,
|
|
|
|
&sctp_snmp_seq_fops);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup the proc fs entry for 'snmp' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
void sctp_snmp_proc_exit(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
remove_proc_entry("snmp", net->sctp.proc_net_sctp);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Dump local addresses of an association/endpoint. */
|
|
|
|
static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb)
|
|
|
|
{
|
2005-06-13 22:11:57 +00:00
|
|
|
struct sctp_association *asoc;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sctp_sockaddr_entry *laddr;
|
2005-06-13 22:11:57 +00:00
|
|
|
struct sctp_transport *peer;
|
|
|
|
union sctp_addr *addr, *primary = NULL;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sctp_af *af;
|
|
|
|
|
2005-06-13 22:11:57 +00:00
|
|
|
if (epb->type == SCTP_EP_TYPE_ASSOCIATION) {
|
2013-06-14 16:24:04 +00:00
|
|
|
asoc = sctp_assoc(epb);
|
|
|
|
|
|
|
|
peer = asoc->peer.primary_path;
|
|
|
|
if (unlikely(peer == NULL)) {
|
2013-06-25 16:17:28 +00:00
|
|
|
WARN(1, "Association %p with NULL primary path!\n", asoc);
|
2013-06-14 16:24:04 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
primary = &peer->saddr;
|
2005-06-13 22:11:57 +00:00
|
|
|
}
|
|
|
|
|
2012-12-06 09:25:04 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(laddr, &epb->bind_addr.address_list, list) {
|
|
|
|
if (!laddr->valid)
|
|
|
|
continue;
|
|
|
|
|
2006-11-21 01:05:23 +00:00
|
|
|
addr = &laddr->a;
|
2005-04-16 22:20:36 +00:00
|
|
|
af = sctp_get_af_specific(addr->sa.sa_family);
|
2005-06-13 22:11:57 +00:00
|
|
|
if (primary && af->cmp_addr(addr, primary)) {
|
|
|
|
seq_printf(seq, "*");
|
|
|
|
}
|
2006-11-21 01:05:23 +00:00
|
|
|
af->seq_dump_addr(seq, addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-12-06 09:25:04 +00:00
|
|
|
rcu_read_unlock();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Dump remote addresses of an association. */
|
|
|
|
static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_association *assoc)
|
|
|
|
{
|
|
|
|
struct sctp_transport *transport;
|
2005-06-13 22:11:57 +00:00
|
|
|
union sctp_addr *addr, *primary;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sctp_af *af;
|
|
|
|
|
2006-11-21 01:06:04 +00:00
|
|
|
primary = &assoc->peer.primary_addr;
|
2012-12-06 09:25:05 +00:00
|
|
|
rcu_read_lock();
|
|
|
|
list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list,
|
2008-04-13 01:54:24 +00:00
|
|
|
transports) {
|
2006-11-21 01:05:23 +00:00
|
|
|
addr = &transport->ipaddr;
|
2012-12-06 09:25:05 +00:00
|
|
|
if (transport->dead)
|
|
|
|
continue;
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
af = sctp_get_af_specific(addr->sa.sa_family);
|
2006-11-21 01:06:04 +00:00
|
|
|
if (af->cmp_addr(addr, primary)) {
|
2005-06-13 22:11:57 +00:00
|
|
|
seq_printf(seq, "*");
|
|
|
|
}
|
2006-11-21 01:05:23 +00:00
|
|
|
af->seq_dump_addr(seq, addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-12-06 09:25:05 +00:00
|
|
|
rcu_read_unlock();
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2013-12-23 04:16:51 +00:00
|
|
|
static void *sctp_eps_seq_start(struct seq_file *seq, loff_t *pos)
|
2005-06-13 22:11:57 +00:00
|
|
|
{
|
2006-01-17 19:53:06 +00:00
|
|
|
if (*pos >= sctp_ep_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (*pos < 0)
|
|
|
|
*pos = 0;
|
|
|
|
|
|
|
|
if (*pos == 0)
|
|
|
|
seq_printf(seq, " ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS\n");
|
|
|
|
|
|
|
|
return (void *)pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_eps_seq_stop(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 04:16:51 +00:00
|
|
|
static void *sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
2005-06-13 22:11:57 +00:00
|
|
|
{
|
2006-01-17 19:53:06 +00:00
|
|
|
if (++*pos >= sctp_ep_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Display sctp endpoints (/proc/net/sctp/eps). */
|
|
|
|
static int sctp_eps_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct sctp_hashbucket *head;
|
|
|
|
struct sctp_ep_common *epb;
|
|
|
|
struct sctp_endpoint *ep;
|
|
|
|
struct sock *sk;
|
2006-01-17 19:54:06 +00:00
|
|
|
int hash = *(loff_t *)v;
|
2005-06-13 22:11:57 +00:00
|
|
|
|
2006-01-17 19:53:06 +00:00
|
|
|
if (hash >= sctp_ep_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2006-01-17 19:53:06 +00:00
|
|
|
head = &sctp_ep_hashtable[hash];
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_disable();
|
2005-06-13 22:11:57 +00:00
|
|
|
read_lock(&head->lock);
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
sctp_for_each_hentry(epb, &head->chain) {
|
2005-06-13 22:11:57 +00:00
|
|
|
ep = sctp_ep(epb);
|
|
|
|
sk = epb->sk;
|
2012-08-16 01:24:49 +00:00
|
|
|
if (!net_eq(sock_net(sk), seq_file_net(seq)))
|
2012-08-06 08:45:15 +00:00
|
|
|
continue;
|
2013-08-15 11:42:14 +00:00
|
|
|
seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5u %5lu ", ep, sk,
|
2006-01-17 19:53:06 +00:00
|
|
|
sctp_sk(sk)->type, sk->sk_state, hash,
|
2005-06-13 22:11:57 +00:00
|
|
|
epb->bind_addr.port,
|
2012-05-24 07:10:10 +00:00
|
|
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
|
|
|
sock_i_ino(sk));
|
2005-06-13 22:11:57 +00:00
|
|
|
|
|
|
|
sctp_seq_dump_local_addrs(seq, epb);
|
|
|
|
seq_printf(seq, "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-06-13 22:11:57 +00:00
|
|
|
read_unlock(&head->lock);
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_enable();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-11 06:07:31 +00:00
|
|
|
static const struct seq_operations sctp_eps_ops = {
|
2005-06-13 22:11:57 +00:00
|
|
|
.start = sctp_eps_seq_start,
|
|
|
|
.next = sctp_eps_seq_next,
|
|
|
|
.stop = sctp_eps_seq_stop,
|
|
|
|
.show = sctp_eps_seq_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Initialize the seq file operations for 'eps' object. */
|
|
|
|
static int sctp_eps_seq_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
return seq_open_net(inode, file, &sctp_eps_ops,
|
|
|
|
sizeof(struct seq_net_private));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:36 +00:00
|
|
|
static const struct file_operations sctp_eps_seq_fops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.open = sctp_eps_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2012-11-15 03:49:05 +00:00
|
|
|
.release = seq_release_net,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Set up the proc fs entry for 'eps' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
int __net_init sctp_eps_proc_init(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
2012-08-06 08:45:15 +00:00
|
|
|
p = proc_create("eps", S_IRUGO, net->sctp.proc_net_sctp,
|
|
|
|
&sctp_eps_seq_fops);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup the proc fs entry for 'eps' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
void sctp_eps_proc_exit(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
remove_proc_entry("eps", net->sctp.proc_net_sctp);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2005-06-13 22:11:57 +00:00
|
|
|
|
2013-12-23 04:16:51 +00:00
|
|
|
static void *sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos)
|
2005-06-13 22:11:57 +00:00
|
|
|
{
|
2006-01-17 19:53:06 +00:00
|
|
|
if (*pos >= sctp_assoc_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (*pos < 0)
|
|
|
|
*pos = 0;
|
|
|
|
|
|
|
|
if (*pos == 0)
|
2008-02-29 19:40:56 +00:00
|
|
|
seq_printf(seq, " ASSOC SOCK STY SST ST HBKT "
|
|
|
|
"ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT "
|
|
|
|
"RPORT LADDRS <-> RADDRS "
|
2013-04-16 01:39:07 +00:00
|
|
|
"HBINT INS OUTS MAXRT T1X T2X RTXC "
|
|
|
|
"wmema wmemq sndbuf rcvbuf\n");
|
2005-06-13 22:11:57 +00:00
|
|
|
|
|
|
|
return (void *)pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_assocs_seq_stop(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-12-23 04:16:51 +00:00
|
|
|
static void *sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
2005-06-13 22:11:57 +00:00
|
|
|
{
|
2006-01-17 19:53:06 +00:00
|
|
|
if (++*pos >= sctp_assoc_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Display sctp associations (/proc/net/sctp/assocs). */
|
|
|
|
static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct sctp_hashbucket *head;
|
|
|
|
struct sctp_ep_common *epb;
|
|
|
|
struct sctp_association *assoc;
|
|
|
|
struct sock *sk;
|
2006-01-17 19:54:06 +00:00
|
|
|
int hash = *(loff_t *)v;
|
2005-06-13 22:11:57 +00:00
|
|
|
|
2006-01-17 19:53:06 +00:00
|
|
|
if (hash >= sctp_assoc_hashsize)
|
2005-06-13 22:11:57 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2006-01-17 19:53:06 +00:00
|
|
|
head = &sctp_assoc_hashtable[hash];
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_disable();
|
2005-06-13 22:11:57 +00:00
|
|
|
read_lock(&head->lock);
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
sctp_for_each_hentry(epb, &head->chain) {
|
2005-06-13 22:11:57 +00:00
|
|
|
assoc = sctp_assoc(epb);
|
|
|
|
sk = epb->sk;
|
2012-08-16 01:24:49 +00:00
|
|
|
if (!net_eq(sock_net(sk), seq_file_net(seq)))
|
2012-08-06 08:45:15 +00:00
|
|
|
continue;
|
2005-06-13 22:11:57 +00:00
|
|
|
seq_printf(seq,
|
net: convert %p usage to %pK
The %pK format specifier is designed to hide exposed kernel pointers,
specifically via /proc interfaces. Exposing these pointers provides an
easy target for kernel write vulnerabilities, since they reveal the
locations of writable structures containing easily triggerable function
pointers. The behavior of %pK depends on the kptr_restrict sysctl.
If kptr_restrict is set to 0, no deviation from the standard %p behavior
occurs. If kptr_restrict is set to 1, the default, if the current user
(intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG
(currently in the LSM tree), kernel pointers using %pK are printed as 0's.
If kptr_restrict is set to 2, kernel pointers using %pK are printed as
0's regardless of privileges. Replacing with 0's was chosen over the
default "(null)", which cannot be parsed by userland %p, which expects
"(nil)".
The supporting code for kptr_restrict and %pK are currently in the -mm
tree. This patch converts users of %p in net/ to %pK. Cases of printing
pointers to the syslog are not covered, since this would eliminate useful
information for postmortem debugging and the reading of the syslog is
already optionally protected by the dmesg_restrict sysctl.
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Cc: James Morris <jmorris@namei.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Thomas Graf <tgraf@infradead.org>
Cc: Eugene Teo <eugeneteo@kernel.org>
Cc: Kees Cook <kees.cook@canonical.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David S. Miller <davem@davemloft.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Eric Paris <eparis@parisplace.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2011-05-23 12:17:35 +00:00
|
|
|
"%8pK %8pK %-3d %-3d %-2d %-4d "
|
2013-08-15 11:42:14 +00:00
|
|
|
"%4d %8d %8d %7u %5lu %-5d %5d ",
|
2005-06-13 22:11:57 +00:00
|
|
|
assoc, sk, sctp_sk(sk)->type, sk->sk_state,
|
2008-02-29 19:40:56 +00:00
|
|
|
assoc->state, hash,
|
|
|
|
assoc->assoc_id,
|
2005-06-13 22:11:57 +00:00
|
|
|
assoc->sndbuf_used,
|
2006-10-10 04:34:26 +00:00
|
|
|
atomic_read(&assoc->rmem_alloc),
|
2012-05-24 07:10:10 +00:00
|
|
|
from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
|
|
|
|
sock_i_ino(sk),
|
2005-06-13 22:11:57 +00:00
|
|
|
epb->bind_addr.port,
|
2008-04-13 01:53:48 +00:00
|
|
|
assoc->peer.port);
|
2005-06-13 22:11:57 +00:00
|
|
|
seq_printf(seq, " ");
|
|
|
|
sctp_seq_dump_local_addrs(seq, epb);
|
|
|
|
seq_printf(seq, "<-> ");
|
|
|
|
sctp_seq_dump_remote_addrs(seq, assoc);
|
2013-04-16 01:39:07 +00:00
|
|
|
seq_printf(seq, "\t%8lu %5d %5d %4d %4d %4d %8d "
|
|
|
|
"%8d %8d %8d %8d",
|
2008-04-13 01:53:48 +00:00
|
|
|
assoc->hbinterval, assoc->c.sinit_max_instreams,
|
|
|
|
assoc->c.sinit_num_ostreams, assoc->max_retrans,
|
|
|
|
assoc->init_retries, assoc->shutdown_retries,
|
2013-04-16 01:39:07 +00:00
|
|
|
assoc->rtx_data_chunks,
|
|
|
|
atomic_read(&sk->sk_wmem_alloc),
|
|
|
|
sk->sk_wmem_queued,
|
|
|
|
sk->sk_sndbuf,
|
|
|
|
sk->sk_rcvbuf);
|
2005-06-13 22:11:57 +00:00
|
|
|
seq_printf(seq, "\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2005-06-13 22:11:57 +00:00
|
|
|
read_unlock(&head->lock);
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_enable();
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2007-07-11 06:07:31 +00:00
|
|
|
static const struct seq_operations sctp_assoc_ops = {
|
2005-06-13 22:11:57 +00:00
|
|
|
.start = sctp_assocs_seq_start,
|
|
|
|
.next = sctp_assocs_seq_next,
|
|
|
|
.stop = sctp_assocs_seq_stop,
|
|
|
|
.show = sctp_assocs_seq_show,
|
|
|
|
};
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Initialize the seq file operations for 'assocs' object. */
|
|
|
|
static int sctp_assocs_seq_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
return seq_open_net(inode, file, &sctp_assoc_ops,
|
|
|
|
sizeof(struct seq_net_private));
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2007-02-12 08:55:36 +00:00
|
|
|
static const struct file_operations sctp_assocs_seq_fops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.open = sctp_assocs_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2012-11-15 03:49:05 +00:00
|
|
|
.release = seq_release_net,
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* Set up the proc fs entry for 'assocs' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
int __net_init sctp_assocs_proc_init(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
2012-08-06 08:45:15 +00:00
|
|
|
p = proc_create("assocs", S_IRUGO, net->sctp.proc_net_sctp,
|
2008-02-29 19:24:45 +00:00
|
|
|
&sctp_assocs_seq_fops);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Cleanup the proc fs entry for 'assocs' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
void sctp_assocs_proc_exit(struct net *net)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
remove_proc_entry("assocs", net->sctp.proc_net_sctp);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-05-09 22:14:50 +00:00
|
|
|
|
|
|
|
static void *sctp_remaddr_seq_start(struct seq_file *seq, loff_t *pos)
|
|
|
|
{
|
|
|
|
if (*pos >= sctp_assoc_hashsize)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
if (*pos < 0)
|
|
|
|
*pos = 0;
|
|
|
|
|
|
|
|
if (*pos == 0)
|
|
|
|
seq_printf(seq, "ADDR ASSOC_ID HB_ACT RTO MAX_PATH_RTX "
|
2014-10-30 09:29:15 +00:00
|
|
|
"REM_ADDR_RTX START STATE\n");
|
2008-05-09 22:14:50 +00:00
|
|
|
|
|
|
|
return (void *)pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void *sctp_remaddr_seq_next(struct seq_file *seq, void *v, loff_t *pos)
|
|
|
|
{
|
|
|
|
if (++*pos >= sctp_assoc_hashsize)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return pos;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void sctp_remaddr_seq_stop(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
|
|
|
|
{
|
|
|
|
struct sctp_hashbucket *head;
|
|
|
|
struct sctp_ep_common *epb;
|
|
|
|
struct sctp_association *assoc;
|
|
|
|
struct sctp_transport *tsp;
|
|
|
|
int hash = *(loff_t *)v;
|
|
|
|
|
|
|
|
if (hash >= sctp_assoc_hashsize)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
|
|
|
head = &sctp_assoc_hashtable[hash];
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_disable();
|
2008-05-09 22:14:50 +00:00
|
|
|
read_lock(&head->lock);
|
2012-12-06 09:25:05 +00:00
|
|
|
rcu_read_lock();
|
hlist: drop the node parameter from iterators
I'm not sure why, but the hlist for each entry iterators were conceived
list_for_each_entry(pos, head, member)
The hlist ones were greedy and wanted an extra parameter:
hlist_for_each_entry(tpos, pos, head, member)
Why did they need an extra pos parameter? I'm not quite sure. Not only
they don't really need it, it also prevents the iterator from looking
exactly like the list iterator, which is unfortunate.
Besides the semantic patch, there was some manual work required:
- Fix up the actual hlist iterators in linux/list.h
- Fix up the declaration of other iterators based on the hlist ones.
- A very small amount of places were using the 'node' parameter, this
was modified to use 'obj->member' instead.
- Coccinelle didn't handle the hlist_for_each_entry_safe iterator
properly, so those had to be fixed up manually.
The semantic patch which is mostly the work of Peter Senna Tschudin is here:
@@
iterator name hlist_for_each_entry, hlist_for_each_entry_continue, hlist_for_each_entry_from, hlist_for_each_entry_rcu, hlist_for_each_entry_rcu_bh, hlist_for_each_entry_continue_rcu_bh, for_each_busy_worker, ax25_uid_for_each, ax25_for_each, inet_bind_bucket_for_each, sctp_for_each_hentry, sk_for_each, sk_for_each_rcu, sk_for_each_from, sk_for_each_safe, sk_for_each_bound, hlist_for_each_entry_safe, hlist_for_each_entry_continue_rcu, nr_neigh_for_each, nr_neigh_for_each_safe, nr_node_for_each, nr_node_for_each_safe, for_each_gfn_indirect_valid_sp, for_each_gfn_sp, for_each_host;
type T;
expression a,c,d,e;
identifier b;
statement S;
@@
-T b;
<+... when != b
(
hlist_for_each_entry(a,
- b,
c, d) S
|
hlist_for_each_entry_continue(a,
- b,
c) S
|
hlist_for_each_entry_from(a,
- b,
c) S
|
hlist_for_each_entry_rcu(a,
- b,
c, d) S
|
hlist_for_each_entry_rcu_bh(a,
- b,
c, d) S
|
hlist_for_each_entry_continue_rcu_bh(a,
- b,
c) S
|
for_each_busy_worker(a, c,
- b,
d) S
|
ax25_uid_for_each(a,
- b,
c) S
|
ax25_for_each(a,
- b,
c) S
|
inet_bind_bucket_for_each(a,
- b,
c) S
|
sctp_for_each_hentry(a,
- b,
c) S
|
sk_for_each(a,
- b,
c) S
|
sk_for_each_rcu(a,
- b,
c) S
|
sk_for_each_from
-(a, b)
+(a)
S
+ sk_for_each_from(a) S
|
sk_for_each_safe(a,
- b,
c, d) S
|
sk_for_each_bound(a,
- b,
c) S
|
hlist_for_each_entry_safe(a,
- b,
c, d, e) S
|
hlist_for_each_entry_continue_rcu(a,
- b,
c) S
|
nr_neigh_for_each(a,
- b,
c) S
|
nr_neigh_for_each_safe(a,
- b,
c, d) S
|
nr_node_for_each(a,
- b,
c) S
|
nr_node_for_each_safe(a,
- b,
c, d) S
|
- for_each_gfn_sp(a, c, d, b) S
+ for_each_gfn_sp(a, c, d) S
|
- for_each_gfn_indirect_valid_sp(a, c, d, b) S
+ for_each_gfn_indirect_valid_sp(a, c, d) S
|
for_each_host(a,
- b,
c) S
|
for_each_host_safe(a,
- b,
c, d) S
|
for_each_mesh_entry(a,
- b,
c, d) S
)
...+>
[akpm@linux-foundation.org: drop bogus change from net/ipv4/raw.c]
[akpm@linux-foundation.org: drop bogus hunk from net/ipv6/raw.c]
[akpm@linux-foundation.org: checkpatch fixes]
[akpm@linux-foundation.org: fix warnings]
[akpm@linux-foudnation.org: redo intrusive kvm changes]
Tested-by: Peter Senna Tschudin <peter.senna@gmail.com>
Acked-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: Wu Fengguang <fengguang.wu@intel.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-02-28 01:06:00 +00:00
|
|
|
sctp_for_each_hentry(epb, &head->chain) {
|
2012-08-16 01:24:49 +00:00
|
|
|
if (!net_eq(sock_net(epb->sk), seq_file_net(seq)))
|
2012-08-06 08:45:15 +00:00
|
|
|
continue;
|
2008-05-09 22:14:50 +00:00
|
|
|
assoc = sctp_assoc(epb);
|
2012-12-06 09:25:05 +00:00
|
|
|
list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
|
2008-05-09 22:14:50 +00:00
|
|
|
transports) {
|
2012-12-06 09:25:05 +00:00
|
|
|
if (tsp->dead)
|
|
|
|
continue;
|
|
|
|
|
2008-05-09 22:14:50 +00:00
|
|
|
/*
|
|
|
|
* The remote address (ADDR)
|
|
|
|
*/
|
|
|
|
tsp->af_specific->seq_dump_addr(seq, &tsp->ipaddr);
|
|
|
|
seq_printf(seq, " ");
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The association ID (ASSOC_ID)
|
|
|
|
*/
|
|
|
|
seq_printf(seq, "%d ", tsp->asoc->assoc_id);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If the Heartbeat is active (HB_ACT)
|
|
|
|
* Note: 1 = Active, 0 = Inactive
|
|
|
|
*/
|
|
|
|
seq_printf(seq, "%d ", timer_pending(&tsp->hb_timer));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Retransmit time out (RTO)
|
|
|
|
*/
|
|
|
|
seq_printf(seq, "%lu ", tsp->rto);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Maximum path retransmit count (PATH_MAX_RTX)
|
|
|
|
*/
|
|
|
|
seq_printf(seq, "%d ", tsp->pathmaxrxt);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* remote address retransmit count (REM_ADDR_RTX)
|
|
|
|
* Note: We don't have a way to tally this at the moment
|
|
|
|
* so lets just leave it as zero for the moment
|
|
|
|
*/
|
2014-10-30 09:29:16 +00:00
|
|
|
seq_puts(seq, "0 ");
|
2008-05-09 22:14:50 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* remote address start time (START). This is also not
|
|
|
|
* currently implemented, but we can record it with a
|
|
|
|
* jiffies marker in a subsequent patch
|
|
|
|
*/
|
2014-10-30 09:29:16 +00:00
|
|
|
seq_puts(seq, "0 ");
|
2014-10-30 09:29:15 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The current state of this destination. I.e.
|
|
|
|
* SCTP_ACTIVE, SCTP_INACTIVE, ...
|
|
|
|
*/
|
|
|
|
seq_printf(seq, "%d", tsp->state);
|
2008-05-09 22:14:50 +00:00
|
|
|
|
|
|
|
seq_printf(seq, "\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-12-06 09:25:05 +00:00
|
|
|
rcu_read_unlock();
|
2008-05-09 22:14:50 +00:00
|
|
|
read_unlock(&head->lock);
|
2014-01-21 07:44:07 +00:00
|
|
|
local_bh_enable();
|
2008-05-09 22:14:50 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct seq_operations sctp_remaddr_ops = {
|
|
|
|
.start = sctp_remaddr_seq_start,
|
|
|
|
.next = sctp_remaddr_seq_next,
|
|
|
|
.stop = sctp_remaddr_seq_stop,
|
|
|
|
.show = sctp_remaddr_seq_show,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Cleanup the proc fs entry for 'remaddr' object. */
|
2012-08-06 08:45:15 +00:00
|
|
|
void sctp_remaddr_proc_exit(struct net *net)
|
2008-05-09 22:14:50 +00:00
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
remove_proc_entry("remaddr", net->sctp.proc_net_sctp);
|
2008-05-09 22:14:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int sctp_remaddr_seq_open(struct inode *inode, struct file *file)
|
|
|
|
{
|
2012-08-06 08:45:15 +00:00
|
|
|
return seq_open_net(inode, file, &sctp_remaddr_ops,
|
|
|
|
sizeof(struct seq_net_private));
|
2008-05-09 22:14:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct file_operations sctp_remaddr_seq_fops = {
|
|
|
|
.open = sctp_remaddr_seq_open,
|
|
|
|
.read = seq_read,
|
|
|
|
.llseek = seq_lseek,
|
2012-11-15 03:49:05 +00:00
|
|
|
.release = seq_release_net,
|
2008-05-09 22:14:50 +00:00
|
|
|
};
|
|
|
|
|
2012-08-06 08:45:15 +00:00
|
|
|
int __net_init sctp_remaddr_proc_init(struct net *net)
|
2008-05-09 22:14:50 +00:00
|
|
|
{
|
|
|
|
struct proc_dir_entry *p;
|
|
|
|
|
2012-08-06 08:45:15 +00:00
|
|
|
p = proc_create("remaddr", S_IRUGO, net->sctp.proc_net_sctp,
|
|
|
|
&sctp_remaddr_seq_fops);
|
2008-05-09 22:14:50 +00:00
|
|
|
if (!p)
|
|
|
|
return -ENOMEM;
|
|
|
|
return 0;
|
|
|
|
}
|