sctp_lock_bsd.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504
  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. #include <sys/cdefs.h>
  35. __FBSDID("$FreeBSD$");
  36. #ifndef _NETINET_SCTP_LOCK_BSD_H_
  37. #define _NETINET_SCTP_LOCK_BSD_H_
  38. /*
  39. * General locking concepts: The goal of our locking is to of course provide
  40. * consistency and yet minimize overhead. We will attempt to use
  41. * non-recursive locks which are supposed to be quite inexpensive. Now in
  42. * order to do this the goal is that most functions are not aware of locking.
  43. * Once we have a TCB we lock it and unlock when we are through. This means
  44. * that the TCB lock is kind-of a "global" lock when working on an
  45. * association. Caution must be used when asserting a TCB_LOCK since if we
  46. * recurse we deadlock.
  47. *
  48. * Most other locks (INP and INFO) attempt to localize the locking i.e. we try
  49. * to contain the lock and unlock within the function that needs to lock it.
  50. * This sometimes mean we do extra locks and unlocks and lose a bit of
  51. * efficiency, but if the performance statements about non-recursive locks are
  52. * true this should not be a problem. One issue that arises with this only
  53. * lock when needed is that if an implicit association setup is done we have
  54. * a problem. If at the time I lookup an association I have NULL in the tcb
  55. * return, by the time I call to create the association some other processor
  56. * could have created it. This is what the CREATE lock on the endpoint.
  57. * Places where we will be implicitly creating the association OR just
  58. * creating an association (the connect call) will assert the CREATE_INP
  59. * lock. This will assure us that during all the lookup of INP and INFO if
  60. * another creator is also locking/looking up we can gate the two to
  61. * synchronize. So the CREATE_INP lock is also another one we must use
  62. * extreme caution in locking to make sure we don't hit a re-entrancy issue.
  63. *
  64. */
  65. /*
  66. * When working with the global SCTP lists we lock and unlock the INP_INFO
  67. * lock. So when we go to lookup an association we will want to do a
  68. * SCTP_INP_INFO_RLOCK() and then when we want to add a new association to
  69. * the SCTP_BASE_INFO() list's we will do a SCTP_INP_INFO_WLOCK().
  70. */
  71. #define SCTP_IPI_COUNT_INIT()
  72. #define SCTP_STATLOG_INIT_LOCK()
  73. #define SCTP_STATLOG_DESTROY()
  74. #define SCTP_STATLOG_LOCK()
  75. #define SCTP_STATLOG_UNLOCK()
  76. #define SCTP_INP_INFO_LOCK_INIT() do { \
  77. rw_init(&SCTP_BASE_INFO(ipi_ep_mtx), "sctp-info"); \
  78. } while (0)
  79. #define SCTP_INP_INFO_LOCK_DESTROY() do { \
  80. if (rw_wowned(&SCTP_BASE_INFO(ipi_ep_mtx))) { \
  81. rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  82. } \
  83. rw_destroy(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  84. } while (0)
  85. #define SCTP_INP_INFO_RLOCK() do { \
  86. rw_rlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  87. } while (0)
  88. #define SCTP_INP_INFO_WLOCK() do { \
  89. rw_wlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  90. } while (0)
  91. #define SCTP_INP_INFO_RUNLOCK() do { \
  92. rw_runlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  93. } while (0)
  94. #define SCTP_INP_INFO_WUNLOCK() do { \
  95. rw_wunlock(&SCTP_BASE_INFO(ipi_ep_mtx)); \
  96. } while (0)
  97. #define SCTP_MCORE_QLOCK_INIT(cpstr) do { \
  98. mtx_init(&(cpstr)->que_mtx, "sctp-mcore_queue","queue_lock", \
  99. MTX_DEF | MTX_DUPOK); \
  100. } while (0)
  101. #define SCTP_MCORE_QDESTROY(cpstr) do { \
  102. if (mtx_owned(&(cpstr)->core_mtx)) { \
  103. mtx_unlock(&(cpstr)->que_mtx); \
  104. } \
  105. mtx_destroy(&(cpstr)->que_mtx); \
  106. } while (0)
  107. #define SCTP_MCORE_QLOCK(cpstr) do { \
  108. mtx_lock(&(cpstr)->que_mtx); \
  109. } while (0)
  110. #define SCTP_MCORE_QUNLOCK(cpstr) do { \
  111. mtx_unlock(&(cpstr)->que_mtx); \
  112. } while (0)
  113. #define SCTP_MCORE_LOCK_INIT(cpstr) do { \
  114. mtx_init(&(cpstr)->core_mtx, "sctp-cpulck","cpu_proc_lock", \
  115. MTX_DEF | MTX_DUPOK); \
  116. } while (0)
  117. #define SCTP_MCORE_DESTROY(cpstr) do { \
  118. if (mtx_owned(&(cpstr)->core_mtx)) { \
  119. mtx_unlock(&(cpstr)->core_mtx); \
  120. } \
  121. mtx_destroy(&(cpstr)->core_mtx); \
  122. } while (0)
  123. #define SCTP_MCORE_LOCK(cpstr) do { \
  124. mtx_lock(&(cpstr)->core_mtx); \
  125. } while (0)
  126. #define SCTP_MCORE_UNLOCK(cpstr) do { \
  127. mtx_unlock(&(cpstr)->core_mtx); \
  128. } while (0)
  129. #define SCTP_IPI_ADDR_INIT() do { \
  130. rw_init(&SCTP_BASE_INFO(ipi_addr_mtx), "sctp-addr"); \
  131. } while (0)
  132. #define SCTP_IPI_ADDR_DESTROY() do { \
  133. if (rw_wowned(&SCTP_BASE_INFO(ipi_addr_mtx))) { \
  134. rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  135. } \
  136. rw_destroy(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  137. } while (0)
  138. #define SCTP_IPI_ADDR_RLOCK() do { \
  139. rw_rlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  140. } while (0)
  141. #define SCTP_IPI_ADDR_WLOCK() do { \
  142. rw_wlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  143. } while (0)
  144. #define SCTP_IPI_ADDR_RUNLOCK() do { \
  145. rw_runlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  146. } while (0)
  147. #define SCTP_IPI_ADDR_WUNLOCK() do { \
  148. rw_wunlock(&SCTP_BASE_INFO(ipi_addr_mtx)); \
  149. } while (0)
  150. #define SCTP_IPI_ADDR_LOCK_ASSERT() do { \
  151. rw_assert(&SCTP_BASE_INFO(ipi_addr_mtx), RA_LOCKED); \
  152. } while (0)
  153. #define SCTP_IPI_ADDR_WLOCK_ASSERT() do { \
  154. rw_assert(&SCTP_BASE_INFO(ipi_addr_mtx), RA_WLOCKED); \
  155. } while (0)
  156. #define SCTP_IPI_ITERATOR_WQ_INIT() do { \
  157. mtx_init(&sctp_it_ctl.ipi_iterator_wq_mtx, "sctp-it-wq", \
  158. "sctp_it_wq", MTX_DEF); \
  159. } while (0)
  160. #define SCTP_IPI_ITERATOR_WQ_DESTROY() do { \
  161. mtx_destroy(&sctp_it_ctl.ipi_iterator_wq_mtx); \
  162. } while (0)
  163. #define SCTP_IPI_ITERATOR_WQ_LOCK() do { \
  164. mtx_lock(&sctp_it_ctl.ipi_iterator_wq_mtx); \
  165. } while (0)
  166. #define SCTP_IPI_ITERATOR_WQ_UNLOCK() do { \
  167. mtx_unlock(&sctp_it_ctl.ipi_iterator_wq_mtx); \
  168. } while (0)
  169. #define SCTP_IP_PKTLOG_INIT() do { \
  170. mtx_init(&SCTP_BASE_INFO(ipi_pktlog_mtx), "sctp-pktlog", \
  171. "packetlog", MTX_DEF); \
  172. } while (0)
  173. #define SCTP_IP_PKTLOG_DESTROY() do { \
  174. mtx_destroy(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \
  175. } while (0)
  176. #define SCTP_IP_PKTLOG_LOCK() do { \
  177. mtx_lock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \
  178. } while (0)
  179. #define SCTP_IP_PKTLOG_UNLOCK() do { \
  180. mtx_unlock(&SCTP_BASE_INFO(ipi_pktlog_mtx)); \
  181. } while (0)
  182. /*
  183. * The INP locks we will use for locking an SCTP endpoint, so for example if
  184. * we want to change something at the endpoint level for example random_store
  185. * or cookie secrets we lock the INP level.
  186. */
  187. #define SCTP_INP_READ_INIT(_inp) do { \
  188. mtx_init(&(_inp)->inp_rdata_mtx, "sctp-read", "inpr", \
  189. MTX_DEF | MTX_DUPOK); \
  190. } while (0)
  191. #define SCTP_INP_READ_DESTROY(_inp) do { \
  192. mtx_destroy(&(_inp)->inp_rdata_mtx); \
  193. } while (0)
  194. #define SCTP_INP_READ_LOCK(_inp) do { \
  195. mtx_lock(&(_inp)->inp_rdata_mtx); \
  196. } while (0)
  197. #define SCTP_INP_READ_UNLOCK(_inp) do { \
  198. mtx_unlock(&(_inp)->inp_rdata_mtx); \
  199. } while (0)
  200. #define SCTP_INP_LOCK_INIT(_inp) do { \
  201. mtx_init(&(_inp)->inp_mtx, "sctp-inp", "inp", \
  202. MTX_DEF | MTX_DUPOK); \
  203. } while (0)
  204. #define SCTP_INP_LOCK_DESTROY(_inp) do { \
  205. mtx_destroy(&(_inp)->inp_mtx); \
  206. } while (0)
  207. #define SCTP_INP_LOCK_CONTENDED(_inp) \
  208. ((_inp)->inp_mtx.mtx_lock & MTX_CONTESTED)
  209. #define SCTP_INP_READ_CONTENDED(_inp) \
  210. ((_inp)->inp_rdata_mtx.mtx_lock & MTX_CONTESTED)
  211. #ifdef SCTP_LOCK_LOGGING
  212. #define SCTP_INP_RLOCK(_inp) do { \
  213. if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
  214. sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
  215. mtx_lock(&(_inp)->inp_mtx); \
  216. } while (0)
  217. #define SCTP_INP_WLOCK(_inp) do { \
  218. if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
  219. sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_INP); \
  220. mtx_lock(&(_inp)->inp_mtx); \
  221. } while (0)
  222. #else
  223. #define SCTP_INP_RLOCK(_inp) do { \
  224. mtx_lock(&(_inp)->inp_mtx); \
  225. } while (0)
  226. #define SCTP_INP_WLOCK(_inp) do { \
  227. mtx_lock(&(_inp)->inp_mtx); \
  228. } while (0)
  229. #endif
  230. #define SCTP_INP_RUNLOCK(_inp) do { \
  231. mtx_unlock(&(_inp)->inp_mtx); \
  232. } while (0)
  233. #define SCTP_INP_WUNLOCK(_inp) do { \
  234. mtx_unlock(&(_inp)->inp_mtx); \
  235. } while (0)
  236. #define SCTP_INP_RLOCK_ASSERT(_inp) do { \
  237. KASSERT(mtx_owned(&(_inp)->inp_mtx), \
  238. ("Don't own INP read lock")); \
  239. } while (0)
  240. #define SCTP_INP_WLOCK_ASSERT(_inp) do { \
  241. KASSERT(mtx_owned(&(_inp)->inp_mtx), \
  242. ("Don't own INP write lock")); \
  243. } while (0)
  244. #define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
  245. #define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
  246. #define SCTP_ASOC_CREATE_LOCK_INIT(_inp) do { \
  247. mtx_init(&(_inp)->inp_create_mtx, "sctp-create", "inp_create", \
  248. MTX_DEF | MTX_DUPOK); \
  249. } while (0)
  250. #define SCTP_ASOC_CREATE_LOCK_DESTROY(_inp) do { \
  251. mtx_destroy(&(_inp)->inp_create_mtx); \
  252. } while (0)
  253. #ifdef SCTP_LOCK_LOGGING
  254. #define SCTP_ASOC_CREATE_LOCK(_inp) do { \
  255. if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
  256. sctp_log_lock(_inp, NULL, SCTP_LOG_LOCK_CREATE); \
  257. mtx_lock(&(_inp)->inp_create_mtx); \
  258. } while (0)
  259. #else
  260. #define SCTP_ASOC_CREATE_LOCK(_inp) do { \
  261. mtx_lock(&(_inp)->inp_create_mtx); \
  262. } while (0)
  263. #endif
  264. #define SCTP_ASOC_CREATE_UNLOCK(_inp) do { \
  265. mtx_unlock(&(_inp)->inp_create_mtx); \
  266. } while (0)
  267. #define SCTP_ASOC_CREATE_LOCK_CONTENDED(_inp) \
  268. ((_inp)->inp_create_mtx.mtx_lock & MTX_CONTESTED)
  269. #define SCTP_TCB_SEND_LOCK_INIT(_tcb) do { \
  270. mtx_init(&(_tcb)->tcb_send_mtx, "sctp-send-tcb", "tcbs", \
  271. MTX_DEF | MTX_DUPOK); \
  272. } while (0)
  273. #define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) do { \
  274. mtx_destroy(&(_tcb)->tcb_send_mtx); \
  275. } while (0)
  276. #define SCTP_TCB_SEND_LOCK(_tcb) do { \
  277. mtx_lock(&(_tcb)->tcb_send_mtx); \
  278. } while (0)
  279. #define SCTP_TCB_SEND_UNLOCK(_tcb) do { \
  280. mtx_unlock(&(_tcb)->tcb_send_mtx); \
  281. } while (0)
  282. /*
  283. * For the majority of things (once we have found the association) we will
  284. * lock the actual association mutex. This will protect all the assoiciation
  285. * level queues and streams and such. We will need to lock the socket layer
  286. * when we stuff data up into the receiving sb_mb. I.e. we will need to do an
  287. * extra SOCKBUF_LOCK(&so->so_rcv) even though the association is locked.
  288. */
  289. #define SCTP_TCB_LOCK_INIT(_tcb) do { \
  290. mtx_init(&(_tcb)->tcb_mtx, "sctp-tcb", "tcb", \
  291. MTX_DEF | MTX_DUPOK); \
  292. } while (0)
  293. #define SCTP_TCB_LOCK_DESTROY(_tcb) do { \
  294. mtx_destroy(&(_tcb)->tcb_mtx); \
  295. } while (0)
  296. #ifdef SCTP_LOCK_LOGGING
  297. #define SCTP_TCB_LOCK(_tcb) do { \
  298. if (SCTP_BASE_SYSCTL(sctp_logging_level) & SCTP_LOCK_LOGGING_ENABLE) \
  299. sctp_log_lock(_tcb->sctp_ep, _tcb, SCTP_LOG_LOCK_TCB); \
  300. mtx_lock(&(_tcb)->tcb_mtx); \
  301. } while (0)
  302. #else
  303. #define SCTP_TCB_LOCK(_tcb) do { \
  304. mtx_lock(&(_tcb)->tcb_mtx); \
  305. } while (0)
  306. #endif
  307. #define SCTP_TCB_TRYLOCK(_tcb) \
  308. mtx_trylock(&(_tcb)->tcb_mtx)
  309. #define SCTP_TCB_UNLOCK(_tcb) do { \
  310. mtx_unlock(&(_tcb)->tcb_mtx); \
  311. } while (0)
  312. #define SCTP_TCB_UNLOCK_IFOWNED(_tcb) do { \
  313. if (mtx_owned(&(_tcb)->tcb_mtx)) \
  314. mtx_unlock(&(_tcb)->tcb_mtx); \
  315. } while (0)
  316. #define SCTP_TCB_LOCK_ASSERT(_tcb) do { \
  317. KASSERT(mtx_owned(&(_tcb)->tcb_mtx), \
  318. ("Don't own TCB lock")); \
  319. } while (0)
  320. #define SCTP_ITERATOR_LOCK_INIT() do { \
  321. mtx_init(&sctp_it_ctl.it_mtx, "sctp-it", "iterator", MTX_DEF); \
  322. } while (0)
  323. #define SCTP_ITERATOR_LOCK_DESTROY() do { \
  324. mtx_destroy(&sctp_it_ctl.it_mtx); \
  325. } while (0)
  326. #define SCTP_ITERATOR_LOCK() \
  327. do { \
  328. KASSERT(!mtx_owned(&sctp_it_ctl.it_mtx), \
  329. ("Own the iterator lock")); \
  330. mtx_lock(&sctp_it_ctl.it_mtx); \
  331. } while (0)
  332. #define SCTP_ITERATOR_UNLOCK() do { \
  333. mtx_unlock(&sctp_it_ctl.it_mtx); \
  334. } while (0)
  335. #define SCTP_WQ_ADDR_INIT() do { \
  336. mtx_init(&SCTP_BASE_INFO(wq_addr_mtx), \
  337. "sctp-addr-wq","sctp_addr_wq", MTX_DEF); \
  338. } while (0)
  339. #define SCTP_WQ_ADDR_DESTROY() do { \
  340. if (mtx_owned(&SCTP_BASE_INFO(wq_addr_mtx))) { \
  341. mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \
  342. } \
  343. mtx_destroy(&SCTP_BASE_INFO(wq_addr_mtx)); \
  344. } while (0)
  345. #define SCTP_WQ_ADDR_LOCK() do { \
  346. mtx_lock(&SCTP_BASE_INFO(wq_addr_mtx)); \
  347. } while (0)
  348. #define SCTP_WQ_ADDR_UNLOCK() do { \
  349. mtx_unlock(&SCTP_BASE_INFO(wq_addr_mtx)); \
  350. } while (0)
  351. #define SCTP_WQ_ADDR_LOCK_ASSERT() do { \
  352. KASSERT(mtx_owned(&SCTP_BASE_INFO(wq_addr_mtx)), \
  353. ("Don't own the ADDR-WQ lock")); \
  354. } while (0)
  355. #define SCTP_INCR_EP_COUNT() do { \
  356. atomic_add_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
  357. } while (0)
  358. #define SCTP_DECR_EP_COUNT() do { \
  359. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_ep), 1); \
  360. } while (0)
  361. #define SCTP_INCR_ASOC_COUNT() do { \
  362. atomic_add_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \
  363. } while (0)
  364. #define SCTP_DECR_ASOC_COUNT() do { \
  365. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_asoc), 1); \
  366. } while (0)
  367. #define SCTP_INCR_LADDR_COUNT() do { \
  368. atomic_add_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \
  369. } while (0)
  370. #define SCTP_DECR_LADDR_COUNT() do { \
  371. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_laddr), 1); \
  372. } while (0)
  373. #define SCTP_INCR_RADDR_COUNT() do { \
  374. atomic_add_int(&SCTP_BASE_INFO(ipi_count_raddr), 1); \
  375. } while (0)
  376. #define SCTP_DECR_RADDR_COUNT() do { \
  377. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_raddr),1); \
  378. } while (0)
  379. #define SCTP_INCR_CHK_COUNT() do { \
  380. atomic_add_int(&SCTP_BASE_INFO(ipi_count_chunk), 1); \
  381. } while (0)
  382. #define SCTP_DECR_CHK_COUNT() do { \
  383. KASSERT(SCTP_BASE_INFO(ipi_count_chunk) > 0, \
  384. ("ipi_count_chunk would become negative")); \
  385. if (SCTP_BASE_INFO(ipi_count_chunk) != 0) \
  386. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_chunk), \
  387. 1); \
  388. } while (0)
  389. #define SCTP_INCR_READQ_COUNT() do { \
  390. atomic_add_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \
  391. } while (0)
  392. #define SCTP_DECR_READQ_COUNT() do { \
  393. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_readq), 1); \
  394. } while (0)
  395. #define SCTP_INCR_STRMOQ_COUNT() do { \
  396. atomic_add_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \
  397. } while (0)
  398. #define SCTP_DECR_STRMOQ_COUNT() do { \
  399. atomic_subtract_int(&SCTP_BASE_INFO(ipi_count_strmoq), 1); \
  400. } while (0)
  401. #if defined(SCTP_SO_LOCK_TESTING)
  402. #define SCTP_INP_SO(sctpinp) \
  403. (sctpinp)->ip_inp.inp.inp_socket
  404. #define SCTP_SOCKET_LOCK(so, refcnt)
  405. #define SCTP_SOCKET_UNLOCK(so, refcnt)
  406. #endif
  407. #endif