Blame view

net/sctp/proc.c 10.8 KB
47505b8bc   Thomas Gleixner   treewide: Replace...
1
  // SPDX-License-Identifier: GPL-2.0-or-later
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
2
  /* SCTP kernel implementation
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
3
4
   * Copyright (c) 2003 International Business Machines, Corp.
   *
60c778b25   Vlad Yasevich   [SCTP]: Stop clai...
5
   * This file is part of the SCTP kernel implementation
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
6
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
7
8
   * Please send any bug reports or fixes you make to the
   * email address(es):
91705c61b   Daniel Borkmann   net: sctp: trivia...
9
   *    lksctp developers <linux-sctp@vger.kernel.org>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
10
   *
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
11
12
   * Written or modified by:
   *    Sridhar Samudrala <sri@us.ibm.com>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
13
14
15
16
17
   */
  
  #include <linux/types.h>
  #include <linux/seq_file.h>
  #include <linux/init.h>
bc3b2d7fb   Paul Gortmaker   net: Add export.h...
18
  #include <linux/export.h>
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
19
  #include <net/sctp/sctp.h>
3f5340a67   Pavel Emelyanov   [SCTP]: Use snmp_...
20
  #include <net/ip.h> /* for snmp_fold_field */
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
21

5833929cc   Alexey Dobriyan   net: constify MIB...
22
  static const struct snmp_mib sctp_snmp_list[] = {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
  	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),
ac0b04627   Sridhar Samudrala   [SCTP]: Extend /p...
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
  	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),
d2287f844   Vlad Yasevich   [SCTP]: Add SENTI...
55
  	SNMP_MIB_SENTINEL
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
56
  };
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
57
58
59
  /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */
  static int sctp_snmp_seq_show(struct seq_file *seq, void *v)
  {
7d64a94be   Jia He   proc: Reduce cach...
60
  	unsigned long buff[SCTP_MIB_MAX];
13d782f6b   Eric W. Biederman   sctp: Make the pr...
61
  	struct net *net = seq->private;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
62
  	int i;
7d64a94be   Jia He   proc: Reduce cach...
63
64
65
66
  	memset(buff, 0, sizeof(unsigned long) * SCTP_MIB_MAX);
  
  	snmp_get_cpu_field_batch(buff, sctp_snmp_list,
  				 net->sctp.sctp_statistics);
6d4a741cb   Jia He   net: Suppress the...
67
  	for (i = 0; sctp_snmp_list[i].name; i++)
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
68
69
  		seq_printf(seq, "%-32s\t%ld
  ", sctp_snmp_list[i].name,
7d64a94be   Jia He   proc: Reduce cach...
70
  						buff[i]);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
71
72
73
  
  	return 0;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
74
75
76
  /* Dump local addresses of an association/endpoint. */
  static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb)
  {
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
77
  	struct sctp_association *asoc;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
78
  	struct sctp_sockaddr_entry *laddr;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
79
80
  	struct sctp_transport *peer;
  	union sctp_addr *addr, *primary = NULL;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
81
  	struct sctp_af *af;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
82
  	if (epb->type == SCTP_EP_TYPE_ASSOCIATION) {
f9e42b853   Daniel Borkmann   net: sctp: sideef...
83
84
85
86
  		asoc = sctp_assoc(epb);
  
  		peer = asoc->peer.primary_path;
  		if (unlikely(peer == NULL)) {
b527fe693   Daniel Borkmann   net: sctp: minor:...
87
88
  			WARN(1, "Association %p with NULL primary path!
  ", asoc);
f9e42b853   Daniel Borkmann   net: sctp: sideef...
89
90
91
92
  			return;
  		}
  
  		primary = &peer->saddr;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
93
  	}
0b0fe913b   Thomas Graf   sctp: proc: prote...
94
95
96
97
  	rcu_read_lock();
  	list_for_each_entry_rcu(laddr, &epb->bind_addr.address_list, list) {
  		if (!laddr->valid)
  			continue;
5f242a13e   Al Viro   [SCTP]: Switch ->...
98
  		addr = &laddr->a;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
99
  		af = sctp_get_af_specific(addr->sa.sa_family);
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
100
101
102
  		if (primary && af->cmp_addr(addr, primary)) {
  			seq_printf(seq, "*");
  		}
5f242a13e   Al Viro   [SCTP]: Switch ->...
103
  		af->seq_dump_addr(seq, addr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
104
  	}
0b0fe913b   Thomas Graf   sctp: proc: prote...
105
  	rcu_read_unlock();
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
106
107
108
109
110
  }
  
  /* Dump remote addresses of an association. */
  static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_association *assoc)
  {
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
111
  	struct sctp_transport *transport;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
112
  	union sctp_addr *addr, *primary;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
113
  	struct sctp_af *af;
acd2bc96e   Al Viro   [SCTP]: Switch ->...
114
  	primary = &assoc->peer.primary_addr;
45122ca26   Thomas Graf   sctp: Add RCU pro...
115
  	list_for_each_entry_rcu(transport, &assoc->peer.transport_addr_list,
9dbc15f05   Robert P. J. Day   [SCTP]: "list_for...
116
  			transports) {
5f242a13e   Al Viro   [SCTP]: Switch ->...
117
  		addr = &transport->ipaddr;
45122ca26   Thomas Graf   sctp: Add RCU pro...
118

1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
119
  		af = sctp_get_af_specific(addr->sa.sa_family);
acd2bc96e   Al Viro   [SCTP]: Switch ->...
120
  		if (af->cmp_addr(addr, primary)) {
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
121
122
  			seq_printf(seq, "*");
  		}
5f242a13e   Al Viro   [SCTP]: Switch ->...
123
  		af->seq_dump_addr(seq, addr);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
124
125
  	}
  }
26ac8e5fe   wangweidong   sctp: fix checkpa...
126
  static void *sctp_eps_seq_start(struct seq_file *seq, loff_t *pos)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
127
  {
49392e5ec   Vlad Yasevich   [SCTP]: sctp does...
128
  	if (*pos >= sctp_ep_hashsize)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
129
130
131
132
133
134
135
136
  		return NULL;
  
  	if (*pos < 0)
  		*pos = 0;
  
  	if (*pos == 0)
  		seq_printf(seq, " ENDPT     SOCK   STY SST HBKT LPORT   UID INODE LADDRS
  ");
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
137
138
139
140
141
  	return (void *)pos;
  }
  
  static void sctp_eps_seq_stop(struct seq_file *seq, void *v)
  {
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
142
  }
26ac8e5fe   wangweidong   sctp: fix checkpa...
143
  static void *sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
144
  {
49392e5ec   Vlad Yasevich   [SCTP]: sctp does...
145
  	if (++*pos >= sctp_ep_hashsize)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
146
  		return NULL;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
147
148
  	return pos;
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
149
150
151
152
153
154
155
  /* 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;
38b0e42ab   Vlad Yasevich   [SCTP]: Fix sctp_...
156
  	int    hash = *(loff_t *)v;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
157

49392e5ec   Vlad Yasevich   [SCTP]: sctp does...
158
  	if (hash >= sctp_ep_hashsize)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
159
  		return -ENOMEM;
49392e5ec   Vlad Yasevich   [SCTP]: sctp does...
160
  	head = &sctp_ep_hashtable[hash];
c0a4c2d1c   Xin Long   sctp: use read_lo...
161
  	read_lock_bh(&head->lock);
b67bfe0d4   Sasha Levin   hlist: drop the n...
162
  	sctp_for_each_hentry(epb, &head->chain) {
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
163
164
  		ep = sctp_ep(epb);
  		sk = epb->sk;
6932f119b   Ulrich Weber   sctp: fix compile...
165
  		if (!net_eq(sock_net(sk), seq_file_net(seq)))
13d782f6b   Eric W. Biederman   sctp: Make the pr...
166
  			continue;
d14c5ab6b   Francesco Fusco   net: proc_fs: tri...
167
  		seq_printf(seq, "%8pK %8pK %-3d %-3d %-4d %-5d %5u %5lu ", ep, sk,
49392e5ec   Vlad Yasevich   [SCTP]: sctp does...
168
  			   sctp_sk(sk)->type, sk->sk_state, hash,
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
169
  			   epb->bind_addr.port,
a7cb5a49b   Eric W. Biederman   userns: Print out...
170
171
  			   from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
  			   sock_i_ino(sk));
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
172
173
174
175
  
  		sctp_seq_dump_local_addrs(seq, epb);
  		seq_printf(seq, "
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
176
  	}
c0a4c2d1c   Xin Long   sctp: use read_lo...
177
  	read_unlock_bh(&head->lock);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
178
179
180
  
  	return 0;
  }
56b3d975b   Philippe De Muyter   [NET]: Make all i...
181
  static const struct seq_operations sctp_eps_ops = {
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
182
183
184
185
186
  	.start = sctp_eps_seq_start,
  	.next  = sctp_eps_seq_next,
  	.stop  = sctp_eps_seq_stop,
  	.show  = sctp_eps_seq_show,
  };
39f66a7dc   Xin Long   sctp: apply rhash...
187
188
189
190
  struct sctp_ht_iter {
  	struct seq_net_private p;
  	struct rhashtable_iter hti;
  };
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
191

b5e2f4e69   Xin Long   sctp: merge the s...
192
  static void *sctp_transport_seq_start(struct seq_file *seq, loff_t *pos)
39f66a7dc   Xin Long   sctp: apply rhash...
193
  {
626d16f50   Xin Long   sctp: export some...
194
  	struct sctp_ht_iter *iter = seq->private;
39f66a7dc   Xin Long   sctp: apply rhash...
195

97a6ec4ac   Tom Herbert   rhashtable: Chang...
196
  	sctp_transport_walk_start(&iter->hti);
39f66a7dc   Xin Long   sctp: apply rhash...
197

626d16f50   Xin Long   sctp: export some...
198
  	return sctp_transport_get_idx(seq_file_net(seq), &iter->hti, *pos);
39f66a7dc   Xin Long   sctp: apply rhash...
199
  }
b5e2f4e69   Xin Long   sctp: merge the s...
200
  static void sctp_transport_seq_stop(struct seq_file *seq, void *v)
39f66a7dc   Xin Long   sctp: apply rhash...
201
  {
626d16f50   Xin Long   sctp: export some...
202
203
204
  	struct sctp_ht_iter *iter = seq->private;
  
  	sctp_transport_walk_stop(&iter->hti);
39f66a7dc   Xin Long   sctp: apply rhash...
205
  }
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
206

b5e2f4e69   Xin Long   sctp: merge the s...
207
  static void *sctp_transport_seq_next(struct seq_file *seq, void *v, loff_t *pos)
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
208
  {
626d16f50   Xin Long   sctp: export some...
209
  	struct sctp_ht_iter *iter = seq->private;
39f66a7dc   Xin Long   sctp: apply rhash...
210
  	++*pos;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
211

626d16f50   Xin Long   sctp: export some...
212
  	return sctp_transport_get_next(seq_file_net(seq), &iter->hti);
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
213
  }
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
214
215
216
  /* Display sctp associations (/proc/net/sctp/assocs). */
  static int sctp_assocs_seq_show(struct seq_file *seq, void *v)
  {
39f66a7dc   Xin Long   sctp: apply rhash...
217
  	struct sctp_transport *transport;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
218
  	struct sctp_association *assoc;
39f66a7dc   Xin Long   sctp: apply rhash...
219
  	struct sctp_ep_common *epb;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
220
  	struct sock *sk;
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
221

39f66a7dc   Xin Long   sctp: apply rhash...
222
223
224
225
226
227
228
229
  	if (v == SEQ_START_TOKEN) {
  		seq_printf(seq, " ASSOC     SOCK   STY SST ST HBKT "
  				"ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT "
  				"RPORT LADDRS <-> RADDRS "
  				"HBINT INS OUTS MAXRT T1X T2X RTXC "
  				"wmema wmemq sndbuf rcvbuf
  ");
  		return 0;
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
230
  	}
39f66a7dc   Xin Long   sctp: apply rhash...
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
  
  	transport = (struct sctp_transport *)v;
  	assoc = transport->asoc;
  	epb = &assoc->base;
  	sk = epb->sk;
  
  	seq_printf(seq,
  		   "%8pK %8pK %-3d %-3d %-2d %-4d "
  		   "%4d %8d %8d %7u %5lu %-5d %5d ",
  		   assoc, sk, sctp_sk(sk)->type, sk->sk_state,
  		   assoc->state, 0,
  		   assoc->assoc_id,
  		   assoc->sndbuf_used,
  		   atomic_read(&assoc->rmem_alloc),
  		   from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
  		   sock_i_ino(sk),
  		   epb->bind_addr.port,
  		   assoc->peer.port);
  	seq_printf(seq, " ");
  	sctp_seq_dump_local_addrs(seq, epb);
  	seq_printf(seq, "<-> ");
  	sctp_seq_dump_remote_addrs(seq, assoc);
  	seq_printf(seq, "\t%8lu %5d %5d %4d %4d %4d %8d "
  		   "%8d %8d %8d %8d",
cee360ab4   Xin Long   sctp: define the ...
255
256
  		assoc->hbinterval, assoc->stream.incnt,
  		assoc->stream.outcnt, assoc->max_retrans,
39f66a7dc   Xin Long   sctp: apply rhash...
257
258
  		assoc->init_retries, assoc->shutdown_retries,
  		assoc->rtx_data_chunks,
14afee4b6   Reshetova, Elena   net: convert sock...
259
  		refcount_read(&sk->sk_wmem_alloc),
39f66a7dc   Xin Long   sctp: apply rhash...
260
261
262
263
264
  		sk->sk_wmem_queued,
  		sk->sk_sndbuf,
  		sk->sk_rcvbuf);
  	seq_printf(seq, "
  ");
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
265

fba4c330c   Xin Long   sctp: hold transp...
266
  	sctp_transport_put(transport);
1da177e4c   Linus Torvalds   Linux-2.6.12-rc2
267
268
  	return 0;
  }
56b3d975b   Philippe De Muyter   [NET]: Make all i...
269
  static const struct seq_operations sctp_assoc_ops = {
b5e2f4e69   Xin Long   sctp: merge the s...
270
271
272
  	.start = sctp_transport_seq_start,
  	.next  = sctp_transport_seq_next,
  	.stop  = sctp_transport_seq_stop,
bca735bd0   Vladislav Yasevich   [SCTP] Extend the...
273
274
  	.show  = sctp_assocs_seq_show,
  };
20c2c1fd6   Neil Horman   sctp: add sctp/re...
275
276
  static int sctp_remaddr_seq_show(struct seq_file *seq, void *v)
  {
20c2c1fd6   Neil Horman   sctp: add sctp/re...
277
  	struct sctp_association *assoc;
3d73e8fac   Xin Long   sctp: sctp_remadd...
278
  	struct sctp_transport *transport, *tsp;
20c2c1fd6   Neil Horman   sctp: add sctp/re...
279

39f66a7dc   Xin Long   sctp: apply rhash...
280
281
282
283
284
285
  	if (v == SEQ_START_TOKEN) {
  		seq_printf(seq, "ADDR ASSOC_ID HB_ACT RTO MAX_PATH_RTX "
  				"REM_ADDR_RTX START STATE
  ");
  		return 0;
  	}
20c2c1fd6   Neil Horman   sctp: add sctp/re...
286

3d73e8fac   Xin Long   sctp: sctp_remadd...
287
  	transport = (struct sctp_transport *)v;
3d73e8fac   Xin Long   sctp: sctp_remadd...
288
  	assoc = transport->asoc;
39f66a7dc   Xin Long   sctp: apply rhash...
289
290
291
  
  	list_for_each_entry_rcu(tsp, &assoc->peer.transport_addr_list,
  				transports) {
39f66a7dc   Xin Long   sctp: apply rhash...
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
  		/*
  		 * 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
  		 */
  		seq_puts(seq, "0 ");
  
  		/*
  		 * remote address start time (START).  This is also not
  		 * currently implemented, but we can record it with a
  		 * jiffies marker in a subsequent patch
  		 */
  		seq_puts(seq, "0 ");
  
  		/*
  		 * The current state of this destination. I.e.
  		 * SCTP_ACTIVE, SCTP_INACTIVE, ...
  		 */
  		seq_printf(seq, "%d", tsp->state);
45122ca26   Thomas Graf   sctp: Add RCU pro...
337

39f66a7dc   Xin Long   sctp: apply rhash...
338
339
  		seq_printf(seq, "
  ");
20c2c1fd6   Neil Horman   sctp: add sctp/re...
340
  	}
3d73e8fac   Xin Long   sctp: sctp_remadd...
341
  	sctp_transport_put(transport);
fba4c330c   Xin Long   sctp: hold transp...
342

20c2c1fd6   Neil Horman   sctp: add sctp/re...
343
  	return 0;
20c2c1fd6   Neil Horman   sctp: add sctp/re...
344
345
346
  }
  
  static const struct seq_operations sctp_remaddr_ops = {
b5e2f4e69   Xin Long   sctp: merge the s...
347
348
349
  	.start = sctp_transport_seq_start,
  	.next  = sctp_transport_seq_next,
  	.stop  = sctp_transport_seq_stop,
20c2c1fd6   Neil Horman   sctp: add sctp/re...
350
351
  	.show  = sctp_remaddr_seq_show,
  };
d47d08c8c   Al Viro   sctp: use proc_re...
352
353
  /* Set up the proc fs entry for the SCTP protocol. */
  int __net_init sctp_proc_init(struct net *net)
20c2c1fd6   Neil Horman   sctp: add sctp/re...
354
  {
d47d08c8c   Al Viro   sctp: use proc_re...
355
356
  	net->sctp.proc_net_sctp = proc_net_mkdir(net, "sctp", net->proc_net);
  	if (!net->sctp.proc_net_sctp)
20c2c1fd6   Neil Horman   sctp: add sctp/re...
357
  		return -ENOMEM;
3617d9496   Christoph Hellwig   proc: introduce p...
358
359
  	if (!proc_create_net_single("snmp", 0444, net->sctp.proc_net_sctp,
  			 sctp_snmp_seq_show, NULL))
d47d08c8c   Al Viro   sctp: use proc_re...
360
  		goto cleanup;
c35063722   Christoph Hellwig   proc: introduce p...
361
362
  	if (!proc_create_net("eps", 0444, net->sctp.proc_net_sctp,
  			&sctp_eps_ops, sizeof(struct seq_net_private)))
d47d08c8c   Al Viro   sctp: use proc_re...
363
  		goto cleanup;
c35063722   Christoph Hellwig   proc: introduce p...
364
365
  	if (!proc_create_net("assocs", 0444, net->sctp.proc_net_sctp,
  			&sctp_assoc_ops, sizeof(struct sctp_ht_iter)))
d47d08c8c   Al Viro   sctp: use proc_re...
366
  		goto cleanup;
c35063722   Christoph Hellwig   proc: introduce p...
367
368
  	if (!proc_create_net("remaddr", 0444, net->sctp.proc_net_sctp,
  			&sctp_remaddr_ops, sizeof(struct sctp_ht_iter)))
d47d08c8c   Al Viro   sctp: use proc_re...
369
  		goto cleanup;
20c2c1fd6   Neil Horman   sctp: add sctp/re...
370
  	return 0;
d47d08c8c   Al Viro   sctp: use proc_re...
371
372
373
374
375
  
  cleanup:
  	remove_proc_subtree("sctp", net->proc_net);
  	net->sctp.proc_net_sctp = NULL;
  	return -ENOMEM;
20c2c1fd6   Neil Horman   sctp: add sctp/re...
376
  }