Blame view
net/sctp/proc.c
11 KB
1da177e4c
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
/* SCTP kernel reference Implementation * Copyright (c) 2003 International Business Machines, Corp. * * This file is part of the SCTP kernel reference Implementation * * The SCTP reference implementation 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, or (at your option) * any later version. * * The SCTP reference implementation is distributed in the hope that it * 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 * along with GNU CC; see the file COPYING. If not, write to * the Free Software Foundation, 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. * * Please send any bug reports or fixes you make to the * email address(es): * lksctp developers <lksctp-developers@lists.sourceforge.net> * * Or submit a bug report through the following website: * http://www.sf.net/projects/lksctp * * Written or modified by: * Sridhar Samudrala <sri@us.ibm.com> * * Any bugs reported given to us we will try to fix... any fixes shared will * be incorporated into the next SCTP release. */ #include <linux/types.h> #include <linux/seq_file.h> #include <linux/init.h> #include <net/sctp/sctp.h> static struct snmp_mib sctp_snmp_list[] = { 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
|
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
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
|
75 |
SNMP_MIB_SENTINEL |
1da177e4c
|
76 77 78 79 |
}; /* Return the current value of a particular entry in the mib by adding its * per cpu counters. |
d808ad9ab
|
80 |
*/ |
1da177e4c
|
81 82 83 84 85 |
static unsigned long fold_field(void *mib[], int nr) { unsigned long res = 0; int i; |
6f9120422
|
86 |
for_each_possible_cpu(i) { |
1da177e4c
|
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
res += *((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) + sizeof (unsigned long) * nr)); res += *((unsigned long *) (((void *) per_cpu_ptr(mib[1], i)) + sizeof (unsigned long) * nr)); } return res; } /* Display sctp snmp mib statistics(/proc/net/sctp/snmp). */ static int sctp_snmp_seq_show(struct seq_file *seq, void *v) { int i; for (i = 0; sctp_snmp_list[i].name != NULL; i++) seq_printf(seq, "%-32s\t%ld ", sctp_snmp_list[i].name, |
d808ad9ab
|
105 |
fold_field((void **)sctp_statistics, |
1da177e4c
|
106 107 108 109 110 111 112 113 114 115 |
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) { return single_open(file, sctp_snmp_seq_show, NULL); } |
da7071d7e
|
116 |
static const struct file_operations sctp_snmp_seq_fops = { |
1da177e4c
|
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
.owner = THIS_MODULE, .open = sctp_snmp_seq_open, .read = seq_read, .llseek = seq_lseek, .release = single_release, }; /* Set up the proc fs entry for 'snmp' object. */ int __init sctp_snmp_proc_init(void) { struct proc_dir_entry *p; p = create_proc_entry("snmp", S_IRUGO, proc_net_sctp); if (!p) return -ENOMEM; p->proc_fops = &sctp_snmp_seq_fops; return 0; } /* Cleanup the proc fs entry for 'snmp' object. */ void sctp_snmp_proc_exit(void) { remove_proc_entry("snmp", proc_net_sctp); } /* Dump local addresses of an association/endpoint. */ static void sctp_seq_dump_local_addrs(struct seq_file *seq, struct sctp_ep_common *epb) { struct list_head *pos; |
bca735bd0
|
148 |
struct sctp_association *asoc; |
1da177e4c
|
149 |
struct sctp_sockaddr_entry *laddr; |
bca735bd0
|
150 151 |
struct sctp_transport *peer; union sctp_addr *addr, *primary = NULL; |
1da177e4c
|
152 |
struct sctp_af *af; |
bca735bd0
|
153 154 155 |
if (epb->type == SCTP_EP_TYPE_ASSOCIATION) { asoc = sctp_assoc(epb); peer = asoc->peer.primary_path; |
5f242a13e
|
156 |
primary = &peer->saddr; |
bca735bd0
|
157 |
} |
1da177e4c
|
158 159 |
list_for_each(pos, &epb->bind_addr.address_list) { laddr = list_entry(pos, struct sctp_sockaddr_entry, list); |
5f242a13e
|
160 |
addr = &laddr->a; |
1da177e4c
|
161 |
af = sctp_get_af_specific(addr->sa.sa_family); |
bca735bd0
|
162 163 164 |
if (primary && af->cmp_addr(addr, primary)) { seq_printf(seq, "*"); } |
5f242a13e
|
165 |
af->seq_dump_addr(seq, addr); |
1da177e4c
|
166 167 168 169 170 171 172 173 |
} } /* Dump remote addresses of an association. */ static void sctp_seq_dump_remote_addrs(struct seq_file *seq, struct sctp_association *assoc) { struct list_head *pos; struct sctp_transport *transport; |
bca735bd0
|
174 |
union sctp_addr *addr, *primary; |
1da177e4c
|
175 |
struct sctp_af *af; |
acd2bc96e
|
176 |
primary = &assoc->peer.primary_addr; |
1da177e4c
|
177 178 |
list_for_each(pos, &assoc->peer.transport_addr_list) { transport = list_entry(pos, struct sctp_transport, transports); |
5f242a13e
|
179 |
addr = &transport->ipaddr; |
1da177e4c
|
180 |
af = sctp_get_af_specific(addr->sa.sa_family); |
acd2bc96e
|
181 |
if (af->cmp_addr(addr, primary)) { |
bca735bd0
|
182 183 |
seq_printf(seq, "*"); } |
5f242a13e
|
184 |
af->seq_dump_addr(seq, addr); |
1da177e4c
|
185 186 |
} } |
bca735bd0
|
187 188 |
static void * sctp_eps_seq_start(struct seq_file *seq, loff_t *pos) { |
49392e5ec
|
189 |
if (*pos >= sctp_ep_hashsize) |
bca735bd0
|
190 191 192 193 194 195 196 197 |
return NULL; if (*pos < 0) *pos = 0; if (*pos == 0) seq_printf(seq, " ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS "); |
bca735bd0
|
198 199 200 201 202 203 204 205 206 207 208 |
return (void *)pos; } static void sctp_eps_seq_stop(struct seq_file *seq, void *v) { return; } static void * sctp_eps_seq_next(struct seq_file *seq, void *v, loff_t *pos) { |
49392e5ec
|
209 |
if (++*pos >= sctp_ep_hashsize) |
bca735bd0
|
210 |
return NULL; |
bca735bd0
|
211 212 |
return pos; } |
1da177e4c
|
213 214 215 216 217 218 219 |
/* 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
|
220 |
int hash = *(loff_t *)v; |
bca735bd0
|
221 |
|
49392e5ec
|
222 |
if (hash >= sctp_ep_hashsize) |
bca735bd0
|
223 |
return -ENOMEM; |
49392e5ec
|
224 |
head = &sctp_ep_hashtable[hash]; |
bca735bd0
|
225 226 227 228 229 230 |
sctp_local_bh_disable(); read_lock(&head->lock); for (epb = head->chain; epb; epb = epb->next) { ep = sctp_ep(epb); sk = epb->sk; seq_printf(seq, "%8p %8p %-3d %-3d %-4d %-5d %5d %5lu ", ep, sk, |
49392e5ec
|
231 |
sctp_sk(sk)->type, sk->sk_state, hash, |
bca735bd0
|
232 233 234 235 236 237 |
epb->bind_addr.port, sock_i_uid(sk), sock_i_ino(sk)); sctp_seq_dump_local_addrs(seq, epb); seq_printf(seq, " "); |
1da177e4c
|
238 |
} |
bca735bd0
|
239 240 |
read_unlock(&head->lock); sctp_local_bh_enable(); |
1da177e4c
|
241 242 243 |
return 0; } |
56b3d975b
|
244 |
static const struct seq_operations sctp_eps_ops = { |
bca735bd0
|
245 246 247 248 249 |
.start = sctp_eps_seq_start, .next = sctp_eps_seq_next, .stop = sctp_eps_seq_stop, .show = sctp_eps_seq_show, }; |
1da177e4c
|
250 251 252 |
/* Initialize the seq file operations for 'eps' object. */ static int sctp_eps_seq_open(struct inode *inode, struct file *file) { |
bca735bd0
|
253 |
return seq_open(file, &sctp_eps_ops); |
1da177e4c
|
254 |
} |
da7071d7e
|
255 |
static const struct file_operations sctp_eps_seq_fops = { |
1da177e4c
|
256 257 258 |
.open = sctp_eps_seq_open, .read = seq_read, .llseek = seq_lseek, |
bca735bd0
|
259 |
.release = seq_release, |
1da177e4c
|
260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 |
}; /* Set up the proc fs entry for 'eps' object. */ int __init sctp_eps_proc_init(void) { struct proc_dir_entry *p; p = create_proc_entry("eps", S_IRUGO, proc_net_sctp); if (!p) return -ENOMEM; p->proc_fops = &sctp_eps_seq_fops; return 0; } /* Cleanup the proc fs entry for 'eps' object. */ void sctp_eps_proc_exit(void) { remove_proc_entry("eps", proc_net_sctp); } |
bca735bd0
|
281 282 283 |
static void * sctp_assocs_seq_start(struct seq_file *seq, loff_t *pos) { |
49392e5ec
|
284 |
if (*pos >= sctp_assoc_hashsize) |
bca735bd0
|
285 286 287 288 289 290 291 292 293 |
return NULL; if (*pos < 0) *pos = 0; if (*pos == 0) seq_printf(seq, " ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT " "RPORT LADDRS <-> RADDRS "); |
bca735bd0
|
294 295 296 297 298 299 300 301 302 303 304 |
return (void *)pos; } static void sctp_assocs_seq_stop(struct seq_file *seq, void *v) { return; } static void * sctp_assocs_seq_next(struct seq_file *seq, void *v, loff_t *pos) { |
49392e5ec
|
305 |
if (++*pos >= sctp_assoc_hashsize) |
bca735bd0
|
306 |
return NULL; |
bca735bd0
|
307 308 |
return pos; } |
1da177e4c
|
309 310 311 312 313 314 315 |
/* 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; |
38b0e42ab
|
316 |
int hash = *(loff_t *)v; |
bca735bd0
|
317 |
|
49392e5ec
|
318 |
if (hash >= sctp_assoc_hashsize) |
bca735bd0
|
319 |
return -ENOMEM; |
49392e5ec
|
320 |
head = &sctp_assoc_hashtable[hash]; |
bca735bd0
|
321 322 323 324 325 326 327 328 |
sctp_local_bh_disable(); read_lock(&head->lock); for (epb = head->chain; epb; epb = epb->next) { assoc = sctp_assoc(epb); sk = epb->sk; seq_printf(seq, "%8p %8p %-3d %-3d %-2d %-4d %4d %8d %8d %7d %5lu %-5d %5d ", assoc, sk, sctp_sk(sk)->type, sk->sk_state, |
49392e5ec
|
329 |
assoc->state, hash, assoc->assoc_id, |
bca735bd0
|
330 |
assoc->sndbuf_used, |
6aa2551cf
|
331 |
atomic_read(&assoc->rmem_alloc), |
bca735bd0
|
332 333 334 335 336 337 338 339 340 341 |
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, " "); |
1da177e4c
|
342 |
} |
bca735bd0
|
343 344 |
read_unlock(&head->lock); sctp_local_bh_enable(); |
1da177e4c
|
345 346 347 |
return 0; } |
56b3d975b
|
348 |
static const struct seq_operations sctp_assoc_ops = { |
bca735bd0
|
349 350 351 352 353 |
.start = sctp_assocs_seq_start, .next = sctp_assocs_seq_next, .stop = sctp_assocs_seq_stop, .show = sctp_assocs_seq_show, }; |
1da177e4c
|
354 355 356 |
/* Initialize the seq file operations for 'assocs' object. */ static int sctp_assocs_seq_open(struct inode *inode, struct file *file) { |
bca735bd0
|
357 |
return seq_open(file, &sctp_assoc_ops); |
1da177e4c
|
358 |
} |
da7071d7e
|
359 |
static const struct file_operations sctp_assocs_seq_fops = { |
1da177e4c
|
360 361 362 |
.open = sctp_assocs_seq_open, .read = seq_read, .llseek = seq_lseek, |
bca735bd0
|
363 |
.release = seq_release, |
1da177e4c
|
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 |
}; /* Set up the proc fs entry for 'assocs' object. */ int __init sctp_assocs_proc_init(void) { struct proc_dir_entry *p; p = create_proc_entry("assocs", S_IRUGO, proc_net_sctp); if (!p) return -ENOMEM; p->proc_fops = &sctp_assocs_seq_fops; return 0; } /* Cleanup the proc fs entry for 'assocs' object. */ void sctp_assocs_proc_exit(void) { remove_proc_entry("assocs", proc_net_sctp); } |