1/*- 2 * Copyright (c) 2001-2007, 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/* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $ */ 32 33#include <sys/cdefs.h>
| 1/*- 2 * Copyright (c) 2001-2007, 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/* $KAME: sctp_var.h,v 1.24 2005/03/06 16:04:19 itojun Exp $ */ 32 33#include <sys/cdefs.h>
|
34__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 166675 2007-02-12 23:24:31Z rrs $");
| 34__FBSDID("$FreeBSD: head/sys/netinet/sctp_var.h 167598 2007-03-15 11:27:14Z rrs $");
|
35 36#ifndef _NETINET_SCTP_VAR_H_ 37#define _NETINET_SCTP_VAR_H_ 38
| 35 36#ifndef _NETINET_SCTP_VAR_H_ 37#define _NETINET_SCTP_VAR_H_ 38
|
39
| |
40#include <netinet/sctp_uio.h> 41
| 39#include <netinet/sctp_uio.h> 40
|
42/* SCTP Kernel structures */ 43 44/* 45 * Names for SCTP sysctl objects 46 */ 47#define SCTPCTL_MAXDGRAM 1 /* max datagram size */ 48#define SCTPCTL_RECVSPACE 2 /* default receive buffer space */ 49#define SCTPCTL_AUTOASCONF 3 /* auto asconf enable/disable flag */ 50#define SCTPCTL_ECN_ENABLE 4 /* Is ecn allowed */ 51#define SCTPCTL_ECN_NONCE 5 /* Is ecn nonce allowed */ 52#define SCTPCTL_STRICT_SACK 6 /* strictly require sack'd TSN's to be 53 * smaller than sndnxt. */ 54#define SCTPCTL_NOCSUM_LO 7 /* Require that the Loopback NOT have 55 * the crc32 checksum on packets 56 * routed over it. */ 57#define SCTPCTL_STRICT_INIT 8 58#define SCTPCTL_PEER_CHK_OH 9 59#define SCTPCTL_MAXBURST 10 60#define SCTPCTL_MAXCHUNKONQ 11 61#define SCTPCTL_DELAYED_SACK 12 62#define SCTPCTL_HB_INTERVAL 13 63#define SCTPCTL_PMTU_RAISE 14 64#define SCTPCTL_SHUTDOWN_GUARD 15 65#define SCTPCTL_SECRET_LIFETIME 16 66#define SCTPCTL_RTO_MAX 17 67#define SCTPCTL_RTO_MIN 18 68#define SCTPCTL_RTO_INITIAL 19 69#define SCTPCTL_INIT_RTO_MAX 20 70#define SCTPCTL_COOKIE_LIFE 21 71#define SCTPCTL_INIT_RTX_MAX 22 72#define SCTPCTL_ASSOC_RTX_MAX 23 73#define SCTPCTL_PATH_RTX_MAX 24 74#define SCTPCTL_NR_OUTGOING_STREAMS 25 75#define SCTPCTL_CMT_ON_OFF 26 76#define SCTPCTL_CWND_MAXBURST 27 77#define SCTPCTL_EARLY_FR 28 78#define SCTPCTL_RTTVAR_CC 29 79#define SCTPCTL_DEADLOCK_DET 30 80#define SCTPCTL_EARLY_FR_MSEC 31 81#define SCTPCTL_ASCONF_AUTH_NOCHK 32 82#define SCTPCTL_AUTH_DISABLE 33 83#define SCTPCTL_AUTH_RANDOM_LEN 34 84#define SCTPCTL_AUTH_HMAC_ID 35 85#define SCTPCTL_ABC_L_VAR 36 86#define SCTPCTL_MAX_MBUF_CHAIN 37 87#define SCTPCTL_CMT_USE_DAC 38 88#define SCTPCTL_DO_DRAIN 39 89#define SCTPCTL_WARM_CRC32 40 90#define SCTPCTL_QLIMIT_ABORT 41 91#define SCTPCTL_STRICT_ORDER 42 92#define SCTPCTL_TCBHASHSIZE 43 93#define SCTPCTL_PCBHASHSIZE 44 94#define SCTPCTL_CHUNKSCALE 45 95#define SCTPCTL_MINSPLIT 46 96#define SCTPCTL_ADD_MORE 47 97#define SCTPCTL_SYS_RESC 48 98#define SCTPCTL_ASOC_RESC 49 99#define SCTPCTL_NAT_FRIENDLY 50 100#ifdef SCTP_DEBUG 101#define SCTPCTL_DEBUG 51 102#define SCTPCTL_MAXID 51 103#else 104#define SCTPCTL_MAXID 50 105#endif 106 107#ifdef SCTP_DEBUG 108#define SCTPCTL_NAMES { \ 109 { 0, 0 }, \ 110 { "sendspace", CTLTYPE_INT }, \ 111 { "recvspace", CTLTYPE_INT }, \ 112 { "autoasconf", CTLTYPE_INT }, \ 113 { "ecn_enable", CTLTYPE_INT }, \ 114 { "ecn_nonce", CTLTYPE_INT }, \ 115 { "strict_sack", CTLTYPE_INT }, \ 116 { "looback_nocsum", CTLTYPE_INT }, \ 117 { "strict_init", CTLTYPE_INT }, \ 118 { "peer_chkoh", CTLTYPE_INT }, \ 119 { "maxburst", CTLTYPE_INT }, \ 120 { "maxchunks", CTLTYPE_INT }, \ 121 { "delayed_sack_time", CTLTYPE_INT }, \ 122 { "heartbeat_interval", CTLTYPE_INT }, \ 123 { "pmtu_raise_time", CTLTYPE_INT }, \ 124 { "shutdown_guard_time", CTLTYPE_INT }, \ 125 { "secret_lifetime", CTLTYPE_INT }, \ 126 { "rto_max", CTLTYPE_INT }, \ 127 { "rto_min", CTLTYPE_INT }, \ 128 { "rto_initial", CTLTYPE_INT }, \ 129 { "init_rto_max", CTLTYPE_INT }, \ 130 { "valid_cookie_life", CTLTYPE_INT }, \ 131 { "init_rtx_max", CTLTYPE_INT }, \ 132 { "assoc_rtx_max", CTLTYPE_INT }, \ 133 { "path_rtx_max", CTLTYPE_INT }, \ 134 { "nr_outgoing_streams", CTLTYPE_INT }, \ 135 { "cmt_on_off", CTLTYPE_INT }, \ 136 { "cwnd_maxburst", CTLTYPE_INT }, \ 137 { "early_fast_retran", CTLTYPE_INT }, \ 138 { "use_rttvar_congctrl", CTLTYPE_INT }, \ 139 { "deadlock_detect", CTLTYPE_INT }, \ 140 { "early_fast_retran_msec", CTLTYPE_INT }, \ 141 { "asconf_auth_nochk", CTLTYPE_INT }, \ 142 { "auth_disable", CTLTYPE_INT }, \ 143 { "auth_random_len", CTLTYPE_INT }, \ 144 { "auth_hmac_id", CTLTYPE_INT }, \ 145 { "abc_l_var", CTLTYPE_INT }, \ 146 { "max_mbuf_chain", CTLTYPE_INT }, \ 147 { "cmt_use_dac", CTLTYPE_INT }, \ 148 { "do_sctp_drain", CTLTYPE_INT }, \ 149 { "warm_crc_table", CTLTYPE_INT }, \ 150 { "abort_at_limit", CTLTYPE_INT }, \ 151 { "strict_data_order", CTLTYPE_INT }, \ 152 { "tcbhashsize", CTLTYPE_INT }, \ 153 { "pcbhashsize", CTLTYPE_INT }, \ 154 { "chunkscale", CTLTYPE_INT }, \ 155 { "min_split_point", CTLTYPE_INT }, \ 156 { "add_more_on_output", CTLTYPE_INT }, \ 157 { "sys_resource", CTLTYPE_INT }, \ 158 { "asoc_resource", CTLTYPE_INT }, \ 159 { "nat_friendly", CTLTYPE_INT }, \ 160 { "debug", CTLTYPE_INT }, \ 161} 162#else 163#define SCTPCTL_NAMES { \ 164 { 0, 0 }, \ 165 { "sendspace", CTLTYPE_INT }, \ 166 { "recvspace", CTLTYPE_INT }, \ 167 { "autoasconf", CTLTYPE_INT }, \ 168 { "ecn_enable", CTLTYPE_INT }, \ 169 { "ecn_nonce", CTLTYPE_INT }, \ 170 { "strict_sack", CTLTYPE_INT }, \ 171 { "looback_nocsum", CTLTYPE_INT }, \ 172 { "strict_init", CTLTYPE_INT }, \ 173 { "peer_chkoh", CTLTYPE_INT }, \ 174 { "maxburst", CTLTYPE_INT }, \ 175 { "maxchunks", CTLTYPE_INT }, \ 176 { "delayed_sack_time", CTLTYPE_INT }, \ 177 { "heartbeat_interval", CTLTYPE_INT }, \ 178 { "pmtu_raise_time", CTLTYPE_INT }, \ 179 { "shutdown_guard_time", CTLTYPE_INT }, \ 180 { "secret_lifetime", CTLTYPE_INT }, \ 181 { "rto_max", CTLTYPE_INT }, \ 182 { "rto_min", CTLTYPE_INT }, \ 183 { "rto_initial", CTLTYPE_INT }, \ 184 { "init_rto_max", CTLTYPE_INT }, \ 185 { "valid_cookie_life", CTLTYPE_INT }, \ 186 { "init_rtx_max", CTLTYPE_INT }, \ 187 { "assoc_rtx_max", CTLTYPE_INT }, \ 188 { "path_rtx_max", CTLTYPE_INT }, \ 189 { "nr_outgoing_streams", CTLTYPE_INT }, \ 190 { "cmt_on_off", CTLTYPE_INT }, \ 191 { "cwnd_maxburst", CTLTYPE_INT }, \ 192 { "early_fast_retran", CTLTYPE_INT }, \ 193 { "use_rttvar_congctrl", CTLTYPE_INT }, \ 194 { "deadlock_detect", CTLTYPE_INT }, \ 195 { "early_fast_retran_msec", CTLTYPE_INT }, \ 196 { "asconf_auth_nochk", CTLTYPE_INT }, \ 197 { "auth_disable", CTLTYPE_INT }, \ 198 { "auth_random_len", CTLTYPE_INT }, \ 199 { "auth_hmac_id", CTLTYPE_INT }, \ 200 { "abc_l_var", CTLTYPE_INT }, \ 201 { "max_mbuf_chain", CTLTYPE_INT }, \ 202 { "cmt_use_dac", CTLTYPE_INT }, \ 203 { "do_sctp_drain", CTLTYPE_INT }, \ 204 { "warm_crc_table", CTLTYPE_INT }, \ 205 { "abort_at_limit", CTLTYPE_INT }, \ 206 { "strict_data_order", CTLTYPE_INT }, \ 207 { "tcbhashsize", CTLTYPE_INT }, \ 208 { "pcbhashsize", CTLTYPE_INT }, \ 209 { "chunkscale", CTLTYPE_INT }, \ 210 { "min_split_point", CTLTYPE_INT }, \ 211 { "add_more_on_output", CTLTYPE_INT }, \ 212 { "sys_resource", CTLTYPE_INT }, \ 213 { "asoc_resource", CTLTYPE_INT }, \ 214 { "nat_friendly", CTLTYPE_INT }, \ 215} 216#endif 217 218
| |
219#if defined(_KERNEL) 220
| 41#if defined(_KERNEL) 42
|
221#ifdef SYSCTL_DECL 222SYSCTL_DECL(_net_inet_sctp); 223#endif
| |
224extern struct pr_usrreqs sctp_usrreqs; 225 226 227#define sctp_feature_on(inp, feature) (inp->sctp_features |= feature) 228#define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature) 229#define sctp_is_feature_on(inp, feature) (inp->sctp_features & feature) 230#define sctp_is_feature_off(inp, feature) ((inp->sctp_features & feature) == 0) 231 232#define sctp_sbspace(asoc, sb) ((long) (((sb)->sb_hiwat > (asoc)->sb_cc) ? ((sb)->sb_hiwat - (asoc)->sb_cc) : 0)) 233 234#define sctp_sbspace_failedmsgs(sb) ((long) (((sb)->sb_hiwat > (sb)->sb_cc) ? ((sb)->sb_hiwat - (sb)->sb_cc) : 0)) 235 236#define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0) 237
| 43extern struct pr_usrreqs sctp_usrreqs; 44 45 46#define sctp_feature_on(inp, feature) (inp->sctp_features |= feature) 47#define sctp_feature_off(inp, feature) (inp->sctp_features &= ~feature) 48#define sctp_is_feature_on(inp, feature) (inp->sctp_features & feature) 49#define sctp_is_feature_off(inp, feature) ((inp->sctp_features & feature) == 0) 50 51#define sctp_sbspace(asoc, sb) ((long) (((sb)->sb_hiwat > (asoc)->sb_cc) ? ((sb)->sb_hiwat - (asoc)->sb_cc) : 0)) 52 53#define sctp_sbspace_failedmsgs(sb) ((long) (((sb)->sb_hiwat > (sb)->sb_cc) ? ((sb)->sb_hiwat - (sb)->sb_cc) : 0)) 54 55#define sctp_sbspace_sub(a,b) ((a > b) ? (a - b) : 0) 56
|
238extern uint32_t sctp_asoc_free_resc_limit; 239extern uint32_t sctp_system_free_resc_limit; 240 241/* I tried to cache the readq entries at one 242 * point. But the reality is that it did not 243 * add any performance since this meant 244 * we had to lock the STCB on read. And at that point 245 * once you have to do an extra lock, it really does 246 * not matter if the lock is in the ZONE stuff or 247 * in our code. Note that this same problem would 248 * occur with an mbuf cache as well so it is 249 * not really worth doing, at least right now :-D
| 57/* 58 * I tried to cache the readq entries at one point. But the reality 59 * is that it did not add any performance since this meant we had to 60 * lock the STCB on read. And at that point once you have to do an 61 * extra lock, it really does not matter if the lock is in the ZONE 62 * stuff or in our code. Note that this same problem would occur with 63 * an mbuf cache as well so it is not really worth doing, at least 64 * right now :-D
|
250 */ 251 252#define sctp_free_a_readq(_stcb, _readq) { \ 253 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_readq, (_readq)); \ 254 SCTP_DECR_READQ_COUNT(); \ 255} 256 257#define sctp_alloc_a_readq(_stcb, _readq) { \ 258 (_readq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_readq, struct sctp_queued_to_read); \ 259 if ((_readq)) { \ 260 SCTP_INCR_READQ_COUNT(); \ 261 } \ 262} 263 264#define sctp_free_a_strmoq(_stcb, _strmoq) { \ 265 if (((_stcb)->asoc.free_strmoq_cnt > sctp_asoc_free_resc_limit) || \ 266 (sctppcbinfo.ipi_free_strmoq > sctp_system_free_resc_limit)) { \ 267 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_strmoq, (_strmoq)); \ 268 SCTP_DECR_STRMOQ_COUNT(); \ 269 } else { \ 270 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \ 271 (_stcb)->asoc.free_strmoq_cnt++; \ 272 atomic_add_int(&sctppcbinfo.ipi_free_strmoq, 1); \ 273 } \ 274} 275 276#define sctp_alloc_a_strmoq(_stcb, _strmoq) { \ 277 if (TAILQ_EMPTY(&(_stcb)->asoc.free_strmoq)) { \ 278 (_strmoq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_strmoq, struct sctp_stream_queue_pending); \ 279 if ((_strmoq)) { \ 280 SCTP_INCR_STRMOQ_COUNT(); \ 281 } \ 282 } else { \ 283 (_strmoq) = TAILQ_FIRST(&(_stcb)->asoc.free_strmoq); \ 284 TAILQ_REMOVE(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \ 285 atomic_subtract_int(&sctppcbinfo.ipi_free_strmoq, 1); \ 286 (_stcb)->asoc.free_strmoq_cnt--; \ 287 } \ 288} 289 290 291#define sctp_free_a_chunk(_stcb, _chk) { \ 292 if (((_stcb)->asoc.free_chunk_cnt > sctp_asoc_free_resc_limit) || \ 293 (sctppcbinfo.ipi_free_chunks > sctp_system_free_resc_limit)) { \ 294 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, (_chk)); \ 295 SCTP_DECR_CHK_COUNT(); \ 296 } else { \ 297 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 298 (_stcb)->asoc.free_chunk_cnt++; \ 299 atomic_add_int(&sctppcbinfo.ipi_free_chunks, 1); \ 300 } \ 301} 302 303#define sctp_alloc_a_chunk(_stcb, _chk) { \ 304 if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ 305 (_chk) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_chunk, struct sctp_tmit_chunk); \ 306 if ((_chk)) { \ 307 SCTP_INCR_CHK_COUNT(); \ 308 } \ 309 } else { \ 310 (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \ 311 TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 312 atomic_subtract_int(&sctppcbinfo.ipi_free_chunks, 1); \ 313 (_stcb)->asoc.free_chunk_cnt--; \ 314 } \ 315} 316 317 318 319#define sctp_free_remote_addr(__net) { \
| 65 */ 66 67#define sctp_free_a_readq(_stcb, _readq) { \ 68 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_readq, (_readq)); \ 69 SCTP_DECR_READQ_COUNT(); \ 70} 71 72#define sctp_alloc_a_readq(_stcb, _readq) { \ 73 (_readq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_readq, struct sctp_queued_to_read); \ 74 if ((_readq)) { \ 75 SCTP_INCR_READQ_COUNT(); \ 76 } \ 77} 78 79#define sctp_free_a_strmoq(_stcb, _strmoq) { \ 80 if (((_stcb)->asoc.free_strmoq_cnt > sctp_asoc_free_resc_limit) || \ 81 (sctppcbinfo.ipi_free_strmoq > sctp_system_free_resc_limit)) { \ 82 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_strmoq, (_strmoq)); \ 83 SCTP_DECR_STRMOQ_COUNT(); \ 84 } else { \ 85 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \ 86 (_stcb)->asoc.free_strmoq_cnt++; \ 87 atomic_add_int(&sctppcbinfo.ipi_free_strmoq, 1); \ 88 } \ 89} 90 91#define sctp_alloc_a_strmoq(_stcb, _strmoq) { \ 92 if (TAILQ_EMPTY(&(_stcb)->asoc.free_strmoq)) { \ 93 (_strmoq) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_strmoq, struct sctp_stream_queue_pending); \ 94 if ((_strmoq)) { \ 95 SCTP_INCR_STRMOQ_COUNT(); \ 96 } \ 97 } else { \ 98 (_strmoq) = TAILQ_FIRST(&(_stcb)->asoc.free_strmoq); \ 99 TAILQ_REMOVE(&(_stcb)->asoc.free_strmoq, (_strmoq), next); \ 100 atomic_subtract_int(&sctppcbinfo.ipi_free_strmoq, 1); \ 101 (_stcb)->asoc.free_strmoq_cnt--; \ 102 } \ 103} 104 105 106#define sctp_free_a_chunk(_stcb, _chk) { \ 107 if (((_stcb)->asoc.free_chunk_cnt > sctp_asoc_free_resc_limit) || \ 108 (sctppcbinfo.ipi_free_chunks > sctp_system_free_resc_limit)) { \ 109 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_chunk, (_chk)); \ 110 SCTP_DECR_CHK_COUNT(); \ 111 } else { \ 112 TAILQ_INSERT_TAIL(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 113 (_stcb)->asoc.free_chunk_cnt++; \ 114 atomic_add_int(&sctppcbinfo.ipi_free_chunks, 1); \ 115 } \ 116} 117 118#define sctp_alloc_a_chunk(_stcb, _chk) { \ 119 if (TAILQ_EMPTY(&(_stcb)->asoc.free_chunks)) { \ 120 (_chk) = SCTP_ZONE_GET(sctppcbinfo.ipi_zone_chunk, struct sctp_tmit_chunk); \ 121 if ((_chk)) { \ 122 SCTP_INCR_CHK_COUNT(); \ 123 } \ 124 } else { \ 125 (_chk) = TAILQ_FIRST(&(_stcb)->asoc.free_chunks); \ 126 TAILQ_REMOVE(&(_stcb)->asoc.free_chunks, (_chk), sctp_next); \ 127 atomic_subtract_int(&sctppcbinfo.ipi_free_chunks, 1); \ 128 (_stcb)->asoc.free_chunk_cnt--; \ 129 } \ 130} 131 132 133 134#define sctp_free_remote_addr(__net) { \
|
320 if ((__net)) { \
| 135 if ((__net)) { \
|
321 if (atomic_fetchadd_int(&(__net)->ref_count, -1) == 1) { \ 322 SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ 323 SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ 324 SCTP_OS_TIMER_STOP(&(__net)->fr_timer.timer); \
| 136 if (atomic_fetchadd_int(&(__net)->ref_count, -1) == 1) { \ 137 SCTP_OS_TIMER_STOP(&(__net)->rxt_timer.timer); \ 138 SCTP_OS_TIMER_STOP(&(__net)->pmtu_timer.timer); \ 139 SCTP_OS_TIMER_STOP(&(__net)->fr_timer.timer); \
|
| 140 if ((__net)->ro.ro_rt) { \ 141 RTFREE((__net)->ro.ro_rt); \ 142 (__net)->ro.ro_rt = NULL; \ 143 } \ 144 if ((__net)->src_addr_selected) { \ 145 sctp_free_ifa((__net)->ro._s_addr); \ 146 (__net)->ro._s_addr = NULL; \ 147 } \ 148 (__net)->src_addr_selected = 0; \
|
325 (__net)->dest_state = SCTP_ADDR_NOT_REACHABLE; \ 326 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_net, (__net)); \ 327 SCTP_DECR_RADDR_COUNT(); \ 328 } \ 329 } \ 330} 331 332#define sctp_sbfree(ctl, stcb, sb, m) { \ 333 uint32_t val; \ 334 val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \ 335 if (val < SCTP_BUF_LEN((m))) { \ 336 panic("sb_cc goes negative"); \ 337 } \ 338 val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(MSIZE)); \ 339 if (val < MSIZE) { \ 340 panic("sb_mbcnt goes negative"); \ 341 } \ 342 if (SCTP_BUF_IS_EXTENDED(m)) { \ 343 val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \ 344 if (val < SCTP_BUF_EXTEND_SIZE(m)) { \ 345 panic("sb_mbcnt goes negative2"); \ 346 } \ 347 } \ 348 if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ 349 val = atomic_fetchadd_int(&(stcb)->asoc.sb_cc,-(SCTP_BUF_LEN((m)))); \ 350 if (val < SCTP_BUF_LEN((m))) {\ 351 panic("stcb->sb_cc goes negative"); \ 352 } \ 353 val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(MSIZE)); \ 354 if (val < MSIZE) { \ 355 panic("asoc->mbcnt goes negative"); \ 356 } \ 357 if (SCTP_BUF_IS_EXTENDED(m)) { \ 358 val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \ 359 if (val < SCTP_BUF_EXTEND_SIZE(m)) { \ 360 panic("assoc stcb->mbcnt would go negative"); \ 361 } \ 362 } \ 363 } \ 364 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 365 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 366 atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 367} 368 369 370#define sctp_sballoc(stcb, sb, m) { \ 371 atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ 372 atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ 373 if (SCTP_BUF_IS_EXTENDED(m)) \ 374 atomic_add_int(&(sb)->sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \ 375 if (stcb) { \ 376 atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \ 377 atomic_add_int(&(stcb)->asoc.sb_mbcnt, MSIZE); \ 378 if (SCTP_BUF_IS_EXTENDED(m)) \ 379 atomic_add_int(&(stcb)->asoc.sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \ 380 } \ 381 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 382 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 383 atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 384} 385 386 387#define sctp_ucount_incr(val) { \ 388 val++; \ 389} 390 391#define sctp_ucount_decr(val) { \ 392 if (val > 0) { \ 393 val--; \ 394 } else { \ 395 val = 0; \ 396 } \ 397} 398 399#define sctp_mbuf_crush(data) do { \ 400 struct mbuf *_m; \ 401 _m = (data); \ 402 while(_m && (SCTP_BUF_LEN(_m) == 0)) { \ 403 (data) = SCTP_BUF_NEXT(_m); \ 404 SCTP_BUF_NEXT(_m) = NULL; \ 405 sctp_m_free(_m); \ 406 _m = (data); \ 407 } \ 408} while (0) 409 410
| 149 (__net)->dest_state = SCTP_ADDR_NOT_REACHABLE; \ 150 SCTP_ZONE_FREE(sctppcbinfo.ipi_zone_net, (__net)); \ 151 SCTP_DECR_RADDR_COUNT(); \ 152 } \ 153 } \ 154} 155 156#define sctp_sbfree(ctl, stcb, sb, m) { \ 157 uint32_t val; \ 158 val = atomic_fetchadd_int(&(sb)->sb_cc,-(SCTP_BUF_LEN((m)))); \ 159 if (val < SCTP_BUF_LEN((m))) { \ 160 panic("sb_cc goes negative"); \ 161 } \ 162 val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(MSIZE)); \ 163 if (val < MSIZE) { \ 164 panic("sb_mbcnt goes negative"); \ 165 } \ 166 if (SCTP_BUF_IS_EXTENDED(m)) { \ 167 val = atomic_fetchadd_int(&(sb)->sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \ 168 if (val < SCTP_BUF_EXTEND_SIZE(m)) { \ 169 panic("sb_mbcnt goes negative2"); \ 170 } \ 171 } \ 172 if (((ctl)->do_not_ref_stcb == 0) && stcb) {\ 173 val = atomic_fetchadd_int(&(stcb)->asoc.sb_cc,-(SCTP_BUF_LEN((m)))); \ 174 if (val < SCTP_BUF_LEN((m))) {\ 175 panic("stcb->sb_cc goes negative"); \ 176 } \ 177 val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(MSIZE)); \ 178 if (val < MSIZE) { \ 179 panic("asoc->mbcnt goes negative"); \ 180 } \ 181 if (SCTP_BUF_IS_EXTENDED(m)) { \ 182 val = atomic_fetchadd_int(&(stcb)->asoc.sb_mbcnt,-(SCTP_BUF_EXTEND_SIZE(m))); \ 183 if (val < SCTP_BUF_EXTEND_SIZE(m)) { \ 184 panic("assoc stcb->mbcnt would go negative"); \ 185 } \ 186 } \ 187 } \ 188 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 189 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 190 atomic_subtract_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 191} 192 193 194#define sctp_sballoc(stcb, sb, m) { \ 195 atomic_add_int(&(sb)->sb_cc,SCTP_BUF_LEN((m))); \ 196 atomic_add_int(&(sb)->sb_mbcnt, MSIZE); \ 197 if (SCTP_BUF_IS_EXTENDED(m)) \ 198 atomic_add_int(&(sb)->sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \ 199 if (stcb) { \ 200 atomic_add_int(&(stcb)->asoc.sb_cc,SCTP_BUF_LEN((m))); \ 201 atomic_add_int(&(stcb)->asoc.sb_mbcnt, MSIZE); \ 202 if (SCTP_BUF_IS_EXTENDED(m)) \ 203 atomic_add_int(&(stcb)->asoc.sb_mbcnt,SCTP_BUF_EXTEND_SIZE(m)); \ 204 } \ 205 if (SCTP_BUF_TYPE(m) != MT_DATA && SCTP_BUF_TYPE(m) != MT_HEADER && \ 206 SCTP_BUF_TYPE(m) != MT_OOBDATA) \ 207 atomic_add_int(&(sb)->sb_ctl,SCTP_BUF_LEN((m))); \ 208} 209 210 211#define sctp_ucount_incr(val) { \ 212 val++; \ 213} 214 215#define sctp_ucount_decr(val) { \ 216 if (val > 0) { \ 217 val--; \ 218 } else { \ 219 val = 0; \ 220 } \ 221} 222 223#define sctp_mbuf_crush(data) do { \ 224 struct mbuf *_m; \ 225 _m = (data); \ 226 while(_m && (SCTP_BUF_LEN(_m) == 0)) { \ 227 (data) = SCTP_BUF_NEXT(_m); \ 228 SCTP_BUF_NEXT(_m) = NULL; \ 229 sctp_m_free(_m); \ 230 _m = (data); \ 231 } \ 232} while (0) 233 234
|
411/* 412 * some sysctls 413 */ 414extern int sctp_sendspace; 415extern int sctp_recvspace; 416extern int sctp_ecn_enable; 417extern int sctp_ecn_nonce; 418extern int sctp_use_cwnd_based_maxburst; 419extern unsigned int sctp_cmt_on_off; 420extern unsigned int sctp_cmt_use_dac; 421extern unsigned int sctp_cmt_sockopt_on_off; 422extern uint32_t sctp_nat_friendly; 423
| |
424struct sctp_nets; 425struct sctp_inpcb; 426struct sctp_tcb; 427struct sctphdr; 428 429void sctp_ctlinput __P((int, struct sockaddr *, void *)); 430int sctp_ctloutput __P((struct socket *, struct sockopt *)); 431void sctp_input __P((struct mbuf *, int));
| 235struct sctp_nets; 236struct sctp_inpcb; 237struct sctp_tcb; 238struct sctphdr; 239 240void sctp_ctlinput __P((int, struct sockaddr *, void *)); 241int sctp_ctloutput __P((struct socket *, struct sockopt *)); 242void sctp_input __P((struct mbuf *, int));
|
432
| |
433void sctp_drain __P((void)); 434void sctp_init __P((void)); 435 436 437void sctp_pcbinfo_cleanup(void); 438 439int sctp_shutdown __P((struct socket *)); 440void sctp_notify 441__P((struct sctp_inpcb *, int, struct sctphdr *, 442 struct sockaddr *, struct sctp_tcb *, 443 struct sctp_nets *)); 444 445#if defined(INET6) 446 void ip_2_ip6_hdr __P((struct ip6_hdr *, struct ip *)); 447 448#endif 449 450 int sctp_bindx(struct socket *, int, struct sockaddr_storage *, 451 int, int, struct proc *); 452 453/* can't use sctp_assoc_t here */ 454 int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); 455 456 sctp_assoc_t sctp_getassocid(struct sockaddr *); 457 458 459 int sctp_ingetaddr(struct socket *, 460 struct sockaddr ** 461); 462 463 int sctp_peeraddr(struct socket *, 464 struct sockaddr ** 465); 466 467 int sctp_listen(struct socket *, int, struct thread *); 468 469 int sctp_accept(struct socket *, struct sockaddr **); 470
| 243void sctp_drain __P((void)); 244void sctp_init __P((void)); 245 246 247void sctp_pcbinfo_cleanup(void); 248 249int sctp_shutdown __P((struct socket *)); 250void sctp_notify 251__P((struct sctp_inpcb *, int, struct sctphdr *, 252 struct sockaddr *, struct sctp_tcb *, 253 struct sctp_nets *)); 254 255#if defined(INET6) 256 void ip_2_ip6_hdr __P((struct ip6_hdr *, struct ip *)); 257 258#endif 259 260 int sctp_bindx(struct socket *, int, struct sockaddr_storage *, 261 int, int, struct proc *); 262 263/* can't use sctp_assoc_t here */ 264 int sctp_peeloff(struct socket *, struct socket *, int, caddr_t, int *); 265 266 sctp_assoc_t sctp_getassocid(struct sockaddr *); 267 268 269 int sctp_ingetaddr(struct socket *, 270 struct sockaddr ** 271); 272 273 int sctp_peeraddr(struct socket *, 274 struct sockaddr ** 275); 276 277 int sctp_listen(struct socket *, int, struct thread *); 278 279 int sctp_accept(struct socket *, struct sockaddr **); 280
|
471
| |
472#endif /* _KERNEL */ 473 474#endif /* !_NETINET_SCTP_VAR_H_ */
| 281#endif /* _KERNEL */ 282 283#endif /* !_NETINET_SCTP_VAR_H_ */
|