xref: /freebsd/usr.bin/netstat/sctp.c (revision 0c927cdd8e6e05387fc5a9ffcb5dbe128d4ad749)
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 		(int)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 proto,
435     const char *name, int af1)
436 {
437 	char *buf;
438 	const char *mibvar = "net.inet.sctp.assoclist";
439 	u_int 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 __unused, const char *name, int af1 __unused)
514 {
515 	struct sctpstat sctpstat, zerostat;
516 	size_t len = sizeof(sctpstat);
517 
518 	if (zflag)
519 		memset(&zerostat, 0, len);
520 	if (sysctlbyname("net.inet.sctp.stats", &sctpstat, &len,
521 	    zflag ? &zerostat : NULL, zflag ? len : 0) < 0) {
522 		warn("sysctl: net.inet.sctp.stats");
523 		return;
524 	}
525 
526 	printf ("%s:\n", name);
527 
528 #define	p(f, m) if (sctpstat.f || sflag <= 1) \
529     printf(m, sctpstat.f, plural(sctpstat.f))
530 #define	p1a(f, m) if (sctpstat.f || sflag <= 1) \
531     printf(m, sctpstat.f)
532 #define	p2(f1, f2, m) if (sctpstat.f1 || sctpstat.f2 || sflag <= 1) \
533     printf(m, sctpstat.f1, plural(sctpstat.f1), sctpstat.f2, plural(sctpstat.f2))
534 #define	p2a(f1, f2, m) if (sctpstat.f1 || sctpstat.f2 || sflag <= 1) \
535     printf(m, sctpstat.f1, plural(sctpstat.f1), sctpstat.f2)
536 #define	p3(f, m) if (sctpstat.f || sflag <= 1) \
537     printf(m, sctpstat.f, plurales(sctpstat.f))
538 
539 	/*
540 	 * input statistics
541 	 */
542 	p(sctps_recvpackets, "\t%lu total input packet%s\n");
543 	p(sctps_recvdatagrams, "\t%lu total input datagram%s\n");
544 	p(sctps_recvpktwithdata, "\t%lu total packet%s that had data\n");
545 	p(sctps_recvsacks, "\t%lu total input SACK chunk%s\n");
546 	p(sctps_recvdata, "\t%lu total input DATA chunk%s\n");
547 	p(sctps_recvdupdata, "\t%lu total input duplicate DATA chunk%s\n");
548 	p(sctps_recvheartbeat, "\t%lu total input HB chunk%s\n");
549 	p(sctps_recvheartbeatack, "\t%lu total input HB-ACK chunk%s\n");
550 	p(sctps_recvecne, "\t%lu total input ECNE chunk%s\n");
551 	p(sctps_recvauth, "\t%lu total input AUTH chunk%s\n");
552 	p(sctps_recvauthmissing, "\t%lu total input chunk%s missing AUTH\n");
553 	p(sctps_recvivalhmacid, "\t%lu total number of invalid HMAC id%s "
554 	    "received\n");
555 	p(sctps_recvivalkeyid, "\t%lu total number of invalid %secret ids "
556 	    "received\n");
557 	p1a(sctps_recvauthfailed, "\t%lu total number of auth failed\n");
558 	p(sctps_recvexpress, "\t%lu total fa%st path receives all one "
559 	    "chunk\n");
560 	p(sctps_recvexpressm, "\t%lu total fa%st path multi-part data\n");
561 
562 	/*
563 	 * output statistics
564 	 */
565 	p(sctps_sendpackets, "\t%lu total output packet%s\n");
566 	p(sctps_sendsacks, "\t%lu total output SACK%s\n");
567 	p(sctps_senddata, "\t%lu total output DATA chunk%s\n");
568 	p(sctps_sendretransdata, "\t%lu total output retran%smitted DATA "
569 	    "chunks\n");
570 	p(sctps_sendfastretrans, "\t%lu total output fa%st retransmitted "
571 	    "DATA chunks\n");
572 	p(sctps_sendmultfastretrans, "\t%lu total FR'%s that happened more "
573 	    "than once to same chunk (u-del multi-fr algo).\n");
574 	p(sctps_sendheartbeat, "\t%lu total output HB chunk%s\n");
575 	p(sctps_sendecne, "\t%lu total output ECNE chunk%s\n");
576 	p(sctps_sendauth, "\t%lu total output AUTH chunk%s\n");
577 	p1a(sctps_senderrors, "\t%lu ip_output error counter\n");
578 
579 	/*
580 	 * PCKDROPREP statistics
581 	 */
582 	p1a(sctps_pdrpfmbox, "\t%lu packet drop from middle box\n");
583 	p(sctps_pdrpfehos, "\t%lu packet drop from end ho%st\n");
584 	p(sctps_pdrpmbda, "\t%lu packet drop%s with data\n");
585 	p(sctps_pdrpmbct, "\t%lu packet drop%s, non-data, non-endhost\n");
586 	p(sctps_pdrpbwrpt, "\t%lu packet drop, non-endho%st, bandwidth "
587 	    "rep only\n");
588 	p1a(sctps_pdrpcrupt, "\t%lu packet drop, not enough for chunk "
589 	    "header\n");
590 	p1a(sctps_pdrpnedat, "\t%lu packet drop, not enough data to confirm\n");
591 	p(sctps_pdrppdbrk, "\t%lu packet drop, where proce%ss_chunk_drop "
592 	    "said break\n");
593 	p1a(sctps_pdrptsnnf, "\t%lu packet drop, could not find TSN\n");
594 	p(sctps_pdrpdnfnd, "\t%lu packet drop, attempt rever%se TSN lookup\n");
595 	p(sctps_pdrpdiwnp, "\t%lu packet drop, e-ho%st confirms zero-rwnd\n");
596 	p(sctps_pdrpdizrw, "\t%lu packet drop, midbox confirm%s no space\n");
597 	p1a(sctps_pdrpbadd, "\t%lu packet drop, data did not match TSN\n");
598 	p(sctps_pdrpmark, "\t%lu packet drop, TSN'%s marked for Fast Retran\n");
599 
600 	/*
601 	 * Timeouts
602 	 */
603 	p(sctps_timoiterator, "\t%lu number of iterator timer%s that fired\n");
604 	p(sctps_timodata, "\t%lu number of T3 data time out%s\n");
605 	p(sctps_timowindowprobe, "\t%lu number of window probe (T3) timer%s "
606 	    "that fired\n");
607 	p(sctps_timoinit, "\t%lu number of INIT timer%s that fired\n");
608 	p(sctps_timosack, "\t%lu number of %sack timers that fired\n");
609 	p(sctps_timoshutdown, "\t%lu number of %shutdown timers that fired\n");
610 	p(sctps_timoheartbeat, "\t%lu number of heartbeat timer%s that "
611 	    "fired\n");
612 	p(sctps_timocookie, "\t%lu number of time%s a cookie timeout fired\n");
613 	p(sctps_timosecret, "\t%lu number of time%s an endpoint changed its "
614 	    "cookie secret\n");
615 	p(sctps_timopathmtu, "\t%lu number of PMTU timer%s that fired\n");
616 	p(sctps_timoshutdownack, "\t%lu number of %shutdown ack timers that "
617 	    "fired\n");
618 	p(sctps_timoshutdownguard, "\t%lu number of %shutdown guard timers "
619 	    "that fired\n");
620 	p(sctps_timostrmrst, "\t%lu number of %stream reset timers that "
621 	    "fired\n");
622 	p(sctps_timoearlyfr, "\t%lu number of early FR timer%s that fired\n");
623 	p(sctps_timoasconf, "\t%lu number of time%s an asconf timer fired\n");
624 	p(sctps_timoautoclose, "\t%lu number of time%s auto close timer "
625 	    "fired\n");
626 	p(sctps_timoassockill, "\t%lu number of a%soc free timers expired\n");
627 	p(sctps_timoinpkill, "\t%lu number of inp free timer%s expired\n");
628 
629 #if 0
630 	/*
631 	 * Early fast retransmission counters
632 	 */
633 	p(sctps_earlyfrstart, "\t%lu TODO:%sctps_earlyfrstart\n");
634 	p(sctps_earlyfrstop, "\t%lu TODO:sctp%s_earlyfrstop\n");
635 	p(sctps_earlyfrmrkretrans, "\t%lu TODO:%sctps_earlyfrmrkretrans\n");
636 	p(sctps_earlyfrstpout, "\t%lu TODO:%sctps_earlyfrstpout\n");
637 	p(sctps_earlyfrstpidsck1, "\t%lu TODO:%sctps_earlyfrstpidsck1\n");
638 	p(sctps_earlyfrstpidsck2, "\t%lu TODO:%sctps_earlyfrstpidsck2\n");
639 	p(sctps_earlyfrstpidsck3, "\t%lu TODO:%sctps_earlyfrstpidsck3\n");
640 	p(sctps_earlyfrstpidsck4, "\t%lu TODO:%sctps_earlyfrstpidsck4\n");
641 	p(sctps_earlyfrstrid, "\t%lu TODO:%sctps_earlyfrstrid\n");
642 	p(sctps_earlyfrstrout, "\t%lu TODO:%sctps_earlyfrstrout\n");
643 	p(sctps_earlyfrstrtmr, "\t%lu TODO:%sctps_earlyfrstrtmr\n");
644 #endif
645 
646 	/*
647 	 * Others
648 	 */
649 	p(sctps_hdrops, "\t%lu packet %shorter than header\n");
650 	p(sctps_badsum, "\t%lu check%sum error\n");
651 	p1a(sctps_noport, "\t%lu no endpoint for port\n");
652 	p1a(sctps_badvtag, "\t%lu bad v-tag\n");
653 	p1a(sctps_badsid, "\t%lu bad SID\n");
654 	p1a(sctps_nomem, "\t%lu no memory\n");
655 	p1a(sctps_fastretransinrtt, "\t%lu number of multiple FR in a RTT "
656 	    "window\n");
657 #if 0
658 	p(sctps_markedretrans, "\t%lu TODO:%sctps_markedretrans\n");
659 #endif
660 	p(sctps_naglesent, "\t%lu nagle allowed %sending\n");
661 	p(sctps_naglequeued, "\t%lu nagle doe%s't allow sending\n");
662 	p(sctps_maxburstqueued, "\t%lu max bur%st dosn't allow sending\n");
663 	p(sctps_ifnomemqueued, "\t%lu look ahead tell%s us no memory in "
664 	    "interface ring buffer or we had a send error and are queuing "
665 	    "one send.\n");
666 	p(sctps_windowprobed, "\t%lu total number of window probe%s sent\n");
667 	p(sctps_lowlevelerr, "\t%lu total time%s an output error causes us "
668 	    "to clamp down on next user send.\n");
669 	p(sctps_lowlevelerrusr, "\t%lu total time%s sctp_senderrors were "
670 	    "caused from a user send from a user invoked send not a sack "
671 	    "response\n");
672 	p(sctps_datadropchklmt, "\t%lu number of in data drop%s due to "
673 	    "chunk limit reached\n");
674 	p(sctps_datadroprwnd, "\t%lu number of in data drop%s due to rwnd "
675 	    "limit reached\n");
676 	p(sctps_ecnereducedcwnd, "\t%lu number of time%s a ECN reduced "
677 	    "the cwnd\n");
678 	p(sctps_vtagexpress, "\t%lu u%sed express lookup via vtag\n");
679 	p(sctps_vtagbogus, "\t%lu colli%sion in express lookup.\n");
680 	p(sctps_primary_randry, "\t%lu number of time%s the sender ran dry "
681 	    "of user data on primary\n");
682 	p1a(sctps_cmt_randry, "\t%lu same for above\n");
683 	p(sctps_slowpath_sack, "\t%lu sack%s the slow way\n");
684 	p(sctps_wu_sacks_sent, "\t%lu window update only %sacks sent\n");
685 	p(sctps_sends_with_flags, "\t%lu number of %sends with "
686 	    "sinfo_flags !=0\n");
687 	p(sctps_sends_with_unord, "\t%lu number of undordered %sends\n");
688 	p(sctps_sends_with_eof, "\t%lu number of %sends with EOF flag set\n");
689 	p(sctps_sends_with_abort, "\t%lu number of %sends with ABORT "
690 	    "flag set\n");
691 	p(sctps_protocol_drain_calls, "\t%lu number of time%s protocol "
692 	    "drain called\n");
693 	p(sctps_protocol_drains_done, "\t%lu number of time%s we did a "
694 	    "protocol drain\n");
695 	p(sctps_read_peeks, "\t%lu number of time%s recv was called with "
696 	    "peek\n");
697 	p(sctps_cached_chk, "\t%lu number of cached chunk%s used\n");
698 	p(sctps_cached_strmoq, "\t%lu number of cached %stream oq's used\n");
699 	p(sctps_left_abandon, "\t%lu number of unread me%ssage abandonded "
700 	    "by close\n");
701 	p(sctps_send_burst_avoid, "\t%lu send bur%st avoidance, already "
702 	    "max burst inflight to net\n");
703 	p(sctps_send_cwnd_avoid, "\t%lu send cwnd full avoidance, already "
704 	    "max bur%st inflight to net\n");
705 	p(sctps_fwdtsn_map_over, "\t%lu number of map array over-run%s via "
706 	    "fwd-tsn's\n");
707 }
708 
709 #endif /* SCTP */
710