]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/netinet/sctp_sysctl.c
Make gcc4.2 happy and zero save_ip for the unlikely (blackhole != 0)
[FreeBSD/FreeBSD.git] / sys / netinet / sctp_sysctl.c
1 /*-
2  * Copyright (c) 2007, by Cisco Systems, Inc. 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 #include <sys/cdefs.h>
32 __FBSDID("$FreeBSD$");
33
34 #include <netinet/sctp_os.h>
35 #include <netinet/sctp_constants.h>
36 #include <netinet/sctp_sysctl.h>
37 #include <netinet/sctp_pcb.h>
38 #include <netinet/sctputil.h>
39 #include <netinet/sctp_output.h>
40 /*
41  * sysctl tunable variables
42  */
43 uint32_t sctp_sendspace = (128 * 1024);
44 uint32_t sctp_recvspace = 128 * (1024 +
45 #ifdef INET6
46     sizeof(struct sockaddr_in6)
47 #else
48     sizeof(struct sockaddr_in)
49 #endif
50 );
51 uint32_t sctp_mbuf_threshold_count = SCTP_DEFAULT_MBUFS_IN_CHAIN;
52 uint32_t sctp_auto_asconf = SCTP_DEFAULT_AUTO_ASCONF;
53 uint32_t sctp_ecn_enable = 1;
54 uint32_t sctp_ecn_nonce = 0;
55 uint32_t sctp_strict_sacks = 0;
56 uint32_t sctp_no_csum_on_loopback = 1;
57 uint32_t sctp_strict_init = 1;
58 uint32_t sctp_abort_if_one_2_one_hits_limit = 0;
59 uint32_t sctp_strict_data_order = 0;
60
61 uint32_t sctp_peer_chunk_oh = SCTPCTL_PEER_CHKOH_DEFAULT;
62 uint32_t sctp_max_burst_default = SCTP_DEF_MAX_BURST;
63 uint32_t sctp_use_cwnd_based_maxburst = 1;
64 uint32_t sctp_do_drain = 1;
65 uint32_t sctp_hb_maxburst = SCTP_DEF_MAX_BURST;
66 uint32_t sctp_logging_level = SCTPCTL_LOGGING_LEVEL_DEFAULT;
67
68
69 uint32_t sctp_max_chunks_on_queue = SCTP_ASOC_MAX_CHUNKS_ON_QUEUE;
70 uint32_t sctp_delayed_sack_time_default = SCTP_RECV_MSEC;
71 uint32_t sctp_sack_freq_default = SCTP_DEFAULT_SACK_FREQ;
72 uint32_t sctp_heartbeat_interval_default = SCTP_HB_DEFAULT_MSEC;
73 uint32_t sctp_pmtu_raise_time_default = SCTP_DEF_PMTU_RAISE_SEC;
74 uint32_t sctp_shutdown_guard_time_default = SCTP_DEF_MAX_SHUTDOWN_SEC;
75 uint32_t sctp_secret_lifetime_default = SCTP_DEFAULT_SECRET_LIFE_SEC;
76 uint32_t sctp_rto_max_default = SCTP_RTO_UPPER_BOUND;
77 uint32_t sctp_rto_min_default = SCTP_RTO_LOWER_BOUND;
78 uint32_t sctp_rto_initial_default = SCTP_RTO_INITIAL;
79 uint32_t sctp_init_rto_max_default = SCTP_RTO_UPPER_BOUND;
80 uint32_t sctp_valid_cookie_life_default = SCTP_DEFAULT_COOKIE_LIFE;
81 uint32_t sctp_init_rtx_max_default = SCTP_DEF_MAX_INIT;
82 uint32_t sctp_assoc_rtx_max_default = SCTP_DEF_MAX_SEND;
83 uint32_t sctp_path_rtx_max_default = SCTP_DEF_MAX_PATH_RTX;
84 uint32_t sctp_nr_outgoing_streams_default = SCTP_OSTREAM_INITIAL;
85 uint32_t sctp_add_more_threshold = SCTP_DEFAULT_ADD_MORE;
86 uint32_t sctp_asoc_free_resc_limit = SCTP_DEF_ASOC_RESC_LIMIT;
87 uint32_t sctp_system_free_resc_limit = SCTP_DEF_SYSTEM_RESC_LIMIT;
88
89 uint32_t sctp_min_split_point = SCTP_DEFAULT_SPLIT_POINT_MIN;
90 uint32_t sctp_pcbtblsize = SCTP_PCBHASHSIZE;
91 uint32_t sctp_hashtblsize = SCTP_TCBHASHSIZE;
92 uint32_t sctp_chunkscale = SCTP_CHUNKQUEUE_SCALE;
93
94 uint32_t sctp_cmt_on_off = 0;
95 uint32_t sctp_cmt_use_dac = 0;
96 uint32_t sctp_max_retran_chunk = SCTPCTL_MAX_RETRAN_CHUNK_DEFAULT;
97
98
99 uint32_t sctp_L2_abc_variable = 1;
100 uint32_t sctp_early_fr = 0;
101 uint32_t sctp_early_fr_msec = SCTP_MINFR_MSEC_TIMER;
102 uint32_t sctp_says_check_for_deadlock = 0;
103 uint32_t sctp_asconf_auth_nochk = 0;
104 uint32_t sctp_auth_disable = 0;
105 uint32_t sctp_nat_friendly = 1;
106 uint32_t sctp_min_residual = SCTPCTL_MIN_RESIDUAL_DEFAULT;;
107
108
109 struct sctpstat sctpstat;
110
111 #ifdef SCTP_DEBUG
112 uint32_t sctp_debug_on = 0;
113
114 #endif
115
116
117
118 /* It returns an upper limit. No filtering is done here */
119 static unsigned int
120 number_of_addresses(struct sctp_inpcb *inp)
121 {
122         int cnt;
123         struct sctp_vrf *vrf;
124         struct sctp_ifn *sctp_ifn;
125         struct sctp_ifa *sctp_ifa;
126         struct sctp_laddr *laddr;
127
128         cnt = 0;
129         /* neither Mac OS X nor FreeBSD support mulitple routing functions */
130         if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
131                 return (0);
132         }
133         if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
134                 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
135                         LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
136                                 if ((sctp_ifa->address.sa.sa_family == AF_INET) ||
137                                     (sctp_ifa->address.sa.sa_family == AF_INET6)) {
138                                         cnt++;
139                                 }
140                         }
141                 }
142         } else {
143                 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
144                         if ((laddr->ifa->address.sa.sa_family == AF_INET) ||
145                             (laddr->ifa->address.sa.sa_family == AF_INET6)) {
146                                 cnt++;
147                         }
148                 }
149         }
150         return (cnt);
151 }
152
153 static int
154 copy_out_local_addresses(struct sctp_inpcb *inp, struct sctp_tcb *stcb, struct sysctl_req *req)
155 {
156         struct sctp_ifn *sctp_ifn;
157         struct sctp_ifa *sctp_ifa;
158         int loopback_scope, ipv4_local_scope, local_scope, site_scope;
159         int ipv4_addr_legal, ipv6_addr_legal;
160         struct sctp_vrf *vrf;
161         struct xsctp_laddr xladdr;
162         struct sctp_laddr *laddr;
163         int error;
164
165         /* Turn on all the appropriate scope */
166         if (stcb) {
167                 /* use association specific values */
168                 loopback_scope = stcb->asoc.loopback_scope;
169                 ipv4_local_scope = stcb->asoc.ipv4_local_scope;
170                 local_scope = stcb->asoc.local_scope;
171                 site_scope = stcb->asoc.site_scope;
172         } else {
173                 /* use generic values for endpoints */
174                 loopback_scope = 1;
175                 ipv4_local_scope = 1;
176                 local_scope = 1;
177                 site_scope = 1;
178         }
179
180         /* use only address families of interest */
181         if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUND_V6) {
182                 ipv6_addr_legal = 1;
183                 if (SCTP_IPV6_V6ONLY(inp)) {
184                         ipv4_addr_legal = 0;
185                 } else {
186                         ipv4_addr_legal = 1;
187                 }
188         } else {
189                 ipv4_addr_legal = 1;
190                 ipv6_addr_legal = 0;
191         }
192
193         error = 0;
194
195         /* neither Mac OS X nor FreeBSD support mulitple routing functions */
196         if ((vrf = sctp_find_vrf(inp->def_vrf_id)) == NULL) {
197                 SCTP_INP_RUNLOCK(inp);
198                 SCTP_INP_INFO_RUNLOCK();
199                 return (-1);
200         }
201         if (inp->sctp_flags & SCTP_PCB_FLAGS_BOUNDALL) {
202                 LIST_FOREACH(sctp_ifn, &vrf->ifnlist, next_ifn) {
203                         if ((loopback_scope == 0) && SCTP_IFN_IS_IFT_LOOP(sctp_ifn))
204                                 /* Skip loopback if loopback_scope not set */
205                                 continue;
206                         LIST_FOREACH(sctp_ifa, &sctp_ifn->ifalist, next_ifa) {
207                                 if (stcb) {
208                                         /*
209                                          * ignore if blacklisted at
210                                          * association level
211                                          */
212                                         if (sctp_is_addr_restricted(stcb, sctp_ifa))
213                                                 continue;
214                                 }
215                                 if ((sctp_ifa->address.sa.sa_family == AF_INET) && (ipv4_addr_legal)) {
216                                         struct sockaddr_in *sin;
217
218                                         sin = (struct sockaddr_in *)&sctp_ifa->address.sa;
219                                         if (sin->sin_addr.s_addr == 0)
220                                                 continue;
221                                         if ((ipv4_local_scope == 0) && (IN4_ISPRIVATE_ADDRESS(&sin->sin_addr)))
222                                                 continue;
223                                 } else if ((sctp_ifa->address.sa.sa_family == AF_INET6) && (ipv6_addr_legal)) {
224                                         struct sockaddr_in6 *sin6;
225
226                                         sin6 = (struct sockaddr_in6 *)&sctp_ifa->address.sa;
227                                         if (IN6_IS_ADDR_UNSPECIFIED(&sin6->sin6_addr))
228                                                 continue;
229                                         if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
230                                                 if (local_scope == 0)
231                                                         continue;
232                                                 if (sin6->sin6_scope_id == 0) {
233                                                         /*
234                                                          * bad link local
235                                                          * address
236                                                          */
237                                                         if (sa6_recoverscope(sin6) != 0)
238                                                                 continue;
239                                                 }
240                                         }
241                                         if ((site_scope == 0) && (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)))
242                                                 continue;
243                                 } else
244                                         continue;
245                                 memset((void *)&xladdr, 0, sizeof(union sctp_sockstore));
246                                 memcpy((void *)&xladdr.address, (const void *)&sctp_ifa->address, sizeof(union sctp_sockstore));
247                                 (void)SCTP_GETTIME_TIMEVAL(&xladdr.start_time);
248                                 SCTP_INP_RUNLOCK(inp);
249                                 SCTP_INP_INFO_RUNLOCK();
250                                 error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
251                                 if (error)
252                                         return (error);
253                                 else {
254                                         SCTP_INP_INFO_RLOCK();
255                                         SCTP_INP_RLOCK(inp);
256                                 }
257                         }
258                 }
259         } else {
260                 LIST_FOREACH(laddr, &inp->sctp_addr_list, sctp_nxt_addr) {
261                         /* ignore if blacklisted at association level */
262                         if (stcb && sctp_is_addr_restricted(stcb, laddr->ifa))
263                                 continue;
264                         memset((void *)&xladdr, 0, sizeof(union sctp_sockstore));
265                         memcpy((void *)&xladdr.address, (const void *)&laddr->ifa->address, sizeof(union sctp_sockstore));
266                         xladdr.start_time = laddr->start_time;
267                         SCTP_INP_RUNLOCK(inp);
268                         SCTP_INP_INFO_RUNLOCK();
269                         error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
270                         if (error)
271                                 return (error);
272                         else {
273                                 SCTP_INP_INFO_RLOCK();
274                                 SCTP_INP_RLOCK(inp);
275                         }
276                 }
277         }
278         memset((void *)&xladdr, 0, sizeof(union sctp_sockstore));
279         xladdr.last = 1;
280         SCTP_INP_RUNLOCK(inp);
281         SCTP_INP_INFO_RUNLOCK();
282         error = SYSCTL_OUT(req, &xladdr, sizeof(struct xsctp_laddr));
283
284         if (error)
285                 return (error);
286
287         else {
288                 SCTP_INP_INFO_RLOCK();
289                 SCTP_INP_RLOCK(inp);
290                 return (0);
291         }
292 }
293
294 /*
295  * sysctl functions
296  */
297 static int
298 sctp_assoclist(SYSCTL_HANDLER_ARGS)
299 {
300         unsigned int number_of_endpoints;
301         unsigned int number_of_local_addresses;
302         unsigned int number_of_associations;
303         unsigned int number_of_remote_addresses;
304         unsigned int n;
305         int error;
306         struct sctp_inpcb *inp;
307         struct sctp_tcb *stcb;
308         struct sctp_nets *net;
309         struct xsctp_inpcb xinpcb;
310         struct xsctp_tcb xstcb;
311         struct xsctp_raddr xraddr;
312
313         number_of_endpoints = 0;
314         number_of_local_addresses = 0;
315         number_of_associations = 0;
316         number_of_remote_addresses = 0;
317
318         SCTP_INP_INFO_RLOCK();
319         if (req->oldptr == USER_ADDR_NULL) {
320                 LIST_FOREACH(inp, &sctppcbinfo.listhead, sctp_list) {
321                         SCTP_INP_RLOCK(inp);
322                         number_of_endpoints++;
323                         number_of_local_addresses += number_of_addresses(inp);
324                         LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
325                                 number_of_associations++;
326                                 number_of_local_addresses += number_of_addresses(inp);
327                                 TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
328                                         number_of_remote_addresses++;
329                                 }
330                         }
331                         SCTP_INP_RUNLOCK(inp);
332                 }
333                 SCTP_INP_INFO_RUNLOCK();
334                 n = (number_of_endpoints + 1) * sizeof(struct xsctp_inpcb) +
335                     (number_of_local_addresses + number_of_endpoints + number_of_associations) * sizeof(struct xsctp_laddr) +
336                     (number_of_associations + number_of_endpoints) * sizeof(struct xsctp_tcb) +
337                     (number_of_remote_addresses + number_of_associations) * sizeof(struct xsctp_raddr);
338
339                 /* request some more memory than needed */
340                 req->oldidx = (n + n / 8);
341                 return 0;
342         }
343         if (req->newptr != USER_ADDR_NULL) {
344                 SCTP_INP_INFO_RUNLOCK();
345                 return EPERM;
346         }
347         LIST_FOREACH(inp, &sctppcbinfo.listhead, sctp_list) {
348                 SCTP_INP_RLOCK(inp);
349                 xinpcb.last = 0;
350                 xinpcb.local_port = ntohs(inp->sctp_lport);
351                 xinpcb.flags = inp->sctp_flags;
352                 xinpcb.features = inp->sctp_features;
353                 xinpcb.total_sends = inp->total_sends;
354                 xinpcb.total_recvs = inp->total_recvs;
355                 xinpcb.total_nospaces = inp->total_nospaces;
356                 xinpcb.fragmentation_point = inp->sctp_frag_point;
357                 xinpcb.qlen = inp->sctp_socket->so_qlen;
358                 xinpcb.maxqlen = inp->sctp_socket->so_qlimit;
359                 SCTP_INP_INCR_REF(inp);
360                 SCTP_INP_RUNLOCK(inp);
361                 SCTP_INP_INFO_RUNLOCK();
362                 error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
363                 if (error) {
364                         SCTP_INP_DECR_REF(inp);
365                         return error;
366                 }
367                 SCTP_INP_INFO_RLOCK();
368                 SCTP_INP_RLOCK(inp);
369                 error = copy_out_local_addresses(inp, NULL, req);
370                 if (error) {
371                         SCTP_INP_DECR_REF(inp);
372                         return error;
373                 }
374                 LIST_FOREACH(stcb, &inp->sctp_asoc_list, sctp_tcblist) {
375                         SCTP_TCB_LOCK(stcb);
376                         atomic_add_int(&stcb->asoc.refcnt, 1);
377                         SCTP_TCB_UNLOCK(stcb);
378                         xstcb.last = 0;
379                         xstcb.local_port = ntohs(inp->sctp_lport);
380                         xstcb.remote_port = ntohs(stcb->rport);
381                         if (stcb->asoc.primary_destination != NULL)
382                                 xstcb.primary_addr = stcb->asoc.primary_destination->ro._l_addr;
383                         xstcb.heartbeat_interval = stcb->asoc.heart_beat_delay;
384                         xstcb.state = SCTP_GET_STATE(&stcb->asoc);      /* FIXME */
385                         xstcb.in_streams = stcb->asoc.streamincnt;
386                         xstcb.out_streams = stcb->asoc.streamoutcnt;
387                         xstcb.max_nr_retrans = stcb->asoc.overall_error_count;
388                         xstcb.primary_process = 0;      /* not really supported
389                                                          * yet */
390                         xstcb.T1_expireries = stcb->asoc.timoinit + stcb->asoc.timocookie;
391                         xstcb.T2_expireries = stcb->asoc.timoshutdown + stcb->asoc.timoshutdownack;
392                         xstcb.retransmitted_tsns = stcb->asoc.marked_retrans;
393                         xstcb.start_time = stcb->asoc.start_time;
394                         xstcb.discontinuity_time = stcb->asoc.discontinuity_time;
395
396                         xstcb.total_sends = stcb->total_sends;
397                         xstcb.total_recvs = stcb->total_recvs;
398                         xstcb.local_tag = stcb->asoc.my_vtag;
399                         xstcb.remote_tag = stcb->asoc.peer_vtag;
400                         xstcb.initial_tsn = stcb->asoc.init_seq_number;
401                         xstcb.highest_tsn = stcb->asoc.sending_seq - 1;
402                         xstcb.cumulative_tsn = stcb->asoc.last_acked_seq;
403                         xstcb.cumulative_tsn_ack = stcb->asoc.cumulative_tsn;
404                         xstcb.mtu = stcb->asoc.smallest_mtu;
405                         xstcb.refcnt = stcb->asoc.refcnt;
406                         SCTP_INP_RUNLOCK(inp);
407                         SCTP_INP_INFO_RUNLOCK();
408                         error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
409                         if (error) {
410                                 SCTP_INP_DECR_REF(inp);
411                                 atomic_add_int(&stcb->asoc.refcnt, -1);
412                                 return error;
413                         }
414                         SCTP_INP_INFO_RLOCK();
415                         SCTP_INP_RLOCK(inp);
416                         error = copy_out_local_addresses(inp, stcb, req);
417                         if (error) {
418                                 SCTP_INP_DECR_REF(inp);
419                                 atomic_add_int(&stcb->asoc.refcnt, -1);
420                                 return error;
421                         }
422                         TAILQ_FOREACH(net, &stcb->asoc.nets, sctp_next) {
423                                 xraddr.last = 0;
424                                 xraddr.address = net->ro._l_addr;
425                                 xraddr.active = ((net->dest_state & SCTP_ADDR_REACHABLE) == SCTP_ADDR_REACHABLE);
426                                 xraddr.confirmed = ((net->dest_state & SCTP_ADDR_UNCONFIRMED) == 0);
427                                 xraddr.heartbeat_enabled = ((net->dest_state & SCTP_ADDR_NOHB) == 0);
428                                 xraddr.rto = net->RTO;
429                                 xraddr.max_path_rtx = net->failure_threshold;
430                                 xraddr.rtx = net->marked_retrans;
431                                 xraddr.error_counter = net->error_count;
432                                 xraddr.cwnd = net->cwnd;
433                                 xraddr.flight_size = net->flight_size;
434                                 xraddr.mtu = net->mtu;
435                                 xraddr.start_time = net->start_time;
436                                 SCTP_INP_RUNLOCK(inp);
437                                 SCTP_INP_INFO_RUNLOCK();
438                                 error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
439                                 if (error) {
440                                         SCTP_INP_DECR_REF(inp);
441                                         atomic_add_int(&stcb->asoc.refcnt, -1);
442                                         return error;
443                                 }
444                                 SCTP_INP_INFO_RLOCK();
445                                 SCTP_INP_RLOCK(inp);
446                         }
447                         atomic_add_int(&stcb->asoc.refcnt, -1);
448                         memset((void *)&xraddr, 0, sizeof(struct xsctp_raddr));
449                         xraddr.last = 1;
450                         SCTP_INP_RUNLOCK(inp);
451                         SCTP_INP_INFO_RUNLOCK();
452                         error = SYSCTL_OUT(req, &xraddr, sizeof(struct xsctp_raddr));
453                         if (error) {
454                                 SCTP_INP_DECR_REF(inp);
455                                 return error;
456                         }
457                         SCTP_INP_INFO_RLOCK();
458                         SCTP_INP_RLOCK(inp);
459                 }
460                 SCTP_INP_RUNLOCK(inp);
461                 SCTP_INP_INFO_RUNLOCK();
462                 memset((void *)&xstcb, 0, sizeof(struct xsctp_tcb));
463                 xstcb.last = 1;
464                 error = SYSCTL_OUT(req, &xstcb, sizeof(struct xsctp_tcb));
465                 if (error) {
466                         return error;
467                 }
468                 SCTP_INP_INFO_RLOCK();
469                 SCTP_INP_DECR_REF(inp);
470         }
471         SCTP_INP_INFO_RUNLOCK();
472
473         memset((void *)&xinpcb, 0, sizeof(struct xsctp_inpcb));
474         xinpcb.last = 1;
475         error = SYSCTL_OUT(req, &xinpcb, sizeof(struct xsctp_inpcb));
476         return error;
477 }
478
479
480 /*
481  * sysctl definitions
482  */
483
484 SYSCTL_INT(_net_inet_sctp, OID_AUTO, sendspace, CTLFLAG_RW,
485     &sctp_sendspace, 0, "Maximum outgoing SCTP buffer size");
486
487 SYSCTL_INT(_net_inet_sctp, OID_AUTO, recvspace, CTLFLAG_RW,
488     &sctp_recvspace, 0, "Maximum incoming SCTP buffer size");
489
490 #if defined(__FreeBSD__) || defined(SCTP_APPLE_AUTO_ASCONF)
491 SYSCTL_INT(_net_inet_sctp, OID_AUTO, auto_asconf, CTLFLAG_RW,
492     &sctp_auto_asconf, 0, "Enable SCTP Auto-ASCONF");
493 #endif
494
495 SYSCTL_INT(_net_inet_sctp, OID_AUTO, ecn_enable, CTLFLAG_RW,
496     &sctp_ecn_enable, 0, "Enable SCTP ECN");
497
498 SYSCTL_INT(_net_inet_sctp, OID_AUTO, ecn_nonce, CTLFLAG_RW,
499     &sctp_ecn_nonce, 0, "Enable SCTP ECN Nonce");
500
501 SYSCTL_INT(_net_inet_sctp, OID_AUTO, strict_sacks, CTLFLAG_RW,
502     &sctp_strict_sacks, 0, "Enable SCTP Strict SACK checking");
503
504 SYSCTL_INT(_net_inet_sctp, OID_AUTO, loopback_nocsum, CTLFLAG_RW,
505     &sctp_no_csum_on_loopback, 0,
506     "Enable NO Csum on packets sent on loopback");
507
508 SYSCTL_INT(_net_inet_sctp, OID_AUTO, strict_init, CTLFLAG_RW,
509     &sctp_strict_init, 0,
510     "Enable strict INIT/INIT-ACK singleton enforcement");
511
512 SYSCTL_INT(_net_inet_sctp, OID_AUTO, peer_chkoh, CTLFLAG_RW,
513     &sctp_peer_chunk_oh, 0,
514     "Amount to debit peers rwnd per chunk sent");
515
516 SYSCTL_INT(_net_inet_sctp, OID_AUTO, maxburst, CTLFLAG_RW,
517     &sctp_max_burst_default, 0,
518     "Default max burst for sctp endpoints");
519
520 SYSCTL_INT(_net_inet_sctp, OID_AUTO, maxchunks, CTLFLAG_RW,
521     &sctp_max_chunks_on_queue, 0,
522     "Default max chunks on queue per asoc");
523
524 SYSCTL_INT(_net_inet_sctp, OID_AUTO, tcbhashsize, CTLFLAG_RW,
525     &sctp_hashtblsize, 0,
526     "Tuneable for Hash table sizes");
527
528 SYSCTL_INT(_net_inet_sctp, OID_AUTO, min_split_point, CTLFLAG_RW,
529     &sctp_min_split_point, 0,
530     "Minimum size when splitting a chunk");
531
532 SYSCTL_INT(_net_inet_sctp, OID_AUTO, pcbhashsize, CTLFLAG_RW,
533     &sctp_pcbtblsize, 0,
534     "Tuneable for PCB Hash table sizes");
535
536 SYSCTL_INT(_net_inet_sctp, OID_AUTO, sys_resource, CTLFLAG_RW,
537     &sctp_system_free_resc_limit, 0,
538     "Max number of cached resources in the system");
539
540 SYSCTL_INT(_net_inet_sctp, OID_AUTO, asoc_resource, CTLFLAG_RW,
541     &sctp_asoc_free_resc_limit, 0,
542     "Max number of cached resources in an asoc");
543
544 SYSCTL_INT(_net_inet_sctp, OID_AUTO, chunkscale, CTLFLAG_RW,
545     &sctp_chunkscale, 0,
546     "Tuneable for Scaling of number of chunks and messages");
547
548 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, delayed_sack_time, CTLFLAG_RW,
549     &sctp_delayed_sack_time_default, 0,
550     "Default delayed SACK timer in msec");
551
552 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, sack_freq, CTLFLAG_RW,
553     &sctp_sack_freq_default, 0,
554     "Default SACK frequency");
555
556 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, heartbeat_interval, CTLFLAG_RW,
557     &sctp_heartbeat_interval_default, 0,
558     "Default heartbeat interval in msec");
559
560 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, pmtu_raise_time, CTLFLAG_RW,
561     &sctp_pmtu_raise_time_default, 0,
562     "Default PMTU raise timer in sec");
563
564 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, shutdown_guard_time, CTLFLAG_RW,
565     &sctp_shutdown_guard_time_default, 0,
566     "Default shutdown guard timer in sec");
567
568 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, secret_lifetime, CTLFLAG_RW,
569     &sctp_secret_lifetime_default, 0,
570     "Default secret lifetime in sec");
571
572 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, rto_max, CTLFLAG_RW,
573     &sctp_rto_max_default, 0,
574     "Default maximum retransmission timeout in msec");
575
576 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, rto_min, CTLFLAG_RW,
577     &sctp_rto_min_default, 0,
578     "Default minimum retransmission timeout in msec");
579
580 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, rto_initial, CTLFLAG_RW,
581     &sctp_rto_initial_default, 0,
582     "Default initial retransmission timeout in msec");
583
584 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, init_rto_max, CTLFLAG_RW,
585     &sctp_init_rto_max_default, 0,
586     "Default maximum retransmission timeout during association setup in msec");
587
588 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, valid_cookie_life, CTLFLAG_RW,
589     &sctp_valid_cookie_life_default, 0,
590     "Default cookie lifetime in ticks");
591
592 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, init_rtx_max, CTLFLAG_RW,
593     &sctp_init_rtx_max_default, 0,
594     "Default maximum number of retransmission for INIT chunks");
595
596 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, assoc_rtx_max, CTLFLAG_RW,
597     &sctp_assoc_rtx_max_default, 0,
598     "Default maximum number of retransmissions per association");
599
600 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, path_rtx_max, CTLFLAG_RW,
601     &sctp_path_rtx_max_default, 0,
602     "Default maximum of retransmissions per path");
603
604 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, add_more_on_output, CTLFLAG_RW,
605     &sctp_add_more_threshold, 0,
606     "When space wise is it worthwhile to try to add more to a socket send buffer");
607
608 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, outgoing_streams, CTLFLAG_RW,
609     &sctp_nr_outgoing_streams_default, 0,
610     "Default number of outgoing streams");
611
612 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, cmt_on_off, CTLFLAG_RW,
613     &sctp_cmt_on_off, 0,
614     "CMT ON/OFF flag");
615
616 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, cwnd_maxburst, CTLFLAG_RW,
617     &sctp_use_cwnd_based_maxburst, 0,
618     "Use a CWND adjusting maxburst");
619
620 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, early_fast_retran, CTLFLAG_RW,
621     &sctp_early_fr, 0,
622     "Early Fast Retransmit with timer");
623
624 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, deadlock_detect, CTLFLAG_RW,
625     &sctp_says_check_for_deadlock, 0,
626     "SMP Deadlock detection on/off");
627
628 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, early_fast_retran_msec, CTLFLAG_RW,
629     &sctp_early_fr_msec, 0,
630     "Early Fast Retransmit minimum timer value");
631
632 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, asconf_auth_nochk, CTLFLAG_RW,
633     &sctp_asconf_auth_nochk, 0,
634     "Disable SCTP ASCONF AUTH requirement");
635
636 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, auth_disable, CTLFLAG_RW,
637     &sctp_auth_disable, 0,
638     "Disable SCTP AUTH function");
639
640 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, nat_friendly, CTLFLAG_RW,
641     &sctp_nat_friendly, 0,
642     "SCTP NAT friendly operation");
643
644 SYSCTL_INT(_net_inet_sctp, OID_AUTO, abc_l_var, CTLFLAG_RW,
645     &sctp_L2_abc_variable, 0,
646     "SCTP ABC max increase per SACK (L)");
647
648 SYSCTL_INT(_net_inet_sctp, OID_AUTO, max_chained_mbufs, CTLFLAG_RW,
649     &sctp_mbuf_threshold_count, 0,
650     "Default max number of small mbufs on a chain");
651
652 SYSCTL_UINT(_net_inet_sctp, OID_AUTO, cmt_use_dac, CTLFLAG_RW,
653     &sctp_cmt_use_dac, 0,
654     "CMT DAC ON/OFF flag");
655
656 SYSCTL_INT(_net_inet_sctp, OID_AUTO, do_sctp_drain, CTLFLAG_RW,
657     &sctp_do_drain, 0,
658     "Should SCTP respond to the drain calls");
659
660 SYSCTL_INT(_net_inet_sctp, OID_AUTO, hb_max_burst, CTLFLAG_RW,
661     &sctp_hb_maxburst, 0,
662     "Confirmation Heartbeat max burst?");
663
664 SYSCTL_INT(_net_inet_sctp, OID_AUTO, abort_at_limit, CTLFLAG_RW,
665     &sctp_abort_if_one_2_one_hits_limit, 0,
666     "When one-2-one hits qlimit abort");
667
668 SYSCTL_INT(_net_inet_sctp, OID_AUTO, strict_data_order, CTLFLAG_RW,
669     &sctp_strict_data_order, 0,
670     "Enforce strict data ordering, abort if control inside data");
671
672 SYSCTL_STRUCT(_net_inet_sctp, OID_AUTO, stats, CTLFLAG_RW,
673     &sctpstat, sctpstat,
674     "SCTP statistics (struct sctps_stat, netinet/sctp.h");
675
676 SYSCTL_PROC(_net_inet_sctp, OID_AUTO, assoclist, CTLFLAG_RD,
677     0, 0, sctp_assoclist,
678     "S,xassoc", "List of active SCTP associations");
679
680 SYSCTL_INT(_net_inet_sctp, OID_AUTO, min_residual, CTLFLAG_RW,
681     &sctp_min_residual, 0,
682     SCTPCTL_MIN_RESIDUAL_DESC);
683
684 SYSCTL_INT(_net_inet_sctp, OID_AUTO, max_retran_chunk, CTLFLAG_RW,
685     &sctp_max_retran_chunk, 0,
686     SCTPCTL_MAX_RETRAN_CHUNK_DESC);
687
688 SYSCTL_INT(_net_inet_sctp, OID_AUTO, sctp_logging, CTLFLAG_RW,
689     &sctp_logging_level, 0,
690     SCTPCTL_LOGGING_LEVEL_DESC);
691
692
693 #ifdef SCTP_DEBUG
694 SYSCTL_INT(_net_inet_sctp, OID_AUTO, debug, CTLFLAG_RW,
695     &sctp_debug_on, 0, "Configure debug output");
696 #endif                          /* SCTP_DEBUG */