Deleted Added
full compact
sctp_lock_bsd.h (165220) sctp_lock_bsd.h (167598)
1#ifndef __sctp_lock_bsd_h__
2#define __sctp_lock_bsd_h__
3/*-
4 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 55 unchanged lines hidden (view full) ---

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 sctppcbinfo list's we will do a SCTP_INP_INFO_WLOCK().
70 */
71#include <sys/cdefs.h>
1#ifndef __sctp_lock_bsd_h__
2#define __sctp_lock_bsd_h__
3/*-
4 * Copyright (c) 2001-2006, Cisco Systems, Inc. All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
8 *

--- 55 unchanged lines hidden (view full) ---

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 sctppcbinfo list's we will do a SCTP_INP_INFO_WLOCK().
70 */
71#include <sys/cdefs.h>
72__FBSDID("$FreeBSD: head/sys/netinet/sctp_lock_bsd.h 165220 2006-12-14 17:02:55Z rrs $");
72__FBSDID("$FreeBSD: head/sys/netinet/sctp_lock_bsd.h 167598 2007-03-15 11:27:14Z rrs $");
73
74
75extern struct sctp_foo_stuff sctp_logoff[];
76extern int sctp_logoff_stuff;
77
78#define SCTP_IPI_COUNT_INIT()
79
80#define SCTP_STATLOG_INIT_LOCK()

--- 20 unchanged lines hidden (view full) ---

101} while (0)
102
103
104#define SCTP_INP_INFO_WLOCK() do { \
105 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
106} while (0)
107
108
73
74
75extern struct sctp_foo_stuff sctp_logoff[];
76extern int sctp_logoff_stuff;
77
78#define SCTP_IPI_COUNT_INIT()
79
80#define SCTP_STATLOG_INIT_LOCK()

--- 20 unchanged lines hidden (view full) ---

101} while (0)
102
103
104#define SCTP_INP_INFO_WLOCK() do { \
105 mtx_lock(&sctppcbinfo.ipi_ep_mtx); \
106} while (0)
107
108
109
110#define SCTP_IPI_ADDR_INIT() \
109#define SCTP_IPI_ADDR_INIT() \
111 mtx_init(&sctppcbinfo.ipi_addr_mtx, "sctp-addr-wq", "sctp_addr_wq", MTX_DEF)
110 mtx_init(&sctppcbinfo.ipi_addr_mtx, "sctp-addr", "sctp_addr", MTX_DEF)
112
113#define SCTP_IPI_ADDR_DESTROY() \
114 mtx_destroy(&sctppcbinfo.ipi_addr_mtx)
115
116#define SCTP_IPI_ADDR_LOCK() do { \
117 mtx_lock(&sctppcbinfo.ipi_addr_mtx); \
118} while (0)
119
120#define SCTP_IPI_ADDR_UNLOCK() mtx_unlock(&sctppcbinfo.ipi_addr_mtx)
121
111
112#define SCTP_IPI_ADDR_DESTROY() \
113 mtx_destroy(&sctppcbinfo.ipi_addr_mtx)
114
115#define SCTP_IPI_ADDR_LOCK() do { \
116 mtx_lock(&sctppcbinfo.ipi_addr_mtx); \
117} while (0)
118
119#define SCTP_IPI_ADDR_UNLOCK() mtx_unlock(&sctppcbinfo.ipi_addr_mtx)
120
121
122
123#define SCTP_IPI_ITERATOR_WQ_INIT() \
124 mtx_init(&sctppcbinfo.ipi_iterator_wq_mtx, "sctp-it-wq", "sctp_it_wq", MTX_DEF)
125
126#define SCTP_IPI_ITERATOR_WQ_DESTROY() \
127 mtx_destroy(&sctppcbinfo.ipi_iterator_wq_mtx)
128
129#define SCTP_IPI_ITERATOR_WQ_LOCK() do { \
130 mtx_lock(&sctppcbinfo.ipi_iterator_wq_mtx); \
131} while (0)
132
133#define SCTP_IPI_ITERATOR_WQ_UNLOCK() mtx_unlock(&sctppcbinfo.ipi_iterator_wq_mtx)
134
135
136
137
138
122#define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
123#define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
124
125/*
126 * The INP locks we will use for locking an SCTP endpoint, so for example if
127 * we want to change something at the endpoint level for example random_store
128 * or cookie secrets we lock the INP level.
129 */

--- 55 unchanged lines hidden (view full) ---

185#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_send_mtx)
186
187#define SCTP_TCB_SEND_LOCK(_tcb) do { \
188 mtx_lock(&(_tcb)->tcb_send_mtx); \
189} while (0)
190
191#define SCTP_TCB_SEND_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_send_mtx)
192
139#define SCTP_INP_INFO_RUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
140#define SCTP_INP_INFO_WUNLOCK() mtx_unlock(&sctppcbinfo.ipi_ep_mtx)
141
142/*
143 * The INP locks we will use for locking an SCTP endpoint, so for example if
144 * we want to change something at the endpoint level for example random_store
145 * or cookie secrets we lock the INP level.
146 */

--- 55 unchanged lines hidden (view full) ---

202#define SCTP_TCB_SEND_LOCK_DESTROY(_tcb) mtx_destroy(&(_tcb)->tcb_send_mtx)
203
204#define SCTP_TCB_SEND_LOCK(_tcb) do { \
205 mtx_lock(&(_tcb)->tcb_send_mtx); \
206} while (0)
207
208#define SCTP_TCB_SEND_UNLOCK(_tcb) mtx_unlock(&(_tcb)->tcb_send_mtx)
209
193#ifdef INVARIANTS
194
195#define SCTP_INP_INCR_REF(_inp) { int x; \
196 atomic_add_int(&((_inp)->refcount), 1); \
197 x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \
198 if(x == 30000) \
199 sctp_logoff_stuff = x = 0; \
200 sctp_logoff[x].inp = _inp; \
201 sctp_logoff[x].ticks = ticks; \
202 sctp_logoff[x].lineno = __LINE__; \
203 sctp_logoff[x].updown = 1; \
204}
205
206#define SCTP_INP_DECR_REF(_inp) { int x; \
207 if (atomic_fetchadd_int(&((_inp)->refcount), -1) == 0 ) panic("refcount goes negative"); \
208 x = atomic_fetchadd_int(&sctp_logoff_stuff, 1); \
209 if(x == 30000) \
210 sctp_logoff_stuff = x = 0; \
211 sctp_logoff[x].inp = _inp; \
212 sctp_logoff[x].ticks = ticks; \
213 sctp_logoff[x].lineno = __LINE__; \
214 sctp_logoff[x].updown = 0; \
215}
216
217#else
218
219#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
220#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
221
210#define SCTP_INP_INCR_REF(_inp) atomic_add_int(&((_inp)->refcount), 1)
211#define SCTP_INP_DECR_REF(_inp) atomic_add_int(&((_inp)->refcount), -1)
212
222#endif
223
224#ifdef SCTP_LOCK_LOGGING
225#define SCTP_ASOC_CREATE_LOCK(_inp) \
226 do { \
227 sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
228 mtx_lock(&(_inp)->inp_create_mtx); \
229 } while (0)
230#else

--- 157 unchanged lines hidden ---
213
214#ifdef SCTP_LOCK_LOGGING
215#define SCTP_ASOC_CREATE_LOCK(_inp) \
216 do { \
217 sctp_log_lock(_inp, (struct sctp_tcb *)NULL, SCTP_LOG_LOCK_CREATE); \
218 mtx_lock(&(_inp)->inp_create_mtx); \
219 } while (0)
220#else

--- 157 unchanged lines hidden ---