xref: /freebsd/usr.bin/netstat/sctp.c (revision e28a4053)
1 /*-
2  * Copyright (c) 2001-2007, by Weongyo Jeong. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are met:
6  *
7  * a) Redistributions of source code must retain the above copyright notice,
8  *   this list of conditions and the following disclaimer.
9  *
10  * b) Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in
12  *   the documentation and/or other materials provided with the distribution.
13  *
14  * c) Neither the name of Cisco Systems, Inc. nor the names of its
15  *    contributors may be used to endorse or promote products derived
16  *    from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
20  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
28  * THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 #if 0
32 #ifndef lint
33 static char sccsid[] = "@(#)sctp.c	0.1 (Berkeley) 4/18/2007";
34 #endif /* not lint */
35 #endif
36 
37 #include <sys/cdefs.h>
38 __FBSDID("$FreeBSD$");
39 
40 #include <sys/param.h>
41 #include <sys/queue.h>
42 #include <sys/types.h>
43 #include <sys/socket.h>
44 #include <sys/socketvar.h>
45 #include <sys/sysctl.h>
46 #include <sys/protosw.h>
47 
48 #include <netinet/in.h>
49 #include <netinet/sctp.h>
50 #include <netinet/sctp_constants.h>
51 #include <arpa/inet.h>
52 
53 #include <err.h>
54 #include <errno.h>
55 #include <libutil.h>
56 #include <netdb.h>
57 #include <stdint.h>
58 #include <stdio.h>
59 #include <stdlib.h>
60 #include <string.h>
61 #include <unistd.h>
62 #include "netstat.h"
63 
64 #ifdef SCTP
65 
66 void	inetprint(struct in_addr *, int, const char *, int);
67 static void sctp_statesprint(uint32_t state);
68 
69 #define	NETSTAT_SCTP_STATES_CLOSED		0x0
70 #define	NETSTAT_SCTP_STATES_BOUND		0x1
71 #define	NETSTAT_SCTP_STATES_LISTEN		0x2
72 #define	NETSTAT_SCTP_STATES_COOKIE_WAIT		0x3
73 #define	NETSTAT_SCTP_STATES_COOKIE_ECHOED	0x4
74 #define	NETSTAT_SCTP_STATES_ESTABLISHED		0x5
75 #define	NETSTAT_SCTP_STATES_SHUTDOWN_SENT	0x6
76 #define	NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED	0x7
77 #define	NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT	0x8
78 #define	NETSTAT_SCTP_STATES_SHUTDOWN_PENDING	0x9
79 
80 char *sctpstates[] = {
81 	"CLOSED",
82 	"BOUND",
83 	"LISTEN",
84 	"COOKIE_WAIT",
85 	"COOKIE_ECHOED",
86 	"ESTABLISHED",
87 	"SHUTDOWN_SENT",
88 	"SHUTDOWN_RECEIVED",
89 	"SHUTDOWN_ACK_SENT",
90 	"SHUTDOWN_PENDING"
91 };
92 
93 LIST_HEAD(xladdr_list, xladdr_entry) xladdr_head;
94 struct xladdr_entry {
95 	struct xsctp_laddr *xladdr;
96 	LIST_ENTRY(xladdr_entry) xladdr_entries;
97 };
98 
99 LIST_HEAD(xraddr_list, xraddr_entry) xraddr_head;
100 struct xraddr_entry {
101         struct xsctp_raddr *xraddr;
102         LIST_ENTRY(xraddr_entry) xraddr_entries;
103 };
104 
105 static int
106 sctp_skip_xinpcb_ifneed(char *buf, const size_t buflen, size_t *offset)
107 {
108 	int exist_tcb = 0;
109 	struct xsctp_tcb *xstcb;
110 	struct xsctp_raddr *xraddr;
111 	struct xsctp_laddr *xladdr;
112 
113 	while (*offset < buflen) {
114 		xladdr = (struct xsctp_laddr *)(buf + *offset);
115 		*offset += sizeof(struct xsctp_laddr);
116 		if (xladdr->last == 1)
117 			break;
118 	}
119 
120 	while (*offset < buflen) {
121 		xstcb = (struct xsctp_tcb *)(buf + *offset);
122 		*offset += sizeof(struct xsctp_tcb);
123 		if (xstcb->last == 1)
124 			break;
125 
126 		exist_tcb = 1;
127 
128 		while (*offset < buflen) {
129 			xladdr = (struct xsctp_laddr *)(buf + *offset);
130 			*offset += sizeof(struct xsctp_laddr);
131 			if (xladdr->last == 1)
132 				break;
133 		}
134 
135 		while (*offset < buflen) {
136 			xraddr = (struct xsctp_raddr *)(buf + *offset);
137 			*offset += sizeof(struct xsctp_raddr);
138 			if (xraddr->last == 1)
139 				break;
140 		}
141 	}
142 
143 	/*
144 	 * If Lflag is set, we don't care about the return value.
145 	 */
146 	if (Lflag)
147 		return 0;
148 
149 	return exist_tcb;
150 }
151 
152 static void
153 sctp_process_tcb(struct xsctp_tcb *xstcb, const char *name,
154     char *buf, const size_t buflen, size_t *offset, int *indent)
155 {
156 	int i, xl_total = 0, xr_total = 0, x_max;
157 	struct sockaddr *sa;
158 	struct xsctp_raddr *xraddr;
159 	struct xsctp_laddr *xladdr;
160 	struct xladdr_entry *prev_xl = NULL, *xl = NULL, *xl_tmp;
161 	struct xraddr_entry *prev_xr = NULL, *xr = NULL, *xr_tmp;
162 #ifdef INET6
163 	struct sockaddr_in6 *in6;
164 #endif
165 
166 	LIST_INIT(&xladdr_head);
167 	LIST_INIT(&xraddr_head);
168 
169 	/*
170 	 * Make `struct xladdr_list' list and `struct xraddr_list' list
171 	 * to handle the address flexibly.
172 	 */
173 	while (*offset < buflen) {
174 		xladdr = (struct xsctp_laddr *)(buf + *offset);
175 		*offset += sizeof(struct xsctp_laddr);
176 		if (xladdr->last == 1)
177 			break;
178 
179 		prev_xl = xl;
180 		xl = malloc(sizeof(struct xladdr_entry));
181 		if (xl == NULL) {
182 			warnx("malloc %lu bytes",
183 			    (u_long)sizeof(struct xladdr_entry));
184 			goto out;
185 		}
186 		xl->xladdr = xladdr;
187 		if (prev_xl == NULL)
188 			LIST_INSERT_HEAD(&xladdr_head, xl, xladdr_entries);
189 		else
190 			LIST_INSERT_AFTER(prev_xl, xl, xladdr_entries);
191 		xl_total++;
192 	}
193 
194 	while (*offset < buflen) {
195 		xraddr = (struct xsctp_raddr *)(buf + *offset);
196 		*offset += sizeof(struct xsctp_raddr);
197 		if (xraddr->last == 1)
198 			break;
199 
200 		prev_xr = xr;
201 		xr = malloc(sizeof(struct xraddr_entry));
202 		if (xr == NULL) {
203 			warnx("malloc %lu bytes",
204 			    (u_long)sizeof(struct xraddr_entry));
205 			goto out;
206 		}
207 		xr->xraddr = xraddr;
208 		if (prev_xr == NULL)
209 			LIST_INSERT_HEAD(&xraddr_head, xr, xraddr_entries);
210 		else
211 			LIST_INSERT_AFTER(prev_xr, xr, xraddr_entries);
212 		xr_total++;
213 	}
214 
215 	/*
216 	 * Let's print the address infos.
217 	 */
218 	xl = LIST_FIRST(&xladdr_head);
219 	xr = LIST_FIRST(&xraddr_head);
220 	x_max = (xl_total > xr_total) ? xl_total : xr_total;
221 	for (i = 0; i < x_max; i++) {
222 		if (((*indent == 0) && i > 0) || *indent > 0)
223 			printf("%-11s ", " ");
224 
225 		if (xl != NULL) {
226 			sa = &(xl->xladdr->address.sa);
227 			if ((sa->sa_family) == AF_INET)
228 				inetprint(&((struct sockaddr_in *)sa)->sin_addr,
229 				    htons(xstcb->local_port),
230 				    name, numeric_port);
231 #ifdef INET6
232 			else {
233 				in6 = (struct sockaddr_in6 *)sa;
234 				inet6print(&in6->sin6_addr,
235 				    htons(xstcb->local_port),
236 				    name, numeric_port);
237 			}
238 #endif
239 		}
240 
241 		if (xr != NULL && !Lflag) {
242 			sa = &(xr->xraddr->address.sa);
243 			if ((sa->sa_family) == AF_INET)
244 				inetprint(&((struct sockaddr_in *)sa)->sin_addr,
245 				    htons(xstcb->remote_port),
246 				    name, numeric_port);
247 #ifdef INET6
248 			else {
249 				in6 = (struct sockaddr_in6 *)sa;
250 				inet6print(&in6->sin6_addr,
251 				    htons(xstcb->remote_port),
252 				    name, numeric_port);
253 			}
254 #endif
255 		}
256 
257 		if (xl != NULL)
258 			xl = LIST_NEXT(xl, xladdr_entries);
259 		if (xr != NULL)
260 			xr = LIST_NEXT(xr, xraddr_entries);
261 
262 		if (i == 0 && !Lflag)
263 			sctp_statesprint(xstcb->state);
264 
265 		if (i < x_max)
266 			putchar('\n');
267 	}
268 
269 out:
270 	/*
271 	 * Free the list which be used to handle the address.
272 	 */
273 	xl = LIST_FIRST(&xladdr_head);
274 	while (xl != NULL) {
275 		xl_tmp = LIST_NEXT(xl, xladdr_entries);
276 		free(xl);
277 		xl = xl_tmp;
278 	}
279 
280 	xr = LIST_FIRST(&xraddr_head);
281 	while (xr != NULL) {
282 		xr_tmp = LIST_NEXT(xr, xraddr_entries);
283 		free(xr);
284 		xr = xr_tmp;
285 	}
286 }
287 
288 #ifdef SCTP_DEBUG
289 uint32_t sctp_pdup[64];
290 int sctp_pcnt = 0;
291 #endif
292 
293 static void
294 sctp_process_inpcb(struct xsctp_inpcb *xinpcb, const char *name,
295     char *buf, const size_t buflen, size_t *offset)
296 {
297 	int offset_backup, indent = 0, xladdr_total = 0, is_listening = 0;
298 	static int first = 1;
299 	char *tname;
300 	struct xsctp_tcb *xstcb;
301 	struct xsctp_laddr *xladdr;
302 	struct sockaddr *sa;
303 #ifdef INET6
304 	struct sockaddr_in6 *in6;
305 #endif
306 
307 	if ((xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE) ==
308 	    SCTP_PCB_FLAGS_TCPTYPE && xinpcb->maxqlen > 0)
309 		is_listening = 1;
310 
311 	if (!Lflag && !is_listening &&
312 	    !(xinpcb->flags & SCTP_PCB_FLAGS_CONNECTED)) {
313 #ifdef SCTP_DEBUG
314 		int i, found = 0;
315 
316 		for (i = 0; i < sctp_pcnt; i++) {
317 			if (sctp_pdup[i] == xinpcb->flags) {
318 				found = 1;
319 				break;
320 			}
321 		}
322 		if (!found) {
323 			sctp_pdup[sctp_pcnt++] = xinpcb->flags;
324 			if (sctp_pcnt >= 64)
325 				sctp_pcnt = 0;
326 			printf("[0x%08x]", xinpcb->flags);
327 		}
328 #endif
329 		offset_backup = *offset;
330 		if (!sctp_skip_xinpcb_ifneed(buf, buflen, offset))
331 			return;
332 		*offset = offset_backup;
333 	}
334 
335 	if (first) {
336 		if (!Lflag) {
337 			printf("Active SCTP associations");
338 			if (aflag)
339 				printf(" (including servers)");
340 		} else
341 			printf("Current listen queue sizes (qlen/maxqlen)");
342 		putchar('\n');
343 		if (Aflag)
344 			printf("%-8.8s ", "Socket");
345 		if (Lflag)
346 			printf("%-5.5s %-5.5s %-8.8s %-22.22s\n",
347 			    "Proto", "Type", "Listen", "Local Address");
348 		else
349 			printf((Aflag && !Wflag) ?
350 			    "%-5.5s %-5.5s %-18.18s %-18.18s %s\n" :
351 			    "%-5.5s %-5.5s %-22.22s %-22.22s %s\n",
352 			    "Proto", "Type",
353 			    "Local Address", "Foreign Address",
354 			    "(state)");
355 		first = 0;
356 	}
357 	if (Lflag && xinpcb->maxqlen == 0) {
358 		sctp_skip_xinpcb_ifneed(buf, buflen, offset);
359 		return;
360 	}
361 	if (Aflag)
362 		printf("%8lx ", (u_long)xinpcb);
363 
364 	printf("%-5.5s ", name);
365 
366 	if (xinpcb->flags & SCTP_PCB_FLAGS_TCPTYPE)
367 		tname = "1to1";
368 	else if (xinpcb->flags & SCTP_PCB_FLAGS_UDPTYPE)
369 		tname = "1toN";
370 	else
371 		return;
372 
373 	printf("%-5.5s ", tname);
374 
375 	if (Lflag) {
376 		char buf1[9];
377 
378 		snprintf(buf1, 9, "%hu/%hu", xinpcb->qlen, xinpcb->maxqlen);
379 		printf("%-8.8s ", buf1);
380 	}
381 	/*
382 	 * process the local address.  This routine are used for Lflag.
383 	 */
384 	while (*offset < buflen) {
385 		xladdr = (struct xsctp_laddr *)(buf + *offset);
386 		*offset += sizeof(struct xsctp_laddr);
387 		if (xladdr->last == 1)
388 			break;
389 
390 		if (!Lflag && !is_listening)
391 			continue;
392 
393 		if (xladdr_total != 0)
394 			putchar('\n');
395 		if (xladdr_total > 0)
396 			printf((Lflag) ?
397 			    "%-20.20s " : "%-11.11s ", " ");
398 
399 		sa = &(xladdr->address.sa);
400 		if ((sa->sa_family) == AF_INET)
401 			inetprint(&((struct sockaddr_in *)sa)->sin_addr,
402 			    htons(xinpcb->local_port), name, numeric_port);
403 #ifdef INET6
404 		else {
405 			in6 = (struct sockaddr_in6 *)sa;
406 			inet6print(&in6->sin6_addr,
407 			    htons(xinpcb->local_port), name, numeric_port);
408 		}
409 #endif
410 
411 		if (!Lflag && xladdr_total == 0 && is_listening == 1)
412 			printf("%-22.22s LISTEN", " ");
413 
414 		xladdr_total++;
415 	}
416 
417 	xstcb = (struct xsctp_tcb *)(buf + *offset);
418 	*offset += sizeof(struct xsctp_tcb);
419 	while (xstcb->last == 0 && *offset < buflen) {
420 		sctp_process_tcb(xstcb, name, buf, buflen, offset, &indent);
421 		indent++;
422 		xstcb = (struct xsctp_tcb *)(buf + *offset);
423 		*offset += sizeof(struct xsctp_tcb);
424 	}
425 
426 	putchar('\n');
427 }
428 
429 /*
430  * Print a summary of SCTP connections related to an Internet
431  * protocol.
432  */
433 void
434 sctp_protopr(u_long off __unused,
435     const char *name, int af1, int proto)
436 {
437 	char *buf;
438 	const char *mibvar = "net.inet.sctp.assoclist";
439 	size_t offset = 0;
440 	size_t len = 0;
441 	struct xsctp_inpcb *xinpcb;
442 
443 	if (proto != IPPROTO_SCTP)
444 		return;
445 
446 	if (sysctlbyname(mibvar, 0, &len, 0, 0) < 0) {
447 		if (errno != ENOENT)
448 			warn("sysctl: %s", mibvar);
449 		return;
450 	}
451 	if ((buf = malloc(len)) == 0) {
452 		warnx("malloc %lu bytes", (u_long)len);
453 		return;
454 	}
455 	if (sysctlbyname(mibvar, buf, &len, 0, 0) < 0) {
456 		warn("sysctl: %s", mibvar);
457 		free(buf);
458 		return;
459 	}
460 
461 	xinpcb = (struct xsctp_inpcb *)(buf + offset);
462 	offset += sizeof(struct xsctp_inpcb);
463 	while (xinpcb->last == 0 && offset < len) {
464 		sctp_process_inpcb(xinpcb, name, buf, (const size_t)len,
465 		    &offset);
466 
467 		xinpcb = (struct xsctp_inpcb *)(buf + offset);
468 		offset += sizeof(struct xsctp_inpcb);
469 	}
470 
471 	free(buf);
472 }
473 
474 static void
475 sctp_statesprint(uint32_t state)
476 {
477 	int idx;
478 
479 	switch (state) {
480 	case SCTP_STATE_COOKIE_WAIT:
481 		idx = NETSTAT_SCTP_STATES_COOKIE_WAIT;
482 		break;
483 	case SCTP_STATE_COOKIE_ECHOED:
484 		idx = NETSTAT_SCTP_STATES_COOKIE_ECHOED;
485 		break;
486 	case SCTP_STATE_OPEN:
487 		idx = NETSTAT_SCTP_STATES_ESTABLISHED;
488 		break;
489 	case SCTP_STATE_SHUTDOWN_SENT:
490 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_SENT;
491 		break;
492 	case SCTP_STATE_SHUTDOWN_RECEIVED:
493 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_RECEIVED;
494 		break;
495 	case SCTP_STATE_SHUTDOWN_ACK_SENT:
496 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_ACK_SENT;
497 		break;
498 	case SCTP_STATE_SHUTDOWN_PENDING:
499 		idx = NETSTAT_SCTP_STATES_SHUTDOWN_PENDING;
500 		break;
501 	default:
502 		printf("UNKNOWN 0x%08x", state);
503 		return;
504 	}
505 
506 	printf("%s", sctpstates[idx]);
507 }
508 
509 /*
510  * Dump SCTP statistics structure.
511  */
512 void
513 sctp_stats(u_long off, const char *name, int af1 __unused, int proto __unused)
514 {
515 	struct sctpstat sctpstat, zerostat;
516 	size_t len = sizeof(sctpstat);
517 
518 	if (live) {
519 		if (zflag)
520 			memset(&zerostat, 0, len);
521 		if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
522 		    zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
523 			warn("sysctl: net.inet.sctp.stats");
524 			return;
525 		}
526 	} else
527 		kread(off, &sctpstat, len);
528 
529 	printf ("%s:\n", name);
530 
531 #define	p(f, m) if (sctpstat.f || sflag <= 1) \
532     printf(m, (uintmax_t)sctpstat.f, plural(sctpstat.f))
533 #define	p1a(f, m) if (sctpstat.f || sflag <= 1) \
534     printf(m, (uintmax_t)sctpstat.f)
535 
536 	/*
537 	 * input statistics
538 	 */
539 	p(sctps_recvpackets, "\t%ju input packet%s\n");
540 	p(sctps_recvdatagrams, "\t\t%ju datagram%s\n");
541 	p(sctps_recvpktwithdata, "\t\t%ju packet%s that had data\n");
542 	p(sctps_recvsacks, "\t\t%ju input SACK chunk%s\n");
543 	p(sctps_recvdata, "\t\t%ju input DATA chunk%s\n");
544 	p(sctps_recvdupdata, "\t\t%ju duplicate DATA chunk%s\n");
545 	p(sctps_recvheartbeat, "\t\t%ju input HB chunk%s\n");
546 	p(sctps_recvheartbeatack, "\t\t%ju HB-ACK chunk%s\n");
547 	p(sctps_recvecne, "\t\t%ju input ECNE chunk%s\n");
548 	p(sctps_recvauth, "\t\t%ju input AUTH chunk%s\n");
549 	p(sctps_recvauthmissing, "\t\t%ju chunk%s missing AUTH\n");
550 	p(sctps_recvivalhmacid, "\t\t%ju invalid HMAC id%s received\n");
551 	p(sctps_recvivalkeyid, "\t\t%ju invalid secret id%s received\n");
552 	p1a(sctps_recvauthfailed, "\t\t%ju auth failed\n");
553 	p1a(sctps_recvexpress, "\t\t%ju fast path receives all one chunk\n");
554 	p1a(sctps_recvexpressm, "\t\t%ju fast path multi-part data\n");
555 
556 	/*
557 	 * output statistics
558 	 */
559 	p(sctps_sendpackets, "\t%ju output packet%s\n");
560 	p(sctps_sendsacks, "\t\t%ju output SACK%s\n");
561 	p(sctps_senddata, "\t\t%ju output DATA chunk%s\n");
562 	p(sctps_sendretransdata, "\t\t%ju retransmitted DATA chunk%s\n");
563 	p(sctps_sendfastretrans, "\t\t%ju fast retransmitted DATA chunk%s\n");
564 	p(sctps_sendmultfastretrans, "\t\t%ju FR'%s that happened more "
565 	    "than once to same chunk\n");
566 	p(sctps_sendheartbeat, "\t\t%ju intput HB chunk%s\n");
567 	p(sctps_sendecne, "\t\t%ju output ECNE chunk%s\n");
568 	p(sctps_sendauth, "\t\t%ju output AUTH chunk%s\n");
569 	p1a(sctps_senderrors, "\t\t%ju ip_output error counter\n");
570 
571 	/*
572 	 * PCKDROPREP statistics
573 	 */
574 	printf("\tPacket drop statistics:\n");
575 	p1a(sctps_pdrpfmbox, "\t\t%ju from middle box\n");
576 	p1a(sctps_pdrpfehos, "\t\t%ju from end host\n");
577 	p1a(sctps_pdrpmbda, "\t\t%ju with data\n");
578 	p1a(sctps_pdrpmbct, "\t\t%ju non-data, non-endhost\n");
579 	p1a(sctps_pdrpbwrpt, "\t\t%ju non-endhost, bandwidth rep only\n");
580 	p1a(sctps_pdrpcrupt, "\t\t%ju not enough for chunk header\n");
581 	p1a(sctps_pdrpnedat, "\t\t%ju not enough data to confirm\n");
582 	p1a(sctps_pdrppdbrk, "\t\t%ju where process_chunk_drop said break\n");
583 	p1a(sctps_pdrptsnnf, "\t\t%ju failed to find TSN\n");
584 	p1a(sctps_pdrpdnfnd, "\t\t%ju attempt reverse TSN lookup\n");
585 	p1a(sctps_pdrpdiwnp, "\t\t%ju e-host confirms zero-rwnd\n");
586 	p1a(sctps_pdrpdizrw, "\t\t%ju midbox confirms no space\n");
587 	p1a(sctps_pdrpbadd, "\t\t%ju data did not match TSN\n");
588 	p(sctps_pdrpmark, "\t\t%ju TSN'%s marked for Fast Retran\n");
589 
590 	/*
591 	 * Timeouts
592 	 */
593 	printf("\tTimeouts:\n");
594 	p(sctps_timoiterator, "\t\t%ju iterator timer%s fired\n");
595 	p(sctps_timodata, "\t\t%ju T3 data time out%s\n");
596 	p(sctps_timowindowprobe, "\t\t%ju window probe (T3) timer%s fired\n");
597 	p(sctps_timoinit, "\t\t%ju INIT timer%s fired\n");
598 	p(sctps_timosack, "\t\t%ju sack timer%s fired\n");
599 	p(sctps_timoshutdown, "\t\t%ju shutdown timer%s fired\n");
600 	p(sctps_timoheartbeat, "\t\t%ju heartbeat timer%s fired\n");
601 	p1a(sctps_timocookie, "\t\t%ju a cookie timeout fired\n");
602 	p1a(sctps_timosecret, "\t\t%ju an endpoint changed its cookie"
603 	    "secret\n");
604 	p(sctps_timopathmtu, "\t\t%ju PMTU timer%s fired\n");
605 	p(sctps_timoshutdownack, "\t\t%ju shutdown ack timer%s fired\n");
606 	p(sctps_timoshutdownguard, "\t\t%ju shutdown guard timer%s fired\n");
607 	p(sctps_timostrmrst, "\t\t%ju stream reset timer%s fired\n");
608 	p(sctps_timoearlyfr, "\t\t%ju early FR timer%s fired\n");
609 	p1a(sctps_timoasconf, "\t\t%ju an asconf timer fired\n");
610 	p1a(sctps_timoautoclose, "\t\t%ju auto close timer fired\n");
611 	p(sctps_timoassockill, "\t\t%ju asoc free timer%s expired\n");
612 	p(sctps_timoinpkill, "\t\t%ju inp free timer%s expired\n");
613 
614 #if 0
615 	/*
616 	 * Early fast retransmission counters
617 	 */
618 	p(sctps_earlyfrstart, "\t%ju TODO:sctps_earlyfrstart\n");
619 	p(sctps_earlyfrstop, "\t%ju TODO:sctps_earlyfrstop\n");
620 	p(sctps_earlyfrmrkretrans, "\t%ju TODO:sctps_earlyfrmrkretrans\n");
621 	p(sctps_earlyfrstpout, "\t%ju TODO:sctps_earlyfrstpout\n");
622 	p(sctps_earlyfrstpidsck1, "\t%ju TODO:sctps_earlyfrstpidsck1\n");
623 	p(sctps_earlyfrstpidsck2, "\t%ju TODO:sctps_earlyfrstpidsck2\n");
624 	p(sctps_earlyfrstpidsck3, "\t%ju TODO:sctps_earlyfrstpidsck3\n");
625 	p(sctps_earlyfrstpidsck4, "\t%ju TODO:sctps_earlyfrstpidsck4\n");
626 	p(sctps_earlyfrstrid, "\t%ju TODO:sctps_earlyfrstrid\n");
627 	p(sctps_earlyfrstrout, "\t%ju TODO:sctps_earlyfrstrout\n");
628 	p(sctps_earlyfrstrtmr, "\t%ju TODO:sctps_earlyfrstrtmr\n");
629 #endif
630 
631 	/*
632 	 * Others
633 	 */
634 	p1a(sctps_hdrops, "\t%ju packet shorter than header\n");
635 	p1a(sctps_badsum, "\t%ju checksum error\n");
636 	p1a(sctps_noport, "\t%ju no endpoint for port\n");
637 	p1a(sctps_badvtag, "\t%ju bad v-tag\n");
638 	p1a(sctps_badsid, "\t%ju bad SID\n");
639 	p1a(sctps_nomem, "\t%ju no memory\n");
640 	p1a(sctps_fastretransinrtt, "\t%ju number of multiple FR in a RTT "
641 	    "window\n");
642 #if 0
643 	p(sctps_markedretrans, "\t%ju TODO:sctps_markedretrans\n");
644 #endif
645 	p1a(sctps_naglesent, "\t%ju RFC813 allowed sending\n");
646 	p1a(sctps_naglequeued, "\t%ju RFC813 does not allow sending\n");
647 	p1a(sctps_maxburstqueued, "\t%ju times max burst prohibited sending\n");
648 	p1a(sctps_ifnomemqueued, "\t%ju look ahead tells us no memory in "
649 	    "interface\n");
650 	p(sctps_windowprobed, "\t%ju number%s of window probes sent\n");
651 	p(sctps_lowlevelerr, "\t%ju time%s an output error to clamp "
652 	    "down on next user send\n");
653 	p(sctps_lowlevelerrusr, "\t%ju time%s sctp_senderrors were "
654 	    "caused from a user\n");
655 	p(sctps_datadropchklmt, "\t%ju number of in data drop%s due to "
656 	    "chunk limit reached\n");
657 	p(sctps_datadroprwnd, "\t%ju number of in data drop%s due to rwnd "
658 	    "limit reached\n");
659 	p(sctps_ecnereducedcwnd, "\t%ju time%s a ECN reduced "
660 	    "the cwnd\n");
661 	p1a(sctps_vtagexpress, "\t%ju used express lookup via vtag\n");
662 	p1a(sctps_vtagbogus, "\t%ju collision in express lookup\n");
663 	p(sctps_primary_randry, "\t%ju time%s the sender ran dry "
664 	    "of user data on primary\n");
665 	p1a(sctps_cmt_randry, "\t%ju same for above\n");
666 	p(sctps_slowpath_sack, "\t%ju sack%s the slow way\n");
667 	p(sctps_wu_sacks_sent, "\t%ju window update only sack%s sent\n");
668 	p(sctps_sends_with_flags, "\t%ju send%s with sinfo_flags !=0\n");
669 	p(sctps_sends_with_unord, "\t%ju unordered send%s\n");
670 	p(sctps_sends_with_eof, "\t%ju send%s with EOF flag set\n");
671 	p(sctps_sends_with_abort, "\t%ju send%s with ABORT flag set\n");
672 	p(sctps_protocol_drain_calls, "\t%ju time%s protocol drain called\n");
673 	p(sctps_protocol_drains_done, "\t%ju time%s we did a protocol "
674 	    "drain\n");
675 	p(sctps_read_peeks, "\t%ju time%s recv was called with peek\n");
676 	p(sctps_cached_chk, "\t%ju cached chunk%s used\n");
677 	p1a(sctps_cached_strmoq, "\t%ju cached stream oq's used\n");
678 	p(sctps_left_abandon, "\t%ju unread message%s abandonded by close\n");
679 	p1a(sctps_send_burst_avoid, "\t%ju send burst avoidance, already "
680 	    "max burst inflight to net\n");
681 	p1a(sctps_send_cwnd_avoid, "\t%ju send cwnd full avoidance, already "
682 	    "max burst inflight to net\n");
683 	p(sctps_fwdtsn_map_over, "\t%ju number of map array over-run%s via "
684 	    "fwd-tsn's\n");
685 
686 #undef p
687 #undef p1a
688 }
689 
690 #endif /* SCTP */
691