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