1 /*- 2 * SPDX-License-Identifier: BSD-3-Clause 3 * 4 * Copyright (c) 2001-2007, by Cisco Systems, Inc. All rights reserved. 5 * Copyright (c) 2008-2012, by Randall Stewart. All rights reserved. 6 * Copyright (c) 2008-2012, by Michael Tuexen. All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions are met: 10 * 11 * a) Redistributions of source code must retain the above copyright notice, 12 * this list of conditions and the following disclaimer. 13 * 14 * b) Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in 16 * the documentation and/or other materials provided with the distribution. 17 * 18 * c) Neither the name of Cisco Systems, Inc. nor the names of its 19 * contributors may be used to endorse or promote products derived 20 * from this software without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 32 * THE POSSIBILITY OF SUCH DAMAGE. 33 */ 34 35 #include <sys/cdefs.h> 36 __FBSDID("$FreeBSD$"); 37 38 #ifndef _NETINET_SCTP_LOCK_BSD_H_ 39 #define _NETINET_SCTP_LOCK_BSD_H_ 40 41 /* 42 * General locking concepts: The goal of our locking is to of course provide 43 * consistency and yet minimize overhead. We will attempt to use 44 * non-recursive locks which are supposed to be quite inexpensive. Now in 45 * order to do this the goal is that most functions are not aware of locking. 46 * Once we have a TCB we lock it and unlock when we are through. This means 47 * that the TCB lock is kind-of a "global" lock when working on an 48 * association. Caution must be used when asserting a TCB_LOCK since if we 49 * recurse we deadlock. 50 * 51 * Most other locks (INP and INFO) attempt to localize the locking i.e. we try 52 * to contain the lock and unlock within the function that needs to lock it. 53 * This sometimes mean we do extra locks and unlocks and lose a bit of 54 * efficiency, but if the performance statements about non-recursive locks are 55 * true this should not be a problem. One issue that arises with this only 56 * lock when needed is that if an implicit association setup is done we have 57 * a problem. If at the time I lookup an association I have NULL in the tcb 58 * return, by the time I call to create the association some other processor 59 * could have created it. This is what the CREATE lock on the endpoint. 60 * Places where we will be implicitly creating the association OR just 61 * creating an association (the connect call) will assert the CREATE_INP 62 * lock. This will assure us that during all the lookup of INP and INFO if 63 * another creator is also locking/looking up we can gate the two to 64 * synchronize. So the CREATE_INP lock is also another one we must use 65 * extreme caution in locking to make sure we don't hit a re-entrancy issue. 66 * 67 */ 68 69 /* 70 * When working with the global SCTP lists we lock and unlock the INP_INFO 71 * lock. So when we go to lookup an association we will want to do a 72 * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to 73 * the SCTP_BASE_INFO() list's we will do a SCTP_INP_INFO_WLOCK(). 74 */ 75 76 #define SCTP_IPI_COUNT_INIT() 77 78 #define SCTP_STATLOG_INIT_LOCK() 79 #define SCTP_STATLOG_DESTROY() 80 #define SCTP_STATLOG_LOCK() 81 #define SCTP_STATLOG_UNLOCK() 82 83 #define SCTP_INP_INFO_LOCK_INIT() do { \ 84 rw_init(&SCTP_BASE_INFO(ipi_ep_mtx), "sctp-info"); \ 85 } while (0) 86 87 #define SCTP_INP_INFO_LOCK_DESTROY() do { \ 88 if (rw_wowned(&SCTP_BASE_INFO(ipi_ep_mtx))) { \ 89 rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 90 } \ 91 rw_destroy(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 92 } while (0) 93 94 #define SCTP_INP_INFO_RLOCK() do { \ 95 rw_rlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 96 } while (0) 97 98 #define SCTP_INP_INFO_WLOCK() do { \ 99 rw_wlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 100 } while (0) 101 102 #define SCTP_INP_INFO_RUNLOCK() do { \ 103 rw_runlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 104 } while (0) 105 106 #define SCTP_INP_INFO_WUNLOCK() do { \ 107 rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \ 108 } while (0) 109 110 #define SCTP_INP_INFO_LOCK_ASSERT() do { \ 111 rw_assert(&SCTP_BASE_INFO(ipi_ep_mtx), RA_LOCKED); \ 112 } while (0) 113 114 #define SCTP_INP_INFO_RLOCK_ASSERT() do { \ 115 rw_assert(&SCTP_BASE_INFO(ipi_ep_mtx), RA_RLOCKED); \ 116 } while (0) 117 118 #define SCTP_INP_INFO_WLOCK_ASSERT() do { \ 119 rw_assert(&SCTP_BASE_INFO(ipi_ep_mtx), RA_WLOCKED); \ 120 } while (0) 121 122 #define SCTP_MCORE_QLOCK_INIT(cpstr) do { \ 123 mtx_init(&(cpstr)->que_mtx, "sctp-mcore_queue","queue_lock", \ 124 MTX_DEF | MTX_DUPOK); \ 125 } while (0) 126 127 #define SCTP_MCORE_QDESTROY(cpstr) do { \ 128 if (mtx_owned(&(cpstr)->core_mtx)) { \ 129 mtx_unlock(&(cpstr)->que_mtx); \ 130 } \ 131 mtx_destroy(&(cpstr)->que_mtx); \ 132 } while (0) 133 134 #define SCTP_MCORE_QLOCK(cpstr) do { \ 135 mtx_lock(&(cpstr)->que_mtx); \ 136 } while (0) 137 138 #define SCTP_MCORE_QUNLOCK(cpstr) do { \ 139 mtx_unlock(&(cpstr)->que_mtx); \ 140 } while (0) 141 142 #define SCTP_MCORE_LOCK_INIT(cpstr) do { \ 143 mtx_init(&(cpstr)->core_mtx, "sctp-cpulck","cpu_proc_lock", \ 144 MTX_DEF | MTX_DUPOK); \ 145 } while (0) 146 147 #define SCTP_MCORE_DESTROY(cpstr) do { \ 148 if (mtx_owned(&(cpstr)->core_mtx)) { \ 149 mtx_unlock(&(cpstr)->core_mtx); \ 150 } \ 151 mtx_destroy(&(cpstr)->core_mtx); \ 152 } while (0) 153 154 #define SCTP_MCORE_LOCK(cpstr) do { \ 155 mtx_lock(&(cpstr)->core_mtx); \ 156 } while (0) 157 158 #define SCTP_MCORE_UNLOCK(cpstr) do { \ 159 mtx_unlock(&(cpstr)->core_mtx); \ 160 } while (0) 161 162 #define SCTP_IPI_ADDR_INIT() do { \ 163 rw_init(&SCTP_BASE_INFO(ipi_addr_mtx), "sctp-addr"); \ 164 } while (0) 165 166 #define SCTP_IPI_ADDR_DESTROY() do { \ 167 if (rw_wowned(&SCTP_BASE_INFO(ipi_addr_mtx))) { \ 168 rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 169 } \ 170 rw_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 171 } while (0) 172 173 #define SCTP_IPI_ADDR_RLOCK() do { \ 174 rw_rlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 175 } while (0) 176 177 #define SCTP_IPI_ADDR_WLOCK() do { \ 178 rw_wlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 179 } while (0) 180 181 #define SCTP_IPI_ADDR_RUNLOCK() do { \ 182 rw_runlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 183 } while (0) 184 185 #define SCTP_IPI_ADDR_WUNLOCK() do { \ 186 rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \ 187 } while (0) 188 189 #define SCTP_IPI_ADDR_LOCK_ASSERT() do { \ 190 rw_assert(&SCTP_BASE_INFO(ipi_addr_mtx), RA_LOCKED); \ 191 } while (0) 192 193 #define SCTP_IPI_ADDR_WLOCK_ASSERT() do { \ 194 rw_assert(&SCTP_BASE_INFO(ipi_addr_mtx), RA_WLOCKED); \ 195 } while (0) 196 197 #define SCTP_IPI_ITERATOR_WQ_INIT() do { \ 198 mtx_init(&sctp_it_ctl.ipi_iterator_wq_mtx, "sctp-it-wq", \ 199 "sctp_it_wq", MTX_DEF); \ 200 } while (0) 201 202 #define SCTP_IPI_ITERATOR_WQ_DESTROY() do { \ 203 mtx_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx); \ 204 } while (0) 205 206 #define SCTP_IPI_ITERATOR_WQ_LOCK() do { \ 207 mtx_lock(&sctp_it_ctl.ipi_iterator_wq_mtx); \ 208 } while (0) 209 210 #define SCTP_IPI_ITERATOR_WQ_UNLOCK() do { \ 211 mtx_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx); \ 212 } while (0) 213 214 #define SCTP_IP_PKTLOG_INIT() do { \ 215 mtx_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), "sctp-pktlog", \ 216 "packetlog", MTX_DEF); \ 217 } while (0) 218 219 #define SCTP_IP_PKTLOG_DESTROY() do { \ 220 mtx_destroy(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \ 221 } while (0) 222 223 #define SCTP_IP_PKTLOG_LOCK() do { \ 224 mtx_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \ 225 } while (0) 226 227 #define SCTP_IP_PKTLOG_UNLOCK() do { \ 228 mtx_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \ 229 } while (0) 230 231 /* 232 * The INP locks we will use for locking an SCTP endpoint, so for example if 233 * we want to change something at the endpoint level for example random_store 234 * or cookie secrets we lock the INP level. 235 */ 236 237 #define SCTP_INP_READ_INIT(_inp) do { \ 238 mtx_init(&(_inp)->inp_rdata_mtx, "sctp-read", "inpr", \ 239 MTX_DEF | MTX_DUPOK); \ 240 } while (0) 241 242 #define SCTP_INP_READ_DESTROY(_inp) do { \ 243 mtx_destroy(&(_inp)->inp_rdata_mtx); \ 244 } while (0) 245 246 #define SCTP_INP_READ_LOCK(_inp) do { \ 247 mtx_lock(&(_inp)->inp_rdata_mtx); \ 248 } while (0) 249 250 #define SCTP_INP_READ_UNLOCK(_inp) do { \ 251 mtx_unlock(&(_inp)->inp_rdata_mtx); \ 252 } while (0) 253 254 #define SCTP_INP_LOCK_INIT(_inp) do { \ 255 mtx_init(&(_inp)->inp_mtx, "sctp-inp", "inp", \ 256 MTX_DEF | MTX_DUPOK); \ 257 } while (0) 258 259 #define SCTP_INP_LOCK_DESTROY(_inp) do { \ 260 mtx_destroy(&(_inp)->inp_mtx); \ 261 } while (0) 262 263 #define SCTP_INP_LOCK_CONTENDED(_inp) \ 264 ((_inp)->inp_mtx.mtx_lock & MTX_CONTESTED) 265 266 #define SCTP_INP_READ_CONTENDED(_inp) \ 267 ((_inp)->inp_rdata_mtx.mtx_lock & MTX_CONTESTED) 268 269 #ifdef SCTP_LOCK_LOGGING 270 #define SCTP_INP_RLOCK(_inp) do { \ 271 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ 272 sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ 273 mtx_lock(&(_inp)->inp_mtx); \ 274 } while (0) 275 276 #define SCTP_INP_WLOCK(_inp) do { \ 277 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ 278 sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \ 279 mtx_lock(&(_inp)->inp_mtx); \ 280 } while (0) 281 #else 282 #define SCTP_INP_RLOCK(_inp) do { \ 283 mtx_lock(&(_inp)->inp_mtx); \ 284 } while (0) 285 286 #define SCTP_INP_WLOCK(_inp) do { \ 287 mtx_lock(&(_inp)->inp_mtx); \ 288 } while (0) 289 #endif 290 291 #define SCTP_INP_RUNLOCK(_inp) do { \ 292 mtx_unlock(&(_inp)->inp_mtx); \ 293 } while (0) 294 295 #define SCTP_INP_WUNLOCK(_inp) do { \ 296 mtx_unlock(&(_inp)->inp_mtx); \ 297 } while (0) 298 299 #define SCTP_INP_RLOCK_ASSERT(_inp) do { \ 300 KASSERT(mtx_owned(&(_inp)->inp_mtx), \ 301 ("Don't own INP read lock")); \ 302 } while (0) 303 304 #define SCTP_INP_WLOCK_ASSERT(_inp) do { \ 305 KASSERT(mtx_owned(&(_inp)->inp_mtx), \ 306 ("Don't own INP write lock")); \ 307 } while (0) 308 309 #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1) 310 #define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1) 311 312 #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) do { \ 313 mtx_init(&(_inp)->inp_create_mtx, "sctp-create", "inp_create", \ 314 MTX_DEF | MTX_DUPOK); \ 315 } while (0) 316 317 #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) do { \ 318 mtx_destroy(&(_inp)->inp_create_mtx); \ 319 } while (0) 320 321 #ifdef SCTP_LOCK_LOGGING 322 #define SCTP_ASOC_CREATE_LOCK(_inp) do { \ 323 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ 324 sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \ 325 mtx_lock(&(_inp)->inp_create_mtx); \ 326 } while (0) 327 #else 328 #define SCTP_ASOC_CREATE_LOCK(_inp) do { \ 329 mtx_lock(&(_inp)->inp_create_mtx); \ 330 } while (0) 331 #endif 332 333 #define SCTP_ASOC_CREATE_UNLOCK(_inp) do { \ 334 mtx_unlock(&(_inp)->inp_create_mtx); \ 335 } while (0) 336 337 #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) \ 338 ((_inp)->inp_create_mtx.mtx_lock & MTX_CONTESTED) 339 340 #define SCTP_TCB_SEND_LOCK_INIT(_tcb) do { \ 341 mtx_init(&(_tcb)->tcb_send_mtx, "sctp-send-tcb", "tcbs", \ 342 MTX_DEF | MTX_DUPOK); \ 343 } while (0) 344 345 #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) do { \ 346 mtx_destroy(&(_tcb)->tcb_send_mtx); \ 347 } while (0) 348 349 #define SCTP_TCB_SEND_LOCK(_tcb) do { \ 350 mtx_lock(&(_tcb)->tcb_send_mtx); \ 351 } while (0) 352 353 #define SCTP_TCB_SEND_UNLOCK(_tcb) do { \ 354 mtx_unlock(&(_tcb)->tcb_send_mtx); \ 355 } while (0) 356 357 /* 358 * For the majority of things (once we have found the association) we will 359 * lock the actual association mutex. This will protect all the assoiciation 360 * level queues and streams and such. We will need to lock the socket layer 361 * when we stuff data up into the receiving sb_mb. I.e. we will need to do an 362 * extra SOCKBUF_LOCK(&so->so_rcv) even though the association is locked. 363 */ 364 365 #define SCTP_TCB_LOCK_INIT(_tcb) do { \ 366 mtx_init(&(_tcb)->tcb_mtx, "sctp-tcb", "tcb", \ 367 MTX_DEF | MTX_DUPOK); \ 368 } while (0) 369 370 #define SCTP_TCB_LOCK_DESTROY(_tcb) do { \ 371 mtx_destroy(&(_tcb)->tcb_mtx); \ 372 } while (0) 373 374 #ifdef SCTP_LOCK_LOGGING 375 #define SCTP_TCB_LOCK(_tcb) do { \ 376 if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \ 377 sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \ 378 mtx_lock(&(_tcb)->tcb_mtx); \ 379 } while (0) 380 #else 381 #define SCTP_TCB_LOCK(_tcb) do { \ 382 mtx_lock(&(_tcb)->tcb_mtx); \ 383 } while (0) 384 385 #endif 386 387 #define SCTP_TCB_TRYLOCK(_tcb) \ 388 mtx_trylock(&(_tcb)->tcb_mtx) 389 390 #define SCTP_TCB_UNLOCK(_tcb) do { \ 391 mtx_unlock(&(_tcb)->tcb_mtx); \ 392 } while (0) 393 394 #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) do { \ 395 if (mtx_owned(&(_tcb)->tcb_mtx)) \ 396 mtx_unlock(&(_tcb)->tcb_mtx); \ 397 } while (0) 398 399 #define SCTP_TCB_LOCK_ASSERT(_tcb) do { \ 400 KASSERT(mtx_owned(&(_tcb)->tcb_mtx), \ 401 ("Don't own TCB lock")); \ 402 } while (0) 403 404 #define SCTP_ITERATOR_LOCK_INIT() do { \ 405 mtx_init(&sctp_it_ctl.it_mtx, "sctp-it", "iterator", MTX_DEF); \ 406 } while (0) 407 408 #define SCTP_ITERATOR_LOCK_DESTROY() do { \ 409 mtx_destroy(&sctp_it_ctl.it_mtx); \ 410 } while (0) 411 412 #define SCTP_ITERATOR_LOCK() \ 413 do { \ 414 KASSERT(!mtx_owned(&sctp_it_ctl.it_mtx), \ 415 ("Own the iterator lock")); \ 416 mtx_lock(&sctp_it_ctl.it_mtx); \ 417 } while (0) 418 419 #define SCTP_ITERATOR_UNLOCK() do { \ 420 mtx_unlock(&sctp_it_ctl.it_mtx); \ 421 } while (0) 422 423 #define SCTP_WQ_ADDR_INIT() do { \ 424 mtx_init(&SCTP_BASE_INFO(wq_addr_mtx), \ 425 "sctp-addr-wq","sctp_addr_wq", MTX_DEF); \ 426 } while (0) 427 428 #define SCTP_WQ_ADDR_DESTROY() do { \ 429 if (mtx_owned(&SCTP_BASE_INFO(wq_addr_mtx))) { \ 430 mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \ 431 } \ 432 mtx_destroy(&SCTP_BASE_INFO(wq_addr_mtx)); \ 433 } while (0) 434 435 #define SCTP_WQ_ADDR_LOCK() do { \ 436 mtx_lock(&SCTP_BASE_INFO(wq_addr_mtx)); \ 437 } while (0) 438 439 #define SCTP_WQ_ADDR_UNLOCK() do { \ 440 mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \ 441 } while (0) 442 443 #define SCTP_WQ_ADDR_LOCK_ASSERT() do { \ 444 KASSERT(mtx_owned(&SCTP_BASE_INFO(wq_addr_mtx)), \ 445 ("Don't own the ADDR-WQ lock")); \ 446 } while (0) 447 448 #define SCTP_INCR_EP_COUNT() do { \ 449 atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \ 450 } while (0) 451 452 #define SCTP_DECR_EP_COUNT() do { \ 453 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \ 454 } while (0) 455 456 #define SCTP_INCR_ASOC_COUNT() do { \ 457 atomic_add_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \ 458 } while (0) 459 460 #define SCTP_DECR_ASOC_COUNT() do { \ 461 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \ 462 } while (0) 463 464 #define SCTP_INCR_LADDR_COUNT() do { \ 465 atomic_add_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \ 466 } while (0) 467 468 #define SCTP_DECR_LADDR_COUNT() do { \ 469 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \ 470 } while (0) 471 472 #define SCTP_INCR_RADDR_COUNT() do { \ 473 atomic_add_int(&SCTP_BASE_INFO(ipi_count_raddr), 1); \ 474 } while (0) 475 476 #define SCTP_DECR_RADDR_COUNT() do { \ 477 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_raddr),1); \ 478 } while (0) 479 480 #define SCTP_INCR_CHK_COUNT() do { \ 481 atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \ 482 } while (0) 483 484 #define SCTP_DECR_CHK_COUNT() do { \ 485 KASSERT(SCTP_BASE_INFO(ipi_count_chunk) > 0, \ 486 ("ipi_count_chunk would become negative")); \ 487 if (SCTP_BASE_INFO(ipi_count_chunk) != 0) \ 488 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), \ 489 1); \ 490 } while (0) 491 492 #define SCTP_INCR_READQ_COUNT() do { \ 493 atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \ 494 } while (0) 495 496 #define SCTP_DECR_READQ_COUNT() do { \ 497 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \ 498 } while (0) 499 500 #define SCTP_INCR_STRMOQ_COUNT() do { \ 501 atomic_add_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \ 502 } while (0) 503 504 #define SCTP_DECR_STRMOQ_COUNT() do { \ 505 atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \ 506 } while (0) 507 508 #if defined(SCTP_SO_LOCK_TESTING) 509 #define SCTP_INP_SO(sctpinp) \ 510 (sctpinp)->ip_inp.inp.inp_socket 511 #define SCTP_SOCKET_LOCK(so, refcnt) 512 #define SCTP_SOCKET_UNLOCK(so, refcnt) 513 #endif 514 515 #endif 516